| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 suite('controlled button', function() { | 5 suite('controlled button', function() { |
| 6 /** @type {ControlledButtonElement} */ | 6 /** @type {ControlledButtonElement} */ |
| 7 var button; | 7 var button; |
| 8 | 8 |
| 9 /** @type {!chrome.settingsPrivate.PrefObject} */ | 9 /** @type {!chrome.settingsPrivate.PrefObject} */ |
| 10 var pref = { | 10 var pref = { |
| 11 key: 'test', | 11 key: 'test', |
| 12 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 12 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 13 value: true | 13 value: true |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 setup(function() { | 16 setup(function() { |
| 17 PolymerTest.clearBody(); | 17 PolymerTest.clearBody(); |
| 18 button = document.createElement('controlled-button'); | 18 button = document.createElement('controlled-button'); |
| 19 button.pref = pref; | 19 button.pref = pref; |
| 20 document.body.appendChild(button); | 20 document.body.appendChild(button); |
| 21 }); | 21 }); |
| 22 | 22 |
| 23 test('disables when pref is managed', function() { | 23 test('disables when pref is managed', function() { |
| 24 button.set('pref.policyEnforcement', | 24 button.set('pref.enforcement', chrome.settingsPrivate.Enforcement.ENFORCED); |
| 25 chrome.settingsPrivate.PolicyEnforcement.ENFORCED); | |
| 26 Polymer.dom.flush(); | 25 Polymer.dom.flush(); |
| 27 assertTrue(button.$$('paper-button').disabled); | 26 assertTrue(button.$$('paper-button').disabled); |
| 28 | 27 |
| 29 var indicator = button.$$('cr-policy-pref-indicator'); | 28 var indicator = button.$$('cr-policy-pref-indicator'); |
| 30 assertTrue(!!indicator); | 29 assertTrue(!!indicator); |
| 31 assertGT(indicator.clientHeight, 0); | 30 assertGT(indicator.clientHeight, 0); |
| 32 | 31 |
| 33 button.set('pref.policyEnforcement', undefined); | 32 button.set('pref.enforcement', undefined); |
| 34 Polymer.dom.flush(); | 33 Polymer.dom.flush(); |
| 35 assertFalse(button.$$('paper-button').disabled); | 34 assertFalse(button.$$('paper-button').disabled); |
| 36 assertEquals(0, indicator.clientHeight); | 35 assertEquals(0, indicator.clientHeight); |
| 37 }); | 36 }); |
| 38 }); | 37 }); |
| OLD | NEW |