| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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  * TestFixture for kiosk app settings WebUI testing. | 6  * TestFixture for kiosk app settings WebUI testing. | 
| 7  * @extends {testing.Test} | 7  * @extends {testing.Test} | 
| 8  * @constructor | 8  * @constructor | 
| 9  **/ | 9  **/ | 
| 10 function KioskAppSettingsWebUITest() {} | 10 function KioskAppSettingsWebUITest() {} | 
| 11 | 11 | 
| 12 KioskAppSettingsWebUITest.prototype = { | 12 KioskAppSettingsWebUITest.prototype = { | 
| 13   __proto__: testing.Test.prototype, | 13   __proto__: testing.Test.prototype, | 
| 14 | 14 | 
| 15   /** | 15   /** | 
| 16    * Browse to the kiosk app settings page. | 16    * Browse to the kiosk app settings page. | 
| 17    */ | 17    */ | 
| 18   browsePreload: 'chrome://settings-frame/kioskAppsOverlay', | 18   browsePreload: 'chrome://extensions-frame/', | 
| 19 | 19 | 
| 20   /** | 20   /** | 
| 21    * Mock apps data. | 21    * Mock settings data. | 
|  | 22    * @private | 
| 22    */ | 23    */ | 
| 23   apps_: [ | 24   settings_: { | 
| 24     { | 25     apps: [ | 
| 25       id: 'app_1', | 26       { | 
| 26       name: 'App1 Name', | 27         id: 'app_1', | 
| 27       iconURL: '', | 28         name: 'App1 Name', | 
| 28       autoLaunch: false, | 29         iconURL: '', | 
| 29       isLoading: false, | 30         autoLaunch: false, | 
| 30     }, | 31         isLoading: false, | 
| 31     { | 32       }, | 
| 32       id: 'app_2', | 33       { | 
| 33       name: '',  // no name | 34         id: 'app_2', | 
| 34       iconURL: '', | 35         name: '',  // no name | 
| 35       autoLaunch: false, | 36         iconURL: '', | 
| 36       isLoading: true, | 37         autoLaunch: false, | 
| 37     }, | 38         isLoading: true, | 
| 38   ], | 39       }, | 
|  | 40     ], | 
|  | 41     disableBailout: false | 
|  | 42   }, | 
| 39 | 43 | 
| 40   /** | 44   /** | 
| 41    * Register a mock dictionary handler. | 45    * Register a mock dictionary handler. | 
| 42    */ | 46    */ | 
| 43   preLoad: function() { | 47   preLoad: function() { | 
| 44     this.makeAndRegisterMockHandler( | 48     this.makeAndRegisterMockHandler( | 
| 45         ['getKioskApps', | 49         ['getKioskAppSettings', | 
| 46          'addKioskApp', | 50          'addKioskApp', | 
| 47          'removeKioskApp', | 51          'removeKioskApp', | 
| 48          'enableKioskAutoLaunch', | 52          'enableKioskAutoLaunch', | 
| 49          'disableKioskAutoLaunch' | 53          'disableKioskAutoLaunch' | 
| 50         ]); | 54         ]); | 
| 51     this.mockHandler.stubs().getKioskApps(). | 55     this.mockHandler.stubs().getKioskAppSettings(). | 
| 52         will(callFunction(function() { | 56         will(callFunction(function() { | 
| 53           KioskAppsOverlay.setApps(this.apps_); | 57           extensions.KioskAppsOverlay.setSettings(this.settings_); | 
| 54         }.bind(this))); | 58         }.bind(this))); | 
| 55     this.mockHandler.stubs().addKioskApp(ANYTHING); | 59     this.mockHandler.stubs().addKioskApp(ANYTHING); | 
| 56     this.mockHandler.stubs().removeKioskApp(ANYTHING); | 60     this.mockHandler.stubs().removeKioskApp(ANYTHING); | 
| 57     this.mockHandler.stubs().enableKioskAutoLaunch(ANYTHING); | 61     this.mockHandler.stubs().enableKioskAutoLaunch(ANYTHING); | 
| 58     this.mockHandler.stubs().disableKioskAutoLaunch(ANYTHING); | 62     this.mockHandler.stubs().disableKioskAutoLaunch(ANYTHING); | 
|  | 63   }, | 
|  | 64 | 
|  | 65   setUp: function() { | 
|  | 66     // Shows the kiosk apps management overlay. | 
|  | 67     cr.dispatchSimpleEvent($('add-kiosk-app'), 'click'); | 
| 59   } | 68   } | 
| 60 }; | 69 }; | 
| 61 | 70 | 
| 62 // Test opening kiosk app settings has correct location and app items have | 71 // Test opening kiosk app settings has correct location and app items have | 
| 63 // correct label. | 72 // correct label. | 
| 64 TEST_F('KioskAppSettingsWebUITest', 'testOpenKioskAppSettings', function() { | 73 TEST_F('KioskAppSettingsWebUITest', 'testOpenKioskAppSettings', function() { | 
| 65   assertEquals(this.browsePreload, document.location.href); | 74   assertEquals(this.browsePreload, document.location.href); | 
| 66 | 75 | 
| 67   var appItems = $('kiosk-app-list').items; | 76   var appItems = $('kiosk-app-list').items; | 
| 68   assertEquals(this.apps_.length, appItems.length); | 77   assertEquals(this.settings_.apps.length, appItems.length); | 
| 69   assertEquals(this.apps_[0].name, appItems[0].name.textContent); | 78   assertEquals(this.settings_.apps[0].name, appItems[0].name.textContent); | 
| 70   assertFalse(appItems[0].icon.classList.contains('spinner')); | 79   assertFalse(appItems[0].icon.classList.contains('spinner')); | 
| 71   assertEquals(this.apps_[1].id, appItems[1].name.textContent); | 80   assertEquals(this.settings_.apps[1].id, appItems[1].name.textContent); | 
| 72   assertTrue(appItems[1].icon.classList.contains('spinner')); | 81   assertTrue(appItems[1].icon.classList.contains('spinner')); | 
| 73 }); | 82 }); | 
| 74 | 83 | 
| 75 // Verify that enter key on 'kiosk-app-id-edit' adds an app. | 84 // Verify that enter key on 'kiosk-app-id-edit' adds an app. | 
| 76 TEST_F('KioskAppSettingsWebUITest', 'testAddKioskApp', function() { | 85 TEST_F('KioskAppSettingsWebUITest', 'testAddKioskApp', function() { | 
| 77   var testAppId = 'app_3'; | 86   var testAppId = 'app_3'; | 
| 78   var appIdInput = $('kiosk-app-id-edit'); | 87   var appIdInput = $('kiosk-app-id-edit'); | 
| 79 | 88 | 
| 80   appIdInput.value = testAppId; | 89   appIdInput.value = testAppId; | 
| 81 | 90 | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 126 | 135 | 
| 127   // New data changes name, autoLaunch and isLoading. | 136   // New data changes name, autoLaunch and isLoading. | 
| 128   var newName = 'Name for App2'; | 137   var newName = 'Name for App2'; | 
| 129   var newApp2 = { | 138   var newApp2 = { | 
| 130     id: 'app_2', | 139     id: 'app_2', | 
| 131     name: newName, | 140     name: newName, | 
| 132     iconURL: '', | 141     iconURL: '', | 
| 133     autoLaunch: true, | 142     autoLaunch: true, | 
| 134     isLoading: false, | 143     isLoading: false, | 
| 135   }; | 144   }; | 
| 136   KioskAppsOverlay.updateApp(newApp2); | 145   extensions.KioskAppsOverlay.updateApp(newApp2); | 
| 137 | 146 | 
| 138   assertEquals('app_2', appItems[1].data.id); | 147   assertEquals('app_2', appItems[1].data.id); | 
| 139   expectEquals(newName, appItems[1].data.name, newName); | 148   expectEquals(newName, appItems[1].data.name, newName); | 
| 140   expectEquals(newName, appItems[1].name.textContent); | 149   expectEquals(newName, appItems[1].name.textContent); | 
| 141   expectFalse(appItems[1].icon.classList.contains('spinner')); | 150   expectFalse(appItems[1].icon.classList.contains('spinner')); | 
| 142   expectTrue(appItems[1].autoLaunch); | 151   expectTrue(appItems[1].autoLaunch); | 
| 143 }); | 152 }); | 
| 144 | 153 | 
| 145 // Verify that showError makes error banner visible. | 154 // Verify that showError makes error banner visible. | 
| 146 TEST_F('KioskAppSettingsWebUITest', 'testShowError', function() { | 155 TEST_F('KioskAppSettingsWebUITest', 'testShowError', function() { | 
| 147   KioskAppsOverlay.showError('A bad app'); | 156   extensions.KioskAppsOverlay.showError('A bad app'); | 
| 148   expectTrue($('kiosk-apps-error-banner').classList.contains('visible')); | 157   expectTrue($('kiosk-apps-error-banner').classList.contains('visible')); | 
| 149 }); | 158 }); | 
| 150 | 159 | 
| 151 // Verify that checking disable bailout checkbox brings up confirmation UI and | 160 // Verify that checking disable bailout checkbox brings up confirmation UI and | 
| 152 // the check only remains when the confirmation UI is acknowledged. | 161 // the check only remains when the confirmation UI is acknowledged. | 
| 153 TEST_F('KioskAppSettingsWebUITest', 'testCheckDisableBailout', function() { | 162 TEST_F('KioskAppSettingsWebUITest', 'testCheckDisableBailout', function() { | 
| 154   var checkbox = $('kiosk-disable-bailout-shortcut'); | 163   var checkbox = $('kiosk-disable-bailout-shortcut'); | 
| 155   var confirmOverlay = KioskDisableBailoutConfirm.getInstance(); | 164   var confirmOverlay = $('kiosk-disable-bailout-confirm-overlay'); | 
| 156   expectFalse(confirmOverlay.visible); | 165   expectFalse(confirmOverlay.classList.contains('showing')); | 
| 157 | 166 | 
| 158   // Un-checking the box does not trigger confirmation. | 167   // Un-checking the box does not trigger confirmation. | 
| 159   checkbox.checked = false; | 168   checkbox.checked = false; | 
| 160   cr.dispatchSimpleEvent(checkbox, 'change'); | 169   cr.dispatchSimpleEvent(checkbox, 'change'); | 
| 161   expectFalse(confirmOverlay.visible); | 170   expectFalse(confirmOverlay.classList.contains('showing')); | 
| 162 | 171 | 
| 163   // Checking the box trigger confirmation. | 172   // Checking the box trigger confirmation. | 
| 164   checkbox.checked = true; | 173   checkbox.checked = true; | 
| 165   cr.dispatchSimpleEvent(checkbox, 'change'); | 174   cr.dispatchSimpleEvent(checkbox, 'change'); | 
| 166   expectTrue(confirmOverlay.visible); | 175   expectTrue(confirmOverlay.classList.contains('showing')); | 
| 167 | 176 | 
| 168   // Confirm it and the check remains. | 177   // Confirm it and the check remains. | 
| 169   cr.dispatchSimpleEvent($('kiosk-disable-bailout-confirm-button'), 'click'); | 178   cr.dispatchSimpleEvent($('kiosk-disable-bailout-confirm-button'), 'click'); | 
| 170   expectTrue(checkbox.checked); | 179   expectTrue(checkbox.checked); | 
| 171   expectFalse(confirmOverlay.visible); | 180   expectFalse(confirmOverlay.classList.contains('showing')); | 
| 172 | 181 | 
| 173   // And canceling resets the check. | 182   // And canceling resets the check. | 
| 174   checkbox.checked = true; | 183   checkbox.checked = true; | 
| 175   cr.dispatchSimpleEvent(checkbox, 'change'); | 184   cr.dispatchSimpleEvent(checkbox, 'change'); | 
| 176   expectTrue(confirmOverlay.visible); | 185   expectTrue(confirmOverlay.classList.contains('showing')); | 
| 177   cr.dispatchSimpleEvent($('kiosk-disable-bailout-cancel-button'), 'click'); | 186   cr.dispatchSimpleEvent($('kiosk-disable-bailout-cancel-button'), 'click'); | 
| 178   expectFalse(checkbox.checked); | 187   expectFalse(checkbox.checked); | 
| 179   expectFalse(confirmOverlay.visible); | 188   expectFalse(confirmOverlay.classList.contains('showing')); | 
| 180 }); | 189 }); | 
| OLD | NEW | 
|---|