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 usb_devices. */ | 5 /** @fileoverview Suite of tests for usb_devices. */ |
6 suite('UsbDevices', function() { | 6 suite('UsbDevices', function() { |
7 /** | 7 /** |
8 * A dummy usb-devices element created before each test. | 8 * A dummy usb-devices element created before each test. |
9 * @type {UsbDevices} | 9 * @type {UsbDevices} |
10 */ | 10 */ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return initPage().then(function() { | 83 return initPage().then(function() { |
84 var listItems = testElement.root.querySelectorAll('.list-item'); | 84 var listItems = testElement.root.querySelectorAll('.list-item'); |
85 assertEquals(deviceList.length, listItems.length); | 85 assertEquals(deviceList.length, listItems.length); |
86 }); | 86 }); |
87 }); | 87 }); |
88 | 88 |
89 test('non-empty device list has working menu buttons', function() { | 89 test('non-empty device list has working menu buttons', function() { |
90 browserProxy.setUsbDevices(deviceList); | 90 browserProxy.setUsbDevices(deviceList); |
91 | 91 |
92 return initPage().then(function() { | 92 return initPage().then(function() { |
93 var menuButton = testElement.$$('paper-icon-button'); | 93 var menuButton = testElement.$$('button.icon-more-vert'); |
94 assertTrue(!!menuButton); | 94 assertTrue(!!menuButton); |
95 MockInteractions.tap(menuButton); | 95 MockInteractions.tap(menuButton); |
96 var dialog = testElement.$$('dialog[is=cr-action-menu]'); | 96 var dialog = testElement.$$('dialog[is=cr-action-menu]'); |
97 assertTrue(dialog.open); | 97 assertTrue(dialog.open); |
98 }); | 98 }); |
99 }); | 99 }); |
100 | 100 |
101 /** | 101 /** |
102 * A reusable function to test removing different devices. | 102 * A reusable function to test removing different devices. |
103 * @param {!number} indexToRemove index of devices to be removed. | 103 * @param {!number} indexToRemove index of devices to be removed. |
104 * @return {!Promise} | 104 * @return {!Promise} |
105 */ | 105 */ |
106 function testRemovalFlow(indexToRemove) { | 106 function testRemovalFlow(indexToRemove) { |
107 /** | 107 /** |
108 * Test whether or not clicking remove-button sends the correct | 108 * Test whether or not clicking remove-button sends the correct |
109 * parameters to the browserProxy.removeUsbDevice() function. | 109 * parameters to the browserProxy.removeUsbDevice() function. |
110 */ | 110 */ |
111 var menuButton = | 111 var menuButton = testElement.root.querySelectorAll( |
112 testElement.root.querySelectorAll('paper-icon-button')[indexToRemove]; | 112 'button.icon-more-vert')[indexToRemove]; |
113 var removeButton = testElement.$.removeButton; | 113 var removeButton = testElement.$.removeButton; |
114 MockInteractions.tap(menuButton); | 114 MockInteractions.tap(menuButton); |
115 MockInteractions.tap(removeButton); | 115 MockInteractions.tap(removeButton); |
116 return browserProxy.whenCalled('removeUsbDevice').then(function(args) { | 116 return browserProxy.whenCalled('removeUsbDevice').then(function(args) { |
117 /** | 117 /** |
118 * removeUsbDevice() is expected to be called with arguments as | 118 * removeUsbDevice() is expected to be called with arguments as |
119 * [origin, embeddingOrigin, object]. | 119 * [origin, embeddingOrigin, object]. |
120 */ | 120 */ |
121 assertEquals(deviceList[indexToRemove].origin, args[0]); | 121 assertEquals(deviceList[indexToRemove].origin, args[0]); |
122 assertEquals(deviceList[indexToRemove].embeddingOrigin, args[1]); | 122 assertEquals(deviceList[indexToRemove].embeddingOrigin, args[1]); |
(...skipping 12 matching lines...) Expand all Loading... |
135 return initPage() | 135 return initPage() |
136 .then(function() { | 136 .then(function() { |
137 return testRemovalFlow(0); | 137 return testRemovalFlow(0); |
138 }) | 138 }) |
139 .then(function() { | 139 .then(function() { |
140 browserProxy.reset(); | 140 browserProxy.reset(); |
141 return testRemovalFlow(1); | 141 return testRemovalFlow(1); |
142 }); | 142 }); |
143 }); | 143 }); |
144 }); | 144 }); |
OLD | NEW |