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

Side by Side Diff: chrome/test/data/webui/md_user_manager/control_bar_tests.js

Issue 2020093002: MD User Manager: Browser Tests for when all profiles are locked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md-user-manager-locked
Patch Set: Created 4 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
OLDNEW
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 cr.define('user_manager.control_bar_tests', function() { 5 cr.define('user_manager.control_bar_tests', function() {
6 /** @return {!ControlBarElement} */
7 function createElement() {
8 PolymerTest.clearBody();
9 controlBarElement = document.createElement('control-bar');
dpapad 2016/05/31 22:07:41 I don't think you want to declare a global var her
Moe 2016/05/31 22:47:39 Done.
10 document.body.appendChild(controlBarElement);
11 return controlBarElement;
12 }
13
6 function registerTests() { 14 function registerTests() {
15 /** @type {?TestProfileBrowserProxy} */
16 var browserProxy = null;
17
18 /** @type {?ControlBarElement} */
19 var controlBarElement = null;
20
7 suite('ControlBarTests', function() { 21 suite('ControlBarTests', function() {
8 /** @type {?TestProfileBrowserProxy} */
9 var browserProxy = null;
10
11 /** @type {?ControlBarElement} */
12 var controlBarElement = null;
13
14 setup(function() { 22 setup(function() {
15 browserProxy = new TestProfileBrowserProxy(); 23 browserProxy = new TestProfileBrowserProxy();
16 // Replace real proxy with mock proxy. 24 // Replace real proxy with mock proxy.
17 signin.ProfileBrowserProxyImpl.instance_ = browserProxy; 25 signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
18 26
19 PolymerTest.clearBody(); 27 controlBarElement = createElement();
20 controlBarElement = document.createElement('control-bar');
21 document.body.appendChild(controlBarElement);
22 }); 28 });
23 29
24 teardown(function() { controlBarElement.remove(); }); 30 teardown(function() { controlBarElement.remove(); });
25 31
26 test('Actions are hidden by default', function() { 32 test('Actions are hidden by default', function() {
27 assertTrue(controlBarElement.$.launchGuest.hidden); 33 assertTrue(controlBarElement.$.launchGuest.hidden);
28 assertTrue(controlBarElement.$.addUser.hidden); 34 assertTrue(controlBarElement.$.addUser.hidden);
29 35
30 controlBarElement.showGuest = true; 36 controlBarElement.showGuest = true;
31 controlBarElement.showAddPerson = true; 37 controlBarElement.showAddPerson = true;
(...skipping 15 matching lines...) Expand all
47 MockInteractions.tap(controlBarElement.$.addUser); 53 MockInteractions.tap(controlBarElement.$.addUser);
48 }); 54 });
49 }); 55 });
50 56
51 test('Can launch guest profile', function() { 57 test('Can launch guest profile', function() {
52 // Simulate clicking 'Browse as guest'. 58 // Simulate clicking 'Browse as guest'.
53 MockInteractions.tap(controlBarElement.$.launchGuest); 59 MockInteractions.tap(controlBarElement.$.launchGuest);
54 return browserProxy.whenCalled('launchGuestUser'); 60 return browserProxy.whenCalled('launchGuestUser');
55 }); 61 });
56 }); 62 });
63
64 suite('ControlBarTestsAllProfilesAreLocked', function() {
65 /** @type {?ErrorDialogElement} */
66 var errorDialogElement = null;
67
68 setup(function() {
69 browserProxy = new TestProfileBrowserProxy();
70 // Replace real proxy with mock proxy.
71 signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
72
73 browserProxy.setAtLeastOneProfileUnlocked_(false);
74
75 controlBarElement = createElement();
76
77 errorDialogElement = document.createElement('error-dialog');
78 document.body.appendChild(errorDialogElement);
79 });
80
81 teardown(function() {
82 controlBarElement.remove();
83 errorDialogElement.remove();
84 });
85
86 test('Cannot create profile', function() {
87 return new Promise(function(resolve, reject) {
88 controlBarElement.addEventListener('change-page', function(event) {
89 // We don't expect to go to the 'create-profile' page.
90 assertNotReached('Should not go to the create-profile page.');
91 });
92
93 cr.addWebUIListener('show-error-dialog', function() {
94 // Make sure DOM is up to date.
95 Polymer.dom.flush();
96
97 // The dialog is visible.
98 assertLT(0, errorDialogElement.$$('#backdrop').offsetHeight);
99
100 resolve();
101 });
102
103 // Simulate clicking 'Create Profile'.
104 MockInteractions.tap(controlBarElement.$.addUser);
105 });
106 });
107
108 test('Cannot launch guest profile', function() {
109 return new Promise(function(resolve, reject) {
110 browserProxy.whenCalled('launchGuestUser').then(function() {
111 // Should not launch guest profile.
112 assertNotReached('Should not launch guest profile.');
113 });
114
115 cr.addWebUIListener('show-error-dialog', function() {
116 // Make sure DOM is up to date.
117 Polymer.dom.flush();
118
119 // The error dialog is visible.
120 assertLT(0, errorDialogElement.$$('#backdrop').offsetHeight);
121
122 resolve();
123 });
124
125 // Simulate clicking 'Browse as guest'.
126 MockInteractions.tap(controlBarElement.$.launchGuest);
127 });
128 });
129 });
57 } 130 }
58 131
59 return { 132 return {
60 registerTests: registerTests, 133 registerTests: registerTests,
61 }; 134 };
62 }); 135 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698