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 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 var controlBarElement = document.createElement('control-bar'); |
| 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 Loading... |
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.setAllProfilesLocked(true); |
| 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 // Simulate clicking 'Create Profile'. |
| 88 MockInteractions.tap(controlBarElement.$.addUser); |
| 89 |
| 90 return browserProxy.whenCalled('areAllProfilesLocked').then(function() { |
| 91 // Make sure DOM is up to date. |
| 92 Polymer.dom.flush(); |
| 93 |
| 94 // The dialog is visible. |
| 95 assertLT(0, errorDialogElement.$$('#backdrop').offsetHeight); |
| 96 }); |
| 97 }); |
| 98 |
| 99 test('Cannot launch guest profile', function() { |
| 100 // Simulate clicking 'Browse as guest'. |
| 101 MockInteractions.tap(controlBarElement.$.launchGuest); |
| 102 |
| 103 return browserProxy.whenCalled('areAllProfilesLocked').then(function() { |
| 104 // Make sure DOM is up to date. |
| 105 Polymer.dom.flush(); |
| 106 |
| 107 // The error dialog is visible. |
| 108 assertLT(0, errorDialogElement.$$('#backdrop').offsetHeight); |
| 109 }); |
| 110 }); |
| 111 }); |
57 } | 112 } |
58 | 113 |
59 return { | 114 return { |
60 registerTests: registerTests, | 115 registerTests: registerTests, |
61 }; | 116 }; |
62 }); | 117 }); |
OLD | NEW |