Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5426)

Unified Diff: chrome/test/data/webui/settings/appearance_page_test.js

Issue 2426863002: MD Settings: don't allow supervised users to switch to GTK+ theme (Closed)
Patch Set: split tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/appearance_page_test.js
diff --git a/chrome/test/data/webui/settings/appearance_page_test.js b/chrome/test/data/webui/settings/appearance_page_test.js
index 4ade4fc2f9c366a241d3c4dff5e9d28d25dc3771..49b49090c4be02954eb21c72a3d8769a7f5adb27 100644
--- a/chrome/test/data/webui/settings/appearance_page_test.js
+++ b/chrome/test/data/webui/settings/appearance_page_test.js
@@ -15,6 +15,7 @@ cr.define('settings_appearance', function() {
var TestAppearanceBrowserProxy = function() {
settings.TestBrowserProxy.call(this, [
'getThemeInfo',
+ 'isSupervised',
'openWallpaperManager',
'useDefaultTheme',
'useSystemTheme',
@@ -24,6 +25,9 @@ cr.define('settings_appearance', function() {
TestAppearanceBrowserProxy.prototype = {
__proto__: settings.TestBrowserProxy.prototype,
+ /** @private */
+ isSupervised_: false,
+
/** @override */
getThemeInfo: function(themeId) {
this.methodCalled('getThemeInfo', themeId);
@@ -31,6 +35,12 @@ cr.define('settings_appearance', function() {
},
/** @override */
+ isSupervised: function() {
+ this.methodCalled('isSupervised');
+ return this.isSupervised_;
+ },
+
+ /** @override */
openWallpaperManager: function() {
this.methodCalled('openWallpaperManager');
},
@@ -44,6 +54,11 @@ cr.define('settings_appearance', function() {
useSystemTheme: function() {
this.methodCalled('useSystemTheme');
},
+
+ /** @param {boolean} Whether the user is supervised */
+ setIsSupervised: function(isSupervised) {
+ this.isSupervised_ = isSupervised;
+ },
};
/**
@@ -105,7 +120,7 @@ cr.define('settings_appearance', function() {
extensions: {
theme: {
id: {
- value: 'asdf',
+ value: '',
},
use_system: {
value: false,
@@ -134,20 +149,78 @@ cr.define('settings_appearance', function() {
});
}
- test('useDefaultTheme', function() {
- var button = appearancePage.$$('#useDefault');
- assertTrue(!!button);
- MockInteractions.tap(button);
- return appearanceBrowserProxy.whenCalled('useDefaultTheme');
- });
+ var THEME_ID_PREF = 'prefs.extensions.theme.id.value';
if (cr.isLinux && !cr.isChromeOS) {
- test('useSystemTheme', function() {
+ var USE_SYSTEM_PREF = 'prefs.extensions.theme.use_system.value';
+
+ test('useDefaultThemeLinux', function() {
+ assertFalse(!!appearancePage.get(THEME_ID_PREF));
+ assertFalse(appearancePage.get(USE_SYSTEM_PREF));
+ // No custom nor system theme in use; "USE CLASSIC" should be hidden.
+ assertFalse(!!appearancePage.$$('#useDefault'));
+
+ appearancePage.set(USE_SYSTEM_PREF, true);
+ Polymer.dom.flush();
+ // If the system theme is in use, "USE CLASSIC" should show.
+ assertTrue(!!appearancePage.$$('#useDefault'));
+
+ appearancePage.set(USE_SYSTEM_PREF, false);
+ appearancePage.set(THEME_ID_PREF, 'fake theme id');
+ Polymer.dom.flush();
+
+ // With a custom theme installed, "USE CLASSIC" should show.
+ var button = appearancePage.$$('#useDefault');
+ assertTrue(!!button);
+
+ MockInteractions.tap(button);
+ return appearanceBrowserProxy.whenCalled('useDefaultTheme');
+ });
+
+ test('useSystemThemeLinux', function() {
+ assertFalse(!!appearancePage.get(THEME_ID_PREF));
+ appearancePage.set(USE_SYSTEM_PREF, true);
+ Polymer.dom.flush();
+ // The "USE GTK+" button shouldn't be showing if it's already in use.
+ assertFalse(!!appearancePage.$$('#useSystem'));
+
+ appearanceBrowserProxy.setIsSupervised(true);
+ appearancePage.set(USE_SYSTEM_PREF, false);
+ Polymer.dom.flush();
+ // Supervised users have their own theme and can't use GTK+ theme.
+ assertFalse(!!appearancePage.$$('#useDefault'));
+ assertFalse(!!appearancePage.$$('#useSystem'));
+ // If there's no "USE" buttons, the container should be hidden.
+ assertTrue(appearancePage.$$('.secondary-action').hidden);
+
+ appearanceBrowserProxy.setIsSupervised(false);
+ appearancePage.set(THEME_ID_PREF, 'fake theme id');
+ Polymer.dom.flush();
+ // If there's "USE" buttons again, the container should be visible.
+ assertTrue(!!appearancePage.$$('#useDefault'));
+ assertFalse(appearancePage.$$('.secondary-action').hidden);
+
var button = appearancePage.$$('#useSystem');
assertTrue(!!button);
+
MockInteractions.tap(button);
return appearanceBrowserProxy.whenCalled('useSystemTheme');
});
+ } else {
+ test('useDefaultTheme', function() {
+ assertFalse(!!appearancePage.get(THEME_ID_PREF));
+ assertFalse(!!appearancePage.$$('#useDefault'));
+
+ appearancePage.set(THEME_ID_PREF, 'fake theme id');
+ Polymer.dom.flush();
+
+ // With a custom theme installed, "RESET TO DEFAULT" should show.
+ var button = appearancePage.$$('#useDefault');
+ assertTrue(!!button);
+
+ MockInteractions.tap(button);
+ return appearanceBrowserProxy.whenCalled('useDefaultTheme');
+ });
}
});
}
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698