Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js

Issue 15966004: cros: Move kiosk settings to extensions page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and remove temp flag Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
Dan Beam 2013/05/30 21:14:55 @private
xiyuan 2013/05/30 23:03:38 Done.
22 */ 22 */
23 apps_: [ 23 settings_: {
24 { 24 apps: [
25 id: 'app_1', 25 {
26 name: 'App1 Name', 26 id: 'app_1',
27 iconURL: '', 27 name: 'App1 Name',
28 autoLaunch: false, 28 iconURL: '',
29 isLoading: false, 29 autoLaunch: false,
30 }, 30 isLoading: false,
31 { 31 },
32 id: 'app_2', 32 {
33 name: '', // no name 33 id: 'app_2',
34 iconURL: '', 34 name: '', // no name
35 autoLaunch: false, 35 iconURL: '',
36 isLoading: true, 36 autoLaunch: false,
37 }, 37 isLoading: true,
38 ], 38 },
39 ],
40 disableBailout: false
41 },
39 42
40 /** 43 /**
41 * Register a mock dictionary handler. 44 * Register a mock dictionary handler.
42 */ 45 */
43 preLoad: function() { 46 preLoad: function() {
44 this.makeAndRegisterMockHandler( 47 this.makeAndRegisterMockHandler(
45 ['getKioskApps', 48 ['getKioskAppSettings',
46 'addKioskApp', 49 'addKioskApp',
47 'removeKioskApp', 50 'removeKioskApp',
48 'enableKioskAutoLaunch', 51 'enableKioskAutoLaunch',
49 'disableKioskAutoLaunch' 52 'disableKioskAutoLaunch'
50 ]); 53 ]);
51 this.mockHandler.stubs().getKioskApps(). 54 this.mockHandler.stubs().getKioskAppSettings().
52 will(callFunction(function() { 55 will(callFunction(function() {
53 KioskAppsOverlay.setApps(this.apps_); 56 extensions.KioskAppsOverlay.setSettings(this.settings_);
54 }.bind(this))); 57 }.bind(this)));
55 this.mockHandler.stubs().addKioskApp(ANYTHING); 58 this.mockHandler.stubs().addKioskApp(ANYTHING);
56 this.mockHandler.stubs().removeKioskApp(ANYTHING); 59 this.mockHandler.stubs().removeKioskApp(ANYTHING);
57 this.mockHandler.stubs().enableKioskAutoLaunch(ANYTHING); 60 this.mockHandler.stubs().enableKioskAutoLaunch(ANYTHING);
58 this.mockHandler.stubs().disableKioskAutoLaunch(ANYTHING); 61 this.mockHandler.stubs().disableKioskAutoLaunch(ANYTHING);
62 },
63
64 setUp: function() {
65 // Shows the kiosk apps management overlay.
66 cr.dispatchSimpleEvent($('add-kiosk-app'), 'click');
59 } 67 }
60 }; 68 };
61 69
62 // Test opening kiosk app settings has correct location and app items have 70 // Test opening kiosk app settings has correct location and app items have
63 // correct label. 71 // correct label.
64 TEST_F('KioskAppSettingsWebUITest', 'testOpenKioskAppSettings', function() { 72 TEST_F('KioskAppSettingsWebUITest', 'testOpenKioskAppSettings', function() {
65 assertEquals(this.browsePreload, document.location.href); 73 assertEquals(this.browsePreload, document.location.href);
66 74
67 var appItems = $('kiosk-app-list').items; 75 var appItems = $('kiosk-app-list').items;
68 assertEquals(this.apps_.length, appItems.length); 76 assertEquals(this.settings_.apps.length, appItems.length);
69 assertEquals(this.apps_[0].name, appItems[0].name.textContent); 77 assertEquals(this.settings_.apps[0].name, appItems[0].name.textContent);
70 assertFalse(appItems[0].icon.classList.contains('spinner')); 78 assertFalse(appItems[0].icon.classList.contains('spinner'));
71 assertEquals(this.apps_[1].id, appItems[1].name.textContent); 79 assertEquals(this.settings_.apps[1].id, appItems[1].name.textContent);
72 assertTrue(appItems[1].icon.classList.contains('spinner')); 80 assertTrue(appItems[1].icon.classList.contains('spinner'));
73 }); 81 });
74 82
75 // Verify that enter key on 'kiosk-app-id-edit' adds an app. 83 // Verify that enter key on 'kiosk-app-id-edit' adds an app.
76 TEST_F('KioskAppSettingsWebUITest', 'testAddKioskApp', function() { 84 TEST_F('KioskAppSettingsWebUITest', 'testAddKioskApp', function() {
77 var testAppId = 'app_3'; 85 var testAppId = 'app_3';
78 var appIdInput = $('kiosk-app-id-edit'); 86 var appIdInput = $('kiosk-app-id-edit');
79 87
80 appIdInput.value = testAppId; 88 appIdInput.value = testAppId;
81 89
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 134
127 // New data changes name, autoLaunch and isLoading. 135 // New data changes name, autoLaunch and isLoading.
128 var newName = 'Name for App2'; 136 var newName = 'Name for App2';
129 var newApp2 = { 137 var newApp2 = {
130 id: 'app_2', 138 id: 'app_2',
131 name: newName, 139 name: newName,
132 iconURL: '', 140 iconURL: '',
133 autoLaunch: true, 141 autoLaunch: true,
134 isLoading: false, 142 isLoading: false,
135 }; 143 };
136 KioskAppsOverlay.updateApp(newApp2); 144 extensions.KioskAppsOverlay.updateApp(newApp2);
137 145
138 assertEquals('app_2', appItems[1].data.id); 146 assertEquals('app_2', appItems[1].data.id);
139 expectEquals(newName, appItems[1].data.name, newName); 147 expectEquals(newName, appItems[1].data.name, newName);
140 expectEquals(newName, appItems[1].name.textContent); 148 expectEquals(newName, appItems[1].name.textContent);
141 expectFalse(appItems[1].icon.classList.contains('spinner')); 149 expectFalse(appItems[1].icon.classList.contains('spinner'));
142 expectTrue(appItems[1].autoLaunch); 150 expectTrue(appItems[1].autoLaunch);
143 }); 151 });
144 152
145 // Verify that showError makes error banner visible. 153 // Verify that showError makes error banner visible.
146 TEST_F('KioskAppSettingsWebUITest', 'testShowError', function() { 154 TEST_F('KioskAppSettingsWebUITest', 'testShowError', function() {
147 KioskAppsOverlay.showError('A bad app'); 155 extensions.KioskAppsOverlay.showError('A bad app');
148 expectTrue($('kiosk-apps-error-banner').classList.contains('visible')); 156 expectTrue($('kiosk-apps-error-banner').classList.contains('visible'));
149 }); 157 });
150 158
151 // Verify that checking disable bailout checkbox brings up confirmation UI and 159 // Verify that checking disable bailout checkbox brings up confirmation UI and
152 // the check only remains when the confirmation UI is acknowledged. 160 // the check only remains when the confirmation UI is acknowledged.
153 TEST_F('KioskAppSettingsWebUITest', 'testCheckDisableBailout', function() { 161 TEST_F('KioskAppSettingsWebUITest', 'testCheckDisableBailout', function() {
154 var checkbox = $('kiosk-disable-bailout-shortcut'); 162 var checkbox = $('kiosk-disable-bailout-shortcut');
155 var confirmOverlay = KioskDisableBailoutConfirm.getInstance(); 163 var confirmOverlay = $('kiosk-disable-bailout-confirm-overlay');
156 expectFalse(confirmOverlay.visible); 164 expectFalse(confirmOverlay.classList.contains('showing'));
157 165
158 // Un-checking the box does not trigger confirmation. 166 // Un-checking the box does not trigger confirmation.
159 checkbox.checked = false; 167 checkbox.checked = false;
160 cr.dispatchSimpleEvent(checkbox, 'change'); 168 cr.dispatchSimpleEvent(checkbox, 'change');
161 expectFalse(confirmOverlay.visible); 169 expectFalse(confirmOverlay.classList.contains('showing'));
162 170
163 // Checking the box trigger confirmation. 171 // Checking the box trigger confirmation.
164 checkbox.checked = true; 172 checkbox.checked = true;
165 cr.dispatchSimpleEvent(checkbox, 'change'); 173 cr.dispatchSimpleEvent(checkbox, 'change');
166 expectTrue(confirmOverlay.visible); 174 expectTrue(confirmOverlay.classList.contains('showing'));
167 175
168 // Confirm it and the check remains. 176 // Confirm it and the check remains.
169 cr.dispatchSimpleEvent($('kiosk-disable-bailout-confirm-button'), 'click'); 177 cr.dispatchSimpleEvent($('kiosk-disable-bailout-confirm-button'), 'click');
170 expectTrue(checkbox.checked); 178 expectTrue(checkbox.checked);
171 expectFalse(confirmOverlay.visible); 179 expectFalse(confirmOverlay.classList.contains('showing'));
172 180
173 // And canceling resets the check. 181 // And canceling resets the check.
174 checkbox.checked = true; 182 checkbox.checked = true;
175 cr.dispatchSimpleEvent(checkbox, 'change'); 183 cr.dispatchSimpleEvent(checkbox, 'change');
176 expectTrue(confirmOverlay.visible); 184 expectTrue(confirmOverlay.classList.contains('showing'));
177 cr.dispatchSimpleEvent($('kiosk-disable-bailout-cancel-button'), 'click'); 185 cr.dispatchSimpleEvent($('kiosk-disable-bailout-cancel-button'), 'click');
178 expectFalse(checkbox.checked); 186 expectFalse(checkbox.checked);
179 expectFalse(confirmOverlay.visible); 187 expectFalse(confirmOverlay.classList.contains('showing'));
180 }); 188 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698