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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_user_manager/control_bar_tests.js
diff --git a/chrome/test/data/webui/md_user_manager/control_bar_tests.js b/chrome/test/data/webui/md_user_manager/control_bar_tests.js
index 5adfbd97108aa70ca0fb103e1683069355e8196a..40c86a3fcbbc821150e3f37e6d0512945d04214e 100644
--- a/chrome/test/data/webui/md_user_manager/control_bar_tests.js
+++ b/chrome/test/data/webui/md_user_manager/control_bar_tests.js
@@ -3,22 +3,28 @@
// found in the LICENSE file.
cr.define('user_manager.control_bar_tests', function() {
+ /** @return {!ControlBarElement} */
+ function createElement() {
+ PolymerTest.clearBody();
+ 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.
+ document.body.appendChild(controlBarElement);
+ return controlBarElement;
+ }
+
function registerTests() {
- suite('ControlBarTests', function() {
- /** @type {?TestProfileBrowserProxy} */
- var browserProxy = null;
+ /** @type {?TestProfileBrowserProxy} */
+ var browserProxy = null;
- /** @type {?ControlBarElement} */
- var controlBarElement = null;
+ /** @type {?ControlBarElement} */
+ var controlBarElement = null;
+ suite('ControlBarTests', function() {
setup(function() {
browserProxy = new TestProfileBrowserProxy();
// Replace real proxy with mock proxy.
signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
- PolymerTest.clearBody();
- controlBarElement = document.createElement('control-bar');
- document.body.appendChild(controlBarElement);
+ controlBarElement = createElement();
});
teardown(function() { controlBarElement.remove(); });
@@ -54,6 +60,73 @@ cr.define('user_manager.control_bar_tests', function() {
return browserProxy.whenCalled('launchGuestUser');
});
});
+
+ suite('ControlBarTestsAllProfilesAreLocked', function() {
+ /** @type {?ErrorDialogElement} */
+ var errorDialogElement = null;
+
+ setup(function() {
+ browserProxy = new TestProfileBrowserProxy();
+ // Replace real proxy with mock proxy.
+ signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
+
+ browserProxy.setAtLeastOneProfileUnlocked_(false);
+
+ controlBarElement = createElement();
+
+ errorDialogElement = document.createElement('error-dialog');
+ document.body.appendChild(errorDialogElement);
+ });
+
+ teardown(function() {
+ controlBarElement.remove();
+ errorDialogElement.remove();
+ });
+
+ test('Cannot create profile', function() {
+ return new Promise(function(resolve, reject) {
+ controlBarElement.addEventListener('change-page', function(event) {
+ // We don't expect to go to the 'create-profile' page.
+ assertNotReached('Should not go to the create-profile page.');
+ });
+
+ cr.addWebUIListener('show-error-dialog', function() {
+ // Make sure DOM is up to date.
+ Polymer.dom.flush();
+
+ // The dialog is visible.
+ assertLT(0, errorDialogElement.$$('#backdrop').offsetHeight);
+
+ resolve();
+ });
+
+ // Simulate clicking 'Create Profile'.
+ MockInteractions.tap(controlBarElement.$.addUser);
+ });
+ });
+
+ test('Cannot launch guest profile', function() {
+ return new Promise(function(resolve, reject) {
+ browserProxy.whenCalled('launchGuestUser').then(function() {
+ // Should not launch guest profile.
+ assertNotReached('Should not launch guest profile.');
+ });
+
+ cr.addWebUIListener('show-error-dialog', function() {
+ // Make sure DOM is up to date.
+ Polymer.dom.flush();
+
+ // The error dialog is visible.
+ assertLT(0, errorDialogElement.$$('#backdrop').offsetHeight);
+
+ resolve();
+ });
+
+ // Simulate clicking 'Browse as guest'.
+ MockInteractions.tap(controlBarElement.$.launchGuest);
+ });
+ });
+ });
}
return {

Powered by Google App Engine
This is Rietveld 408576698