OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** @fileoverview Suite of tests for cr_policy-pref-indicator. */ |
| 6 suite('CrPolicyPrefIndicator', function() { |
| 7 /** @type {!CrPolicyPrefIndicatorElement|undefined} */ |
| 8 var indicator; |
| 9 |
| 10 /** @type {!PaperTooltipElement|undefined} */ |
| 11 var tooltip; |
| 12 |
| 13 setup(function() { |
| 14 PolymerTest.clearBody(); |
| 15 |
| 16 CrPolicyStrings = { |
| 17 controlledSettingPolicy: 'policy', |
| 18 controlledSettingRecommendedMatches: 'matches', |
| 19 controlledSettingRecommendedDiffers: 'differs', |
| 20 controlledSettingShared: 'shared: $1', |
| 21 controlledSettingOwner: 'owner: $1', |
| 22 }; |
| 23 |
| 24 indicator = document.createElement('cr-policy-pref-indicator'); |
| 25 document.body.appendChild(indicator); |
| 26 tooltip = indicator.$$('paper-tooltip'); |
| 27 }); |
| 28 |
| 29 teardown(function() { |
| 30 PolymerTest.clearBody(); // crbug.com/680169 |
| 31 }); |
| 32 |
| 33 test('none', function() { |
| 34 assertTrue(indicator.$.indicator.hidden); |
| 35 }); |
| 36 |
| 37 test('indicatorType', function() { |
| 38 indicator.indicatorType = CrPolicyIndicatorType.DEVICE_POLICY; |
| 39 Polymer.dom.flush(); |
| 40 assertFalse(indicator.$.indicator.hidden); |
| 41 assertEquals('cr:domain', indicator.$.indicator.icon); |
| 42 assertEquals('policy', tooltip.textContent.trim()); |
| 43 }); |
| 44 |
| 45 test('pref', function() { |
| 46 /** @type {!chrome.settingsPrivate.PrefObject} */ |
| 47 indicator.pref = { |
| 48 key: 'foo', |
| 49 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 50 value: false, |
| 51 }; |
| 52 Polymer.dom.flush(); |
| 53 assertTrue(indicator.$.indicator.hidden); |
| 54 |
| 55 indicator.set( |
| 56 'pref.controlledBy', chrome.settingsPrivate.ControlledBy.OWNER); |
| 57 indicator.set('pref.controlledByName', 'owner_name'); |
| 58 indicator.set( |
| 59 'pref.enforcement', chrome.settingsPrivate.Enforcement.ENFORCED); |
| 60 Polymer.dom.flush(); |
| 61 assertFalse(indicator.$.indicator.hidden); |
| 62 assertEquals('cr:person', indicator.$.indicator.icon); |
| 63 assertEquals('owner: owner_name', tooltip.textContent.trim()); |
| 64 |
| 65 indicator.set('pref.value', 'foo'); |
| 66 indicator.set('pref.recommendedValue', 'bar'); |
| 67 indicator.set( |
| 68 'pref.enforcement', chrome.settingsPrivate.Enforcement.RECOMMENDED); |
| 69 Polymer.dom.flush(); |
| 70 assertFalse(indicator.$.indicator.hidden); |
| 71 assertEquals('cr:domain', indicator.$.indicator.icon); |
| 72 assertEquals('differs', tooltip.textContent.trim()); |
| 73 |
| 74 indicator.set('pref.value', 'bar'); |
| 75 Polymer.dom.flush(); |
| 76 assertEquals('matches', tooltip.textContent.trim()); |
| 77 }); |
| 78 }); |
OLD | NEW |