Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('settings_system_page', function() { | |
| 6 var HARDWARE_ACCELERATION_ENABLED_AT_STARTUP = true; | |
| 7 | |
| 8 /** | |
| 9 * @constructor | |
| 10 * @extends {TestBrowserProxy} | |
| 11 * @implements {settings.SystemPageBrowserProxy} | |
| 12 */ | |
| 13 function TestSystemPageBrowserProxy() { | |
| 14 settings.TestBrowserProxy.call(this, ['restartBrowser']); | |
| 15 } | |
| 16 | |
| 17 TestSystemPageBrowserProxy.prototype = { | |
| 18 __proto__: settings.TestBrowserProxy.prototype, | |
| 19 | |
| 20 /** @override */ | |
| 21 changeProxySettings: assertNotReached, | |
| 22 | |
| 23 /** @override */ | |
| 24 restartBrowser: function() { | |
| 25 this.methodCalled('restartBrowser'); | |
| 26 }, | |
| 27 | |
| 28 /** @override */ | |
| 29 wasHardwareAccelerationEnabledAtStartup: function() { | |
| 30 return HARDWARE_ACCELERATION_ENABLED_AT_STARTUP; | |
| 31 }, | |
| 32 }; | |
| 33 | |
| 34 suite('SettingsDevicePage', function() { | |
| 35 /** @type {CrSettingsPrefsElement} */ | |
| 36 var settingsPrefs = null; | |
| 37 | |
| 38 /** @type {settings.FakeSettingsPrivate} */ | |
| 39 var fakeSettingsPrivate = null; | |
| 40 | |
| 41 /** @type {settings.TestSystemPageBrowserProxy} */ | |
| 42 var testBrowserProxy; | |
| 43 | |
| 44 var fakePrefs = [{ | |
| 45 key: 'background_mode.enabled', | |
| 46 type: chrome.settingsPrivate.PrefType.BOOLEAN, | |
| 47 value: true, | |
| 48 }, { | |
| 49 key: 'hardware_acceleration_mode.enabled', | |
| 50 type: chrome.settingsPrivate.PrefType.BOOLEAN, | |
| 51 value: HARDWARE_ACCELERATION_ENABLED_AT_STARTUP, | |
| 52 }]; | |
| 53 | |
| 54 // Initialize <settings-device-page> before each test. | |
| 55 setup(function() { | |
| 56 CrSettingsPrefs.deferInitialization = true; | |
| 57 | |
| 58 fakeSettingsPrivate = new settings.FakeSettingsPrivate(fakePrefs); | |
| 59 | |
| 60 settingsPrefs = document.createElement('settings-prefs'); | |
| 61 settingsPrefs.initializeForTesting(fakeSettingsPrivate); | |
| 62 | |
| 63 testBrowserProxy = new TestSystemPageBrowserProxy; | |
| 64 settings.SystemPageBrowserProxyImpl.instance_ = testBrowserProxy; | |
| 65 | |
| 66 return CrSettingsPrefs.initialized; | |
| 67 }); | |
| 68 | |
| 69 test('restart button', function() { | |
| 70 var systemPage = document.createElement('settings-system-page'); | |
| 71 systemPage.set('prefs', settingsPrefs.prefs); | |
|
michaelpg
2016/03/22 00:43:50
this won't bind systemPage.prefs to settingsPrefs.
Dan Beam
2016/03/22 02:17:00
Done.
| |
| 72 | |
| 73 // Restart button should be hidden by default. | |
| 74 expectFalse(!!systemPage.$$('#hardware-acceleration paper-button')); | |
| 75 | |
| 76 // TODO(dbeam): why doesn't settingsPrefs.set() work here? | |
| 77 systemPage.set('prefs.hardware_acceleration_mode.enabled.value', | |
| 78 !HARDWARE_ACCELERATION_ENABLED_AT_STARTUP); | |
| 79 Polymer.dom.flush(); | |
| 80 | |
| 81 var restart = systemPage.$$('#hardware-acceleration paper-button'); | |
| 82 expectTrue(!!restart); // The "RESTART" button should be showing now. | |
| 83 | |
| 84 MockInteractions.tap(restart); | |
| 85 return testBrowserProxy.whenCalled('restartBrowser'); | |
| 86 }); | |
| 87 }); | |
| 88 }); | |
| OLD | NEW |