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

Unified Diff: chrome/test/data/webui/cr_elements/cr_policy_pref_indicator_tests.js

Issue 2624003003: WebUI: Add cr-policy-pref-indicator tests (Closed)
Patch Set: Feedback Created 3 years, 10 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/cr_elements/cr_policy_pref_indicator_tests.js
diff --git a/chrome/test/data/webui/cr_elements/cr_policy_pref_indicator_tests.js b/chrome/test/data/webui/cr_elements/cr_policy_pref_indicator_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..13169cb5e4df31dc08a82640e2bfb5218780d786
--- /dev/null
+++ b/chrome/test/data/webui/cr_elements/cr_policy_pref_indicator_tests.js
@@ -0,0 +1,103 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/** @fileoverview Suite of tests for cr_policy-pref-indicator. */
michaelpg 2017/02/16 21:36:22 cr-policy
stevenjb 2017/02/17 01:08:29 Done.
+suite('CrPolicyPrefIndicator', function() {
+ /** @type {!CrPolicyPrefIndicatorElement|undefined} */
+ var indicator;
+
+ /** @type {!PaperTooltipElement|undefined} */
+ var tooltip;
+
+ suiteSetup(function() {
+ // Define chrome.settingsPrivate enums, normally provided by chrome WebUI.
+ // NOTE: These need to be kept in sync with settings_private.idl.
+
+ chrome.settingsPrivate = chrome.settingsPrivate || {};
+
+ /** @enum {string} */
+ chrome.settingsPrivate.ControlledBy = {
+ DEVICE_POLICY: 'DEVICE_POLICY',
+ USER_POLICY: 'USER_POLICY',
+ OWNER: 'OWNER',
+ PRIMARY_USER: 'PRIMARY_USER',
+ EXTENSION: 'EXTENSION',
+ };
+
+ /** @enum {string} */
+ chrome.settingsPrivate.Enforcement = {
+ ENFORCED: 'ENFORCED',
+ RECOMMENDED: 'RECOMMENDED',
+ };
+
+ /** @enum {string} */
+ chrome.settingsPrivate.PrefType = {
+ BOOLEAN: 'BOOLEAN',
+ NUMBER: 'NUMBER',
+ STRING: 'STRING',
+ URL: 'URL',
+ LIST: 'LIST',
+ DICTIONARY: 'DICTIONARY',
+ };
+
+ // Set up strings used by policy indicator elements.
michaelpg 2017/02/16 21:36:22 Given the comment about settings_private.idl, coul
stevenjb 2017/02/17 01:08:29 Done.
+ CrPolicyStrings = {
+ controlledSettingPolicy: 'policy',
+ controlledSettingRecommendedMatches: 'matches',
+ controlledSettingRecommendedDiffers: 'differs',
+ controlledSettingShared: 'shared: $1',
+ controlledSettingOwner: 'owner: $1',
+ };
+ });
+
+ setup(function() {
+ PolymerTest.clearBody();
+
+ indicator = document.createElement('cr-policy-pref-indicator');
+ document.body.appendChild(indicator);
+ tooltip = indicator.$$('paper-tooltip');
+ });
+
+ teardown(function() {
+ PolymerTest.clearBody(); // crbug.com/680169
+ });
+
+ test('none', function() {
+ assertTrue(indicator.$.indicator.hidden);
+ });
+
+ test('pref', function() {
+ /** @type {!chrome.settingsPrivate.PrefObject} */
+ indicator.pref = {
+ key: 'foo',
+ type: chrome.settingsPrivate.PrefType.BOOLEAN,
+ value: false,
+ };
+ Polymer.dom.flush();
+ assertTrue(indicator.$.indicator.hidden);
+
+ indicator.set(
+ 'pref.controlledBy', chrome.settingsPrivate.ControlledBy.OWNER);
+ indicator.set('pref.controlledByName', 'owner_name');
+ indicator.set(
+ 'pref.enforcement', chrome.settingsPrivate.Enforcement.ENFORCED);
+ Polymer.dom.flush();
+ assertFalse(indicator.$.indicator.hidden);
+ assertEquals('cr:person', indicator.$.indicator.icon);
+ assertEquals('owner: owner_name', tooltip.textContent.trim());
+
+ indicator.set('pref.value', 'foo');
+ indicator.set('pref.recommendedValue', 'bar');
+ indicator.set(
+ 'pref.enforcement', chrome.settingsPrivate.Enforcement.RECOMMENDED);
+ Polymer.dom.flush();
+ assertFalse(indicator.$.indicator.hidden);
+ assertEquals('cr20:domain', indicator.$.indicator.icon);
+ assertEquals('differs', tooltip.textContent.trim());
+
+ indicator.set('pref.value', 'bar');
+ Polymer.dom.flush();
+ assertEquals('matches', tooltip.textContent.trim());
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698