Commit b74c0c83 authored by zmin's avatar zmin Committed by Commit bot

Hide supervised user creation from UserManager when force sign in is enabled.

BUG=642059
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2561243002
Cr-Commit-Position: refs/heads/master@{#438194}
parent a17cccbc
......@@ -164,6 +164,7 @@
hidden="[[!isProfileShortcutsEnabled_]]">
$i18n{createDesktopShortcutLabel}
</paper-checkbox>
<template is="dom-if" if="[[!isForceSigninEnabled_]]">
<paper-checkbox id="makeSupervisedCheckbox" checked="{{isSupervised_}}">
$i18n{manageProfilesSupervisedSignedInLabel}
</paper-checkbox>
......@@ -197,6 +198,7 @@
</div>
</template>
</div>
</template>
<div id="actions">
<paper-spinner active="[[isSpinnerActive_(createInProgress_,
loadingSupervisedUsers_)]]">
......
......@@ -138,6 +138,17 @@ Polymer({
return loadTimeData.getBoolean('profileShortcutsEnabled');
},
readOnly: true
},
/**
* True if the force sign in policy is enabled.
* @private {boolean}
*/
isForceSigninEnabled_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('isForceSigninEnabled');
},
}
},
......
......@@ -66,7 +66,8 @@ cr.define('user_manager.create_profile_tests', function() {
assertFalse(!!createProfileElement.$$('paper-dropdown-menu'));
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// The dropdown menu is visible and is populated with signed in users.
......@@ -115,7 +116,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Has to select a custodian for the supervised profile', function() {
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// Simulate clicking 'Create'.
......@@ -135,7 +137,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Supervised profile name is duplicate (on the device)', function() {
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// There is an existing supervised user with this name on the device.
......@@ -166,7 +169,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Supervised profile name is duplicate (remote)', function() {
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// There is an existing supervised user with this name on the device.
......@@ -199,7 +203,8 @@ cr.define('user_manager.create_profile_tests', function() {
browserProxy.setExistingSupervisedUsers([]);
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// Select the first signed in user.
......@@ -227,7 +232,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Create supervised profile', function() {
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// Select the first signed in user.
......@@ -418,7 +424,8 @@ cr.define('user_manager.create_profile_tests', function() {
assertEquals(0, createProfileElement.signedInUsers_.length);
// Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox);
MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush();
// The dropdown menu is not visible when there are no signed in users.
......@@ -507,6 +514,45 @@ cr.define('user_manager.create_profile_tests', function() {
});
});
});
suite('CreateProfileTestsForceSigninPolicy', function() {
setup(function() {
browserProxy = new TestProfileBrowserProxy();
// Replace real proxy with mock proxy.
signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
browserProxy.setIcons([{url: 'icon1.png', label: 'icon1'}]);
});
teardown(function(done) {
createProfileElement.remove();
// Allow asynchronous tasks to finish.
setTimeout(done);
});
test('force sign in policy enabled', function () {
loadTimeData.overrideValues({
isForceSigninEnabled: true,
});
createProfileElement = createElement();
Polymer.dom.flush();
var createSupervisedUserCheckbox =
createProfileElement.$$("#makeSupervisedCheckbox");
assertFalse(!!createSupervisedUserCheckbox);
});
test('force sign in policy not enabled', function () {
loadTimeData.overrideValues({
isForceSigninEnabled: false,
});
createProfileElement = createElement();
Polymer.dom.flush();
var createSupervisedUserCheckbox =
createProfileElement.$$("#makeSupervisedCheckbox");
assertTrue(createSupervisedUserCheckbox.clientHeight > 0);
});
});
}
return {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment