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

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

Issue 2625213002: WebUI: Add cr_policy_network_indicator_tests.js (Closed)
Patch Set: Rebase 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_network_indicator_tests.js
diff --git a/chrome/test/data/webui/cr_elements/cr_policy_network_indicator_tests.js b/chrome/test/data/webui/cr_elements/cr_policy_network_indicator_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..85e573aae67e01e74c764bbbc1491c9b4419ad04
--- /dev/null
+++ b/chrome/test/data/webui/cr_elements/cr_policy_network_indicator_tests.js
@@ -0,0 +1,88 @@
+// 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-network-indicator. */
+cr.define('cr_policy_network_indicator', function() {
+ function registerTests() {
Dan Beam 2017/01/12 18:18:18 can you just drop these 2 lines? pretty much all n
stevenjb 2017/01/12 18:41:31 Done.
+ suite('cr-policy-network-indicator', function() {
+ /** @type {!CrPolicyNetworkIndicatorElement|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-network-indicator');
+ document.body.appendChild(indicator);
+ tooltip = indicator.$$('paper-tooltip');
+ });
+
+ test('none', function() {
Dan Beam 2017/01/12 18:18:18 can we name this 'hidden by default' or something
stevenjb 2017/01/12 18:41:31 Done.
+ assertTrue(indicator.$.indicator.hidden);
Dan Beam 2017/01/12 18:18:18 can you create an accessor to this.$.indicator or
stevenjb 2017/01/12 18:41:31 Apologies for being dense, but I don't quite follo
Dan Beam 2017/01/18 01:57:57 Polymer({ is: '...', get icon() { return t
+ });
+
+ test('no policy', function() {
+ indicator.property = {Active: 'foo'};
+ Polymer.dom.flush();
+ assertTrue(indicator.$.indicator.hidden);
+ });
+
+ test('recommended', function() {
+ indicator.property = {
+ Active: 'foo',
+ UserPolicy: 'bar',
+ UserEditable: true,
+ Effective: 'UserPolicy',
+ };
+ Polymer.dom.flush();
+ assertFalse(indicator.$.indicator.hidden);
+ assertEquals('cr:domain', indicator.$.indicator.icon);
+ assertEquals('differs', tooltip.textContent.trim());
+
+ indicator.set('property.Active', 'bar');
+ Polymer.dom.flush();
+ assertEquals('matches', tooltip.textContent.trim());
+ });
+
+ test('policy', function() {
+ indicator.property = {
+ DevicePolicy: 'foo',
+ Effective: 'DevicePolicy',
+ };
+ Polymer.dom.flush();
+ assertFalse(indicator.$.indicator.hidden);
+ assertEquals('cr:domain', indicator.$.indicator.icon);
+ assertEquals('policy', tooltip.textContent.trim());
+ });
+
+ test('extension', function() {
+ indicator.property = {
+ Active: 'foo',
+ Effective: 'ActiveExtension',
+ };
+ Polymer.dom.flush();
+ // Extension controlled properties do not have an indicator.
+ assertTrue(indicator.$.indicator.hidden);
+ });
+ });
+
+ suiteTeardown(function() {
+ PolymerTest.clearBody(); // crbug.com/680169
+ });
+ }
+
+ return {
+ registerTests: registerTests,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698