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. */ | |
| 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. | |
| 45 CrPolicyStrings = { | |
| 46 controlledSettingPolicy: 'policy', | |
| 47 controlledSettingRecommendedMatches: 'matches', | |
| 48 controlledSettingRecommendedDiffers: 'differs', | |
| 49 controlledSettingShared: 'shared: $1', | |
| 50 controlledSettingOwner: 'owner: $1', | |
| 51 }; | |
| 52 | |
|
michaelpg
2017/02/15 02:02:11
nit: remove blank line
stevenjb
2017/02/15 02:23:29
Done.
| |
| 53 }); | |
| 54 | |
| 55 setup(function() { | |
| 56 PolymerTest.clearBody(); | |
| 57 | |
| 58 indicator = document.createElement('cr-policy-pref-indicator'); | |
| 59 document.body.appendChild(indicator); | |
| 60 tooltip = indicator.$$('paper-tooltip'); | |
| 61 }); | |
| 62 | |
| 63 teardown(function() { | |
| 64 PolymerTest.clearBody(); // crbug.com/680169 | |
| 65 }); | |
| 66 | |
| 67 test('none', function() { | |
| 68 assertTrue(indicator.$.indicator.hidden); | |
| 69 }); | |
| 70 | |
| 71 test('pref', function() { | |
| 72 /** @type {!chrome.settingsPrivate.PrefObject} */ | |
| 73 indicator.pref = { | |
| 74 key: 'foo', | |
| 75 type: chrome.settingsPrivate.PrefType.BOOLEAN, | |
| 76 value: false, | |
| 77 }; | |
| 78 Polymer.dom.flush(); | |
| 79 assertTrue(indicator.$.indicator.hidden); | |
| 80 | |
| 81 indicator.set( | |
| 82 'pref.controlledBy', chrome.settingsPrivate.ControlledBy.OWNER); | |
| 83 indicator.set('pref.controlledByName', 'owner_name'); | |
| 84 indicator.set( | |
| 85 'pref.enforcement', chrome.settingsPrivate.Enforcement.ENFORCED); | |
| 86 Polymer.dom.flush(); | |
| 87 assertFalse(indicator.$.indicator.hidden); | |
| 88 assertEquals('cr:person', indicator.$.indicator.icon); | |
| 89 assertEquals('owner: owner_name', tooltip.textContent.trim()); | |
| 90 | |
| 91 indicator.set('pref.value', 'foo'); | |
| 92 indicator.set('pref.recommendedValue', 'bar'); | |
| 93 indicator.set( | |
| 94 'pref.enforcement', chrome.settingsPrivate.Enforcement.RECOMMENDED); | |
| 95 Polymer.dom.flush(); | |
| 96 assertFalse(indicator.$.indicator.hidden); | |
| 97 assertEquals('cr20:domain', indicator.$.indicator.icon); | |
| 98 assertEquals('differs', tooltip.textContent.trim()); | |
| 99 | |
| 100 indicator.set('pref.value', 'bar'); | |
| 101 Polymer.dom.flush(); | |
| 102 assertEquals('matches', tooltip.textContent.trim()); | |
| 103 }); | |
| 104 }); | |
| OLD | NEW |