OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="ct-tree-status.html"> | 7 <link rel="import" href="ct-tree-status.html"> |
8 | 8 |
9 <script> | 9 <script> |
10 (function () { | 10 (function () { |
(...skipping 11 matching lines...) Expand all Loading... |
22 "message": "Tree is throttled just for fun", | 22 "message": "Tree is throttled just for fun", |
23 "can_commit_freely": false | 23 "can_commit_freely": false |
24 } | 24 } |
25 | 25 |
26 closedTreeJson = { | 26 closedTreeJson = { |
27 "username": "username@test.org", | 27 "username": "username@test.org", |
28 "message": "Tree is closed for maintenance", | 28 "message": "Tree is closed for maintenance", |
29 "can_commit_freely": false | 29 "can_commit_freely": false |
30 } | 30 } |
31 | 31 |
32 asyncTest("basic", 7, function() { | 32 asyncTest("basic", 9, function() { |
33 var simulator = new NetworkSimulator(); | 33 var simulator = new NetworkSimulator(); |
34 simulator.json = function(url) { | 34 simulator.json = function(url) { |
35 if (url.indexOf('closed') != -1) | 35 if (url.indexOf('closed') != -1) |
36 return Promise.resolve(closedTreeJson); | 36 return Promise.resolve(closedTreeJson); |
37 else if (url.indexOf('throttled') != -1) | 37 else if (url.indexOf('throttled') != -1) |
38 return Promise.resolve(throttledTreeJson); | 38 return Promise.resolve(throttledTreeJson); |
39 else | 39 else |
40 return Promise.resolve(openTreeJson); | 40 return Promise.resolve(openTreeJson); |
41 }; | 41 }; |
| 42 |
42 var opentree = document.createElement("ct-tree-status"); | 43 var opentree = document.createElement("ct-tree-status"); |
43 opentree.setAttribute("project", "open-tree-project"); | 44 opentree.project = "open-tree-project"; |
44 var throttledtree = document.createElement("ct-tree-status"); | 45 var throttledtree = document.createElement("ct-tree-status"); |
45 throttledtree.setAttribute("project", "throttled-tree-project"); | 46 throttledtree.project = "throttled-tree-project"; |
46 var closedtree = document.createElement("ct-tree-status"); | 47 var closedtree = document.createElement("ct-tree-status"); |
47 closedtree.setAttribute("project", "closed-tree-project"); | 48 closedtree.project = "closed-tree-project"; |
| 49 |
48 simulator.runTest(function() { | 50 simulator.runTest(function() { |
49 var urlByName = treestatus.urlByName; | 51 var urlByName = treestatus.urlByName; |
50 treestatus.urlByName = function(name) { | 52 treestatus.urlByName = function(name) { |
51 return name + "-status.appspot.com/current?format=json"; | 53 return name + "-status.appspot.com/current?format=json"; |
52 } | 54 } |
53 Promise.all([ | 55 Promise.all([ |
54 opentree.update().then(function() { | 56 opentree.update().then(function() { |
55 equal(opentree.message, "Tree is open"); | |
56 equal(opentree.status, "open"); | 57 equal(opentree.status, "open"); |
57 }), | 58 }), |
58 throttledtree.update().then(function() { | 59 throttledtree.update().then(function() { |
59 equal(throttledtree.message, | 60 equal(throttledtree.message, |
60 "Tree is throttled just for fun by username@test.org"); | 61 "Tree is throttled just for fun by username@test.org"); |
61 equal(throttledtree.status, "throttled"); | 62 equal(throttledtree.status, "throttled"); |
62 }), | 63 }), |
63 closedtree.update().then(function() { | 64 closedtree.update().then(function() { |
64 equal(closedtree.message, | 65 equal(closedtree.message, |
65 "Tree is closed for maintenance by username@test.org"); | 66 "Tree is closed for maintenance by username@test.org"); |
66 equal(closedtree.status, "closed"); | 67 equal(closedtree.status, "closed"); |
67 }) | 68 }) |
68 ]).then(function() { | 69 ]).then(function() { |
69 start(); | 70 requestAnimationFrame(function() { |
70 treestatus.urlByName = urlByName; | 71 ok(!opentree.shadowRoot.textContent.has("open-tree-project")); |
| 72 ok(throttledtree.shadowRoot.textContent.has("throttled-tree-project")); |
| 73 ok(closedtree.shadowRoot.textContent.has("closed-tree-project")); |
| 74 start(); |
| 75 treestatus.urlByName = urlByName; |
| 76 }); |
71 }); | 77 }); |
72 }); | 78 }); |
73 }); | 79 }); |
74 | 80 |
75 })(); | 81 })(); |
76 </script> | 82 </script> |
OLD | NEW |