| 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {settings.CupsPrintersBrowserProxy} | 7 * @implements {settings.CupsPrintersBrowserProxy} |
| 8 * @extends {TestBrowserProxy} | 8 * @extends {TestBrowserProxy} |
| 9 */ | 9 */ |
| 10 var TestCupsPrintersBrowserProxy = function() { | 10 var TestCupsPrintersBrowserProxy = function() { |
| 11 TestBrowserProxy.call(this, [ | 11 TestBrowserProxy.call(this, [ |
| 12 'getCupsPrintersList', | 12 'getCupsPrintersList', |
| 13 'getCupsPrinterManufacturersList', | 13 'getCupsPrinterManufacturersList', |
| 14 'getCupsPrinterModelsList', | 14 'getCupsPrinterModelsList', |
| 15 'getPrinterInfo', |
| 15 'startDiscoveringPrinters', | 16 'startDiscoveringPrinters', |
| 16 'stopDiscoveringPrinters', | 17 'stopDiscoveringPrinters', |
| 17 ]); | 18 ]); |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 TestCupsPrintersBrowserProxy.prototype = { | 21 TestCupsPrintersBrowserProxy.prototype = { |
| 21 __proto__: TestBrowserProxy.prototype, | 22 __proto__: TestBrowserProxy.prototype, |
| 22 | 23 |
| 23 printerList: [], | 24 printerList: [], |
| 24 manufacturers: [], | 25 manufacturers: [], |
| 25 models: [], | 26 models: [], |
| 27 printerInfo: {}, |
| 26 | 28 |
| 27 /** @override */ | 29 /** @override */ |
| 28 getCupsPrintersList: function() { | 30 getCupsPrintersList: function() { |
| 29 this.methodCalled('getCupsPrintersList'); | 31 this.methodCalled('getCupsPrintersList'); |
| 30 return Promise.resolve(this.printerList); | 32 return Promise.resolve(this.printerList); |
| 31 }, | 33 }, |
| 32 | 34 |
| 33 /** @override */ | 35 /** @override */ |
| 34 getCupsPrinterManufacturersList: function() { | 36 getCupsPrinterManufacturersList: function() { |
| 35 this.methodCalled('getCupsPrinterManufacturersList'); | 37 this.methodCalled('getCupsPrinterManufacturersList'); |
| 36 return Promise.resolve(this.manufacturers); | 38 return Promise.resolve(this.manufacturers); |
| 37 }, | 39 }, |
| 38 | 40 |
| 39 /** @override */ | 41 /** @override */ |
| 40 getCupsPrinterModelsList: function(manufacturer) { | 42 getCupsPrinterModelsList: function(manufacturer) { |
| 41 this.methodCalled('getCupsPrinterModelsList', manufacturer); | 43 this.methodCalled('getCupsPrinterModelsList', manufacturer); |
| 42 return Promise.resolve(this.models); | 44 return Promise.resolve(this.models); |
| 43 }, | 45 }, |
| 44 | 46 |
| 45 /** @override */ | 47 /** @override */ |
| 48 getPrinterInfo: function(newPrinter) { |
| 49 this.methodCalled('getPrinterInfo', newPrinter); |
| 50 // Reject all calls for now. |
| 51 return Promise.reject(); |
| 52 }, |
| 53 |
| 54 /** @override */ |
| 46 startDiscoveringPrinters: function() { | 55 startDiscoveringPrinters: function() { |
| 47 this.methodCalled('startDiscoveringPrinters'); | 56 this.methodCalled('startDiscoveringPrinters'); |
| 48 }, | 57 }, |
| 49 | 58 |
| 50 /** @override */ | 59 /** @override */ |
| 51 stopDiscoveringPrinters: function() { | 60 stopDiscoveringPrinters: function() { |
| 52 this.methodCalled('stopDiscoveringPrinters'); | 61 this.methodCalled('stopDiscoveringPrinters'); |
| 53 }, | 62 }, |
| 54 }; | 63 }; |
| 55 | 64 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 test('ValidAddOpensModelSelection', function() { | 119 test('ValidAddOpensModelSelection', function() { |
| 111 // Starts in discovery dialog, select add manually button. | 120 // Starts in discovery dialog, select add manually button. |
| 112 var discoveryDialog = dialog.$$('add-printer-discovery-dialog'); | 121 var discoveryDialog = dialog.$$('add-printer-discovery-dialog'); |
| 113 assertTrue(!!discoveryDialog); | 122 assertTrue(!!discoveryDialog); |
| 114 MockInteractions.tap(discoveryDialog.$$('.secondary-button')); | 123 MockInteractions.tap(discoveryDialog.$$('.secondary-button')); |
| 115 Polymer.dom.flush(); | 124 Polymer.dom.flush(); |
| 116 | 125 |
| 117 // Now we should be in the manually add dialog. | 126 // Now we should be in the manually add dialog. |
| 118 var addDialog = dialog.$$('add-printer-manually-dialog'); | 127 var addDialog = dialog.$$('add-printer-manually-dialog'); |
| 119 assertTrue(!!addDialog); | 128 assertTrue(!!addDialog); |
| 120 | |
| 121 fillAddManuallyDialog(addDialog); | 129 fillAddManuallyDialog(addDialog); |
| 122 | 130 |
| 123 MockInteractions.tap(addDialog.$$('.action-button')); | 131 MockInteractions.tap(addDialog.$$('.action-button')); |
| 124 Polymer.dom.flush(); | 132 Polymer.dom.flush(); |
| 133 // Configure is shown until getPrinterInfo is rejected. |
| 134 assertTrue(!!dialog.$$('add-printer-configuring-dialog')); |
| 125 | 135 |
| 126 // showing model selection | 136 // Upon rejection, show model. |
| 127 assertFalse(!!dialog.$$('add-printer-configuring-dialog')); | 137 return cupsPrintersBrowserProxy. |
| 128 assertTrue(!!dialog.$$('add-printer-manufacturer-model-dialog')); | 138 whenCalled('getCupsPrinterManufacturersList'). |
| 139 then(function() { |
| 140 // TODO(skau): Verify other dialogs are hidden. |
| 141 assertTrue(!!dialog.$$('add-printer-manufacturer-model-dialog')); |
| 142 }); |
| 129 }); | 143 }); |
| 130 | 144 |
| 131 /** | 145 /** |
| 132 * Test that getModels isn't called with a blank query. | 146 * Test that getModels isn't called with a blank query. |
| 133 */ | 147 */ |
| 134 test('NoBlankQueries', function() { | 148 test('NoBlankQueries', function() { |
| 135 var discoveryDialog = dialog.$$('add-printer-discovery-dialog'); | 149 var discoveryDialog = dialog.$$('add-printer-discovery-dialog'); |
| 136 assertTrue(!!discoveryDialog); | 150 assertTrue(!!discoveryDialog); |
| 137 MockInteractions.tap(discoveryDialog.$$('.secondary-button')); | 151 MockInteractions.tap(discoveryDialog.$$('.secondary-button')); |
| 138 Polymer.dom.flush(); | 152 Polymer.dom.flush(); |
| 139 | 153 |
| 140 var addDialog = dialog.$$('add-printer-manually-dialog'); | 154 var addDialog = dialog.$$('add-printer-manually-dialog'); |
| 141 assertTrue(!!addDialog); | 155 assertTrue(!!addDialog); |
| 142 fillAddManuallyDialog(addDialog); | 156 fillAddManuallyDialog(addDialog); |
| 143 | 157 |
| 144 cupsPrintersBrowserProxy.whenCalled('getCupsPrinterModelsList') | 158 cupsPrintersBrowserProxy.whenCalled('getCupsPrinterModelsList') |
| 145 .then(function(manufacturer) { assertGT(0, manufacturer.length); }); | 159 .then(function(manufacturer) { assertGT(0, manufacturer.length); }); |
| 146 | 160 |
| 147 cupsPrintersBrowserProxy.manufacturers = | 161 cupsPrintersBrowserProxy.manufacturers = |
| 148 ['ManufacturerA', 'ManufacturerB', 'Chromites']; | 162 ['ManufacturerA', 'ManufacturerB', 'Chromites']; |
| 149 MockInteractions.tap(addDialog.$$('.action-button')); | 163 MockInteractions.tap(addDialog.$$('.action-button')); |
| 150 Polymer.dom.flush(); | 164 Polymer.dom.flush(); |
| 151 | 165 |
| 152 var modelDialog = dialog.$$('add-printer-manufacturer-model-dialog'); | 166 return cupsPrintersBrowserProxy. |
| 153 assertTrue(!!modelDialog); | 167 whenCalled('getCupsPrinterManufacturersList'). |
| 154 | 168 then(function() { |
| 155 return cupsPrintersBrowserProxy.whenCalled( | 169 var modelDialog = dialog.$$('add-printer-manufacturer-model-dialog'); |
| 156 'getCupsPrinterManufacturersList'); | 170 assertTrue(!!modelDialog); |
| 171 }); |
| 157 }); | 172 }); |
| 158 }); | 173 }); |
| OLD | NEW |