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

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: Elim registerTests Created 3 years, 11 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..e54f1b8c8d00a894104582067cafb220449951b7
--- /dev/null
+++ b/chrome/test/data/webui/cr_elements/cr_policy_pref_indicator_tests.js
@@ -0,0 +1,78 @@
+// 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. */
+suite('CrPolicyPrefIndicator', function() {
+ /** @type {!CrPolicyPrefIndicatorElement|undefined} */
+ var indicator;
+
+ /** @type {!PaperTooltipElement|undefined} */
+ var tooltip;
+
+ setup(function() {
+ PolymerTest.clearBody();
+
+ CrPolicyStrings = {
+ controlledSettingPolicy: 'policy',
+ controlledSettingRecommendedMatches: 'matches',
+ controlledSettingRecommendedDiffers: 'differs',
+ controlledSettingShared: 'shared: $1',
+ controlledSettingOwner: 'owner: $1',
+ };
+
+ 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('indicatorType', function() {
+ indicator.indicatorType = CrPolicyIndicatorType.DEVICE_POLICY;
+ Polymer.dom.flush();
+ assertFalse(indicator.$.indicator.hidden);
+ assertEquals('cr:domain', indicator.$.indicator.icon);
+ assertEquals('policy', tooltip.textContent.trim());
+ });
+
+ 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('cr: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