Chromium Code Reviews| 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. */ | |
|
michaelpg
2017/02/16 21:36:22
cr-policy
stevenjb
2017/02/17 01:08:29
Done.
| |
| 6 suite('CrPolicyPrefIndicator', function() { | |
| 7 /** @type {!CrPolicyPrefIndicatorElement|undefined} */ | |
| 8 var indicator; | |
| 9 | |
| 10 /** @type {!PaperTooltipElement|undefined} */ | |
| 11 var tooltip; | |
| 12 | |
| 13 suiteSetup(function() { | |
| 14 // Define chrome.settingsPrivate enums, normally provided by chrome WebUI. | |
| 15 // NOTE: These need to be kept in sync with settings_private.idl. | |
| 16 | |
| 17 chrome.settingsPrivate = chrome.settingsPrivate || {}; | |
| 18 | |
| 19 /** @enum {string} */ | |
| 20 chrome.settingsPrivate.ControlledBy = { | |
| 21 DEVICE_POLICY: 'DEVICE_POLICY', | |
| 22 USER_POLICY: 'USER_POLICY', | |
| 23 OWNER: 'OWNER', | |
| 24 PRIMARY_USER: 'PRIMARY_USER', | |
| 25 EXTENSION: 'EXTENSION', | |
| 26 }; | |
| 27 | |
| 28 /** @enum {string} */ | |
| 29 chrome.settingsPrivate.Enforcement = { | |
| 30 ENFORCED: 'ENFORCED', | |
| 31 RECOMMENDED: 'RECOMMENDED', | |
| 32 }; | |
| 33 | |
| 34 /** @enum {string} */ | |
| 35 chrome.settingsPrivate.PrefType = { | |
| 36 BOOLEAN: 'BOOLEAN', | |
| 37 NUMBER: 'NUMBER', | |
| 38 STRING: 'STRING', | |
| 39 URL: 'URL', | |
| 40 LIST: 'LIST', | |
| 41 DICTIONARY: 'DICTIONARY', | |
| 42 }; | |
| 43 | |
| 44 // 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.
| |
| 45 CrPolicyStrings = { | |
| 46 controlledSettingPolicy: 'policy', | |
| 47 controlledSettingRecommendedMatches: 'matches', | |
| 48 controlledSettingRecommendedDiffers: 'differs', | |
| 49 controlledSettingShared: 'shared: $1', | |
| 50 controlledSettingOwner: 'owner: $1', | |
| 51 }; | |
| 52 }); | |
| 53 | |
| 54 setup(function() { | |
| 55 PolymerTest.clearBody(); | |
| 56 | |
| 57 indicator = document.createElement('cr-policy-pref-indicator'); | |
| 58 document.body.appendChild(indicator); | |
| 59 tooltip = indicator.$$('paper-tooltip'); | |
| 60 }); | |
| 61 | |
| 62 teardown(function() { | |
| 63 PolymerTest.clearBody(); // crbug.com/680169 | |
| 64 }); | |
| 65 | |
| 66 test('none', function() { | |
| 67 assertTrue(indicator.$.indicator.hidden); | |
| 68 }); | |
| 69 | |
| 70 test('pref', function() { | |
| 71 /** @type {!chrome.settingsPrivate.PrefObject} */ | |
| 72 indicator.pref = { | |
| 73 key: 'foo', | |
| 74 type: chrome.settingsPrivate.PrefType.BOOLEAN, | |
| 75 value: false, | |
| 76 }; | |
| 77 Polymer.dom.flush(); | |
| 78 assertTrue(indicator.$.indicator.hidden); | |
| 79 | |
| 80 indicator.set( | |
| 81 'pref.controlledBy', chrome.settingsPrivate.ControlledBy.OWNER); | |
| 82 indicator.set('pref.controlledByName', 'owner_name'); | |
| 83 indicator.set( | |
| 84 'pref.enforcement', chrome.settingsPrivate.Enforcement.ENFORCED); | |
| 85 Polymer.dom.flush(); | |
| 86 assertFalse(indicator.$.indicator.hidden); | |
| 87 assertEquals('cr:person', indicator.$.indicator.icon); | |
| 88 assertEquals('owner: owner_name', tooltip.textContent.trim()); | |
| 89 | |
| 90 indicator.set('pref.value', 'foo'); | |
| 91 indicator.set('pref.recommendedValue', 'bar'); | |
| 92 indicator.set( | |
| 93 'pref.enforcement', chrome.settingsPrivate.Enforcement.RECOMMENDED); | |
| 94 Polymer.dom.flush(); | |
| 95 assertFalse(indicator.$.indicator.hidden); | |
| 96 assertEquals('cr20:domain', indicator.$.indicator.icon); | |
| 97 assertEquals('differs', tooltip.textContent.trim()); | |
| 98 | |
| 99 indicator.set('pref.value', 'bar'); | |
| 100 Polymer.dom.flush(); | |
| 101 assertEquals('matches', tooltip.textContent.trim()); | |
| 102 }); | |
| 103 }); | |
| OLD | NEW |