OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** @fileoverview Suite of tests for zoom-levels. */ | 5 /** @fileoverview Suite of tests for zoom-levels. */ |
6 cr.define('zoom_levels', function() { | 6 cr.define('zoom_levels', function() { |
7 function registerTests() { | 7 function registerTests() { |
8 suite('ZoomLevels', function() { | 8 suite('ZoomLevels', function() { |
9 /** | 9 /** |
10 * A zoom levels category created before each test. | 10 * A zoom levels category created before each test. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 testElement.remove(); | 51 testElement.remove(); |
52 testElement = null; | 52 testElement = null; |
53 }); | 53 }); |
54 | 54 |
55 /** @return {!Promise} */ | 55 /** @return {!Promise} */ |
56 function initPage() { | 56 function initPage() { |
57 browserProxy.reset(); | 57 browserProxy.reset(); |
58 PolymerTest.clearBody(); | 58 PolymerTest.clearBody(); |
59 testElement = document.createElement('zoom-levels'); | 59 testElement = document.createElement('zoom-levels'); |
60 document.body.appendChild(testElement); | 60 document.body.appendChild(testElement); |
61 return browserProxy.whenCalled('fetchZoomLevels'); | 61 |
| 62 return Promise.all([ |
| 63 browserProxy.whenCalled('fetchZoomScope'), |
| 64 browserProxy.whenCalled('fetchZoomLevels'), |
| 65 ]); |
62 } | 66 } |
63 | 67 |
64 /** | 68 /** |
65 * Fetch the remove button from the list. | 69 * Fetch the remove button from the list. |
66 * @param {!HTMLElement} listContainer The list to use for the lookup. | 70 * @param {!HTMLElement} listContainer The list to use for the lookup. |
67 * @param {number} index The index of the child element (which site) to | 71 * @param {number} index The index of the child element (which site) to |
68 * fetch. | 72 * fetch. |
69 */ | 73 */ |
70 function getRemoveButton(listContainer, index) { | 74 function getRemoveButton(listContainer, index) { |
71 return listContainer.children[index].querySelector('paper-icon-button'); | 75 return listContainer.children[index].querySelector('paper-icon-button'); |
(...skipping 15 matching lines...) Expand all Loading... |
87 | 91 |
88 var removeButton = | 92 var removeButton = |
89 getRemoveButton(testElement.$.listContainer, 0); | 93 getRemoveButton(testElement.$.listContainer, 0); |
90 assert(!!removeButton); | 94 assert(!!removeButton); |
91 MockInteractions.tap(removeButton); | 95 MockInteractions.tap(removeButton); |
92 return browserProxy.whenCalled('removeZoomLevel'); | 96 return browserProxy.whenCalled('removeZoomLevel'); |
93 }).then(function(args) { | 97 }).then(function(args) { |
94 assertEquals("http://www.google.com", args[0]); | 98 assertEquals("http://www.google.com", args[0]); |
95 }); | 99 }); |
96 }); | 100 }); |
| 101 |
| 102 test('toggle zoom scope', function() { |
| 103 var toggle = testElement.$.toggle; |
| 104 assertTrue(!!toggle); |
| 105 assertTrue(toggle.checked); |
| 106 |
| 107 MockInteractions.tap(toggle); |
| 108 return browserProxy.whenCalled('setZoomScopeIsPerOrigin').then( |
| 109 function(args) { |
| 110 assertFalse(args[0]); |
| 111 }); |
| 112 }); |
| 113 |
| 114 test('can remove entries while per-tab', function() { |
| 115 browserProxy.setZoomScope(false); |
| 116 browserProxy.setZoomList(zoomList); |
| 117 |
| 118 return initPage().then(function() { |
| 119 var toggle = testElement.$.toggle; |
| 120 assertTrue(!!toggle); |
| 121 assertFalse(toggle.checked); |
| 122 |
| 123 var list = testElement.$.list; |
| 124 assertTrue(!!list); |
| 125 assertEquals(2, list.items.length); |
| 126 |
| 127 var removeButton = |
| 128 getRemoveButton(testElement.$.listContainer, 0); |
| 129 assertTrue(!!removeButton); |
| 130 MockInteractions.tap(removeButton); |
| 131 return browserProxy.whenCalled('removeZoomLevel'); |
| 132 }).then(function(args) { |
| 133 assertEquals("http://www.google.com", args[0]); |
| 134 }); |
| 135 }); |
97 }); | 136 }); |
98 } | 137 } |
99 | 138 |
100 return { | 139 return { |
101 registerTests: registerTests, | 140 registerTests: registerTests, |
102 }; | 141 }; |
103 }); | 142 }); |
OLD | NEW |