2 * Copyright (C) 2016 Apple, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 module("BuildBotQueueView");
28 var settings = new Settings;
29 test("_appendPendingRevisionCount", function()
31 trac = new MockTrac();
32 var queue = new MockBuildbotQueue();
40 var view = new MockBuildbotQueueView([queue]);
41 view._appendPendingRevisionCount(queue);
42 var revisionsBehind = view.element.getElementsByClassName("message")[0].innerHTML.match(/.*(\d+) revision(|s) behind/)[1];
43 equal(revisionsBehind, "1", "assert revisions behind");
46 module("BuildBotQueue", {
48 this.queue = new MockBuildbotQueue();
49 this.queue.branches = [{
58 test("compareIterations by revisions", function()
61 var iteration1 = new BuildbotIteration(this.queue, 1, finished);
62 var iteration2 = new BuildbotIteration(this.queue, 2, finished);
63 iteration1.revision = { "openSource": 33018 };
64 iteration2.revision = { "openSource": 33019 };
65 iteration1.loaded = true;
66 iteration2.loaded = true;
67 ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
68 ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
69 strictEqual(this.queue.compareIterations(iteration2, iteration2), 0, "compareIterations: equal");
72 test("compareIterations by loaded (one revision missing)", function()
75 var iteration1 = new BuildbotIteration(this.queue, 1, finished);
76 var iteration2 = new BuildbotIteration(this.queue, 2, finished);
77 iteration1.revision = {};
78 iteration2.revision = { "openSource": 33019 };
79 iteration1.loaded = false;
80 iteration2.loaded = true;
81 ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
82 ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
85 test("compareIterations by loaded (same revision)", function()
88 var iteration1 = new BuildbotIteration(this.queue, 1, finished);
89 var iteration2 = new BuildbotIteration(this.queue, 2, finished);
90 iteration1.revision = { "openSource": 33019 };
91 iteration2.revision = { "openSource": 33019 };
92 iteration1.loaded = false;
93 iteration2.loaded = true;
94 ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
95 ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
98 test("compareIterations by id (revisions not specified)", function()
100 var finished = false;
101 var iteration1 = new BuildbotIteration(this.queue, 1, finished);
102 var iteration2 = new BuildbotIteration(this.queue, 2, finished);
103 iteration1.revision = {};
104 iteration2.revision = {};
105 iteration1.loaded = false;
106 iteration2.loaded = false;
107 ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
108 ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
109 strictEqual(this.queue.compareIterations(iteration2, iteration2), 0, "compareIterations: equal");
112 test("compareIterations by id (same revision)", function()
114 var finished = false;
115 var iteration1 = new BuildbotIteration(this.queue, 1, finished);
116 var iteration2 = new BuildbotIteration(this.queue, 2, finished);
117 iteration1.revision = { "openSource": 33019 };
118 iteration2.revision = { "openSource": 33019 };
119 iteration1.loaded = false;
120 iteration2.loaded = false;
121 ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
122 ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
123 strictEqual(this.queue.compareIterations(iteration2, iteration2), 0, "compareIterations: equal");
126 test("compareIterationsByRevisions", function()
128 var finished = false;
129 var iteration1 = new BuildbotIteration(this.queue, 1, finished);
130 var iteration2 = new BuildbotIteration(this.queue, 2, finished);
131 iteration1.revision = { "openSource": 33018 };
132 iteration2.revision = { "openSource": 33019 };
133 iteration1.loaded = true;
134 iteration2.loaded = false;
135 ok(this.queue.compareIterationsByRevisions(iteration2, iteration1) < 0, "compareIterationsByRevisions: less than");
136 ok(this.queue.compareIterationsByRevisions(iteration1, iteration2) > 0, "compareIterationsByRevisions: greater than");
137 strictEqual(this.queue.compareIterationsByRevisions(iteration2, iteration2), 0, "compareIterationsByRevisions: equal");