Chromium Code Reviews| Index: chrome/test/data/webui/settings/system_page_tests.js |
| diff --git a/chrome/test/data/webui/settings/system_page_tests.js b/chrome/test/data/webui/settings/system_page_tests.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..664c533d124984600abdba760a634d05033810d1 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/settings/system_page_tests.js |
| @@ -0,0 +1,88 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('settings_system_page', function() { |
| + var HARDWARE_ACCELERATION_ENABLED_AT_STARTUP = true; |
|
dpapad
2016/03/21 18:17:38
Nit: @const {boolean}
Dan Beam
2016/03/22 02:16:59
Done.
|
| + |
| + /** |
| + * @constructor |
| + * @extends {TestBrowserProxy} |
| + * @implements {settings.SystemPageBrowserProxy} |
| + */ |
| + function TestSystemPageBrowserProxy() { |
| + settings.TestBrowserProxy.call(this, ['restartBrowser']); |
| + } |
| + |
| + TestSystemPageBrowserProxy.prototype = { |
| + __proto__: settings.TestBrowserProxy.prototype, |
| + |
| + /** @override */ |
| + changeProxySettings: assertNotReached, |
| + |
| + /** @override */ |
| + restartBrowser: function() { |
| + this.methodCalled('restartBrowser'); |
| + }, |
| + |
| + /** @override */ |
| + wasHardwareAccelerationEnabledAtStartup: function() { |
| + return HARDWARE_ACCELERATION_ENABLED_AT_STARTUP; |
| + }, |
| + }; |
| + |
| + suite('SettingsDevicePage', function() { |
| + /** @type {CrSettingsPrefsElement} */ |
| + var settingsPrefs = null; |
| + |
| + /** @type {settings.FakeSettingsPrivate} */ |
| + var fakeSettingsPrivate = null; |
| + |
| + /** @type {settings.TestSystemPageBrowserProxy} */ |
| + var testBrowserProxy; |
| + |
| + var fakePrefs = [{ |
| + key: 'background_mode.enabled', |
| + type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| + value: true, |
| + }, { |
| + key: 'hardware_acceleration_mode.enabled', |
| + type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| + value: HARDWARE_ACCELERATION_ENABLED_AT_STARTUP, |
| + }]; |
| + |
| + // Initialize <settings-device-page> before each test. |
| + setup(function() { |
| + CrSettingsPrefs.deferInitialization = true; |
| + |
| + fakeSettingsPrivate = new settings.FakeSettingsPrivate(fakePrefs); |
| + |
| + settingsPrefs = document.createElement('settings-prefs'); |
| + settingsPrefs.initializeForTesting(fakeSettingsPrivate); |
| + |
| + testBrowserProxy = new TestSystemPageBrowserProxy; |
| + settings.SystemPageBrowserProxyImpl.instance_ = testBrowserProxy; |
| + |
| + return CrSettingsPrefs.initialized; |
| + }); |
| + |
| + test('restart button', function() { |
| + var systemPage = document.createElement('settings-system-page'); |
|
dpapad
2016/03/21 18:17:38
It is a bit odd that you are testing your element
Dan Beam
2016/03/22 02:16:59
Done.
|
| + systemPage.set('prefs', settingsPrefs.prefs); |
| + |
| + // Restart button should be hidden by default. |
| + expectFalse(!!systemPage.$$('#hardware-acceleration paper-button')); |
| + |
| + // TODO(dbeam): why doesn't settingsPrefs.set() work here? |
| + systemPage.set('prefs.hardware_acceleration_mode.enabled.value', |
| + !HARDWARE_ACCELERATION_ENABLED_AT_STARTUP); |
| + Polymer.dom.flush(); |
| + |
| + var restart = systemPage.$$('#hardware-acceleration paper-button'); |
| + expectTrue(!!restart); // The "RESTART" button should be showing now. |
| + |
| + MockInteractions.tap(restart); |
| + return testBrowserProxy.whenCalled('restartBrowser'); |
| + }); |
| + }); |
|
dpapad
2016/03/21 18:17:38
Should we also add a test to ensure that the setti
Dan Beam
2016/03/22 02:17:00
Done.
|
| +}); |