| 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} */ | 6 /** @return {!ControlBarElement} */ |
| 7 function createElement() { | 7 function createElement() { |
| 8 var controlBarElement = document.createElement('control-bar'); | 8 var controlBarElement = document.createElement('control-bar'); |
| 9 document.body.appendChild(controlBarElement); | 9 document.body.appendChild(controlBarElement); |
| 10 return controlBarElement; | 10 return controlBarElement; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 browserProxy.setAllProfilesLocked(true); | 76 browserProxy.setAllProfilesLocked(true); |
| 77 | 77 |
| 78 controlBarElement = createElement(); | 78 controlBarElement = createElement(); |
| 79 | 79 |
| 80 errorDialogElement = document.querySelector('error-dialog'); | 80 errorDialogElement = document.querySelector('error-dialog'); |
| 81 }); | 81 }); |
| 82 | 82 |
| 83 teardown(function(done) { | 83 teardown(function(done) { |
| 84 controlBarElement.remove(); | 84 controlBarElement.remove(); |
| 85 if (errorDialogElement.$.dialog.open) |
| 86 errorDialogElement.$.dialog.close(); |
| 87 |
| 85 // Allow asynchronous tasks to finish. | 88 // Allow asynchronous tasks to finish. |
| 86 setTimeout(done); | 89 setTimeout(done); |
| 87 }); | 90 }); |
| 88 | 91 |
| 89 test('Cannot create profile', function() { | 92 test('Cannot create profile', function() { |
| 90 // Simulate clicking 'Create Profile'. | 93 // Simulate clicking 'Create Profile'. |
| 91 MockInteractions.tap(controlBarElement.$.addUser); | 94 MockInteractions.tap(controlBarElement.$.addUser); |
| 92 | 95 |
| 93 return browserProxy.whenCalled('areAllProfilesLocked').then(function() { | 96 return browserProxy.whenCalled('areAllProfilesLocked').then(function() { |
| 94 // Make sure DOM is up to date. | 97 // Make sure DOM is up to date. |
| 95 Polymer.dom.flush(); | 98 Polymer.dom.flush(); |
| 96 | 99 |
| 97 // The dialog is visible. | 100 // The dialog is visible. |
| 98 assertTrue(errorDialogElement.$.dialog.opened); | 101 assertTrue(errorDialogElement.$.dialog.open); |
| 99 }); | 102 }); |
| 100 }); | 103 }); |
| 101 | 104 |
| 102 test('Cannot launch guest profile', function() { | 105 test('Cannot launch guest profile', function() { |
| 103 // Simulate clicking 'Browse as guest'. | 106 // Simulate clicking 'Browse as guest'. |
| 104 MockInteractions.tap(controlBarElement.$.launchGuest); | 107 MockInteractions.tap(controlBarElement.$.launchGuest); |
| 105 | 108 |
| 106 return browserProxy.whenCalled('areAllProfilesLocked').then(function() { | 109 return browserProxy.whenCalled('areAllProfilesLocked').then(function() { |
| 107 // Make sure DOM is up to date. | 110 // Make sure DOM is up to date. |
| 108 Polymer.dom.flush(); | 111 Polymer.dom.flush(); |
| 109 | 112 |
| 110 // The error dialog is visible. | 113 // The error dialog is visible. |
| 111 assertTrue(errorDialogElement.$.dialog.opened); | 114 assertTrue(errorDialogElement.$.dialog.open); |
| 112 }); | 115 }); |
| 113 }); | 116 }); |
| 114 | 117 |
| 115 test('Can create profile with force signin', function() { | 118 test('Can create profile with force signin', function() { |
| 116 controlBarElement.isForceSigninEnabled_ = true; | 119 controlBarElement.isForceSigninEnabled_ = true; |
| 117 Polymer.dom.flush(); | 120 Polymer.dom.flush(); |
| 118 return new Promise(function(resolve, reject) { | 121 return new Promise(function(resolve, reject) { |
| 119 // We expect to go to the 'create-profile' page. | 122 // We expect to go to the 'create-profile' page. |
| 120 listenOnce(controlBarElement, 'change-page', function(event) { | 123 listenOnce(controlBarElement, 'change-page', function(event) { |
| 121 if (event.detail.page == 'create-user-page') | 124 if (event.detail.page == 'create-user-page') |
| (...skipping 12 matching lines...) Expand all Loading... |
| 134 return browserProxy.whenCalled('launchGuestUser'); | 137 return browserProxy.whenCalled('launchGuestUser'); |
| 135 }); | 138 }); |
| 136 | 139 |
| 137 }); | 140 }); |
| 138 } | 141 } |
| 139 | 142 |
| 140 return { | 143 return { |
| 141 registerTests: registerTests, | 144 registerTests: registerTests, |
| 142 }; | 145 }; |
| 143 }); | 146 }); |
| OLD | NEW |