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

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

Issue 2861443003: MD Settings: Fix subpage visibility and add appearance page tests (Closed)
Patch Set: Restore showPage_ Created 3 years, 7 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/test/data/webui/settings/cr_settings_browsertest.js ('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/settings_main_test.js
diff --git a/chrome/test/data/webui/settings/settings_main_test.js b/chrome/test/data/webui/settings/settings_main_test.js
index 226259a20ad6f4eb3a5e3ef2fbe0167cd16d9e2c..acbbe9201dba45453ffc85defe971d08a00299e3 100644
--- a/chrome/test/data/webui/settings/settings_main_test.js
+++ b/chrome/test/data/webui/settings/settings_main_test.js
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-cr.define('settings_main_page', function() {
+cr.define('settings_test', function() {
/**
* Extending TestBrowserProxy even though SearchManager is not a browser proxy
* itself. Essentially TestBrowserProxy can act as a "proxy" for any external
@@ -22,7 +22,7 @@ cr.define('settings_main_page', function() {
/** @private {?settings.SearchRequest} */
this.searchRequest_ = null;
- }
+ };
TestSearchManager.prototype = {
__proto__: settings.TestBrowserProxy.prototype,
@@ -48,21 +48,25 @@ cr.define('settings_main_page', function() {
},
};
- function registerTests() {
- var settingsPrefs = null;
-
- suiteSetup(function() {
- settingsPrefs = document.createElement('settings-prefs');
- return CrSettingsPrefs.initialized;
- });
-
suite('MainPageTests', function() {
+ /** @type {?SettingsPrefsElement} */
+ var settingsPrefs = null;
+
/** @type {?TestSearchManager} */
var searchManager = null;
/** @type {?SettingsMainElement} */
var settingsMain = null;
+ suiteSetup(function() {
+ CrOncStrings = {};
+ settingsPrefs = document.createElement('settings-prefs');
+ var fakePrefs = [];
+ var fakeApi = new settings.FakeSettingsPrivate(fakePrefs);
+ settingsPrefs.initialize(fakeApi);
+ return CrSettingsPrefs.initialized;
+ });
+
setup(function() {
settings.navigateTo(settings.Route.BASIC);
searchManager = new TestSearchManager();
@@ -76,7 +80,9 @@ cr.define('settings_main_page', function() {
document.body.appendChild(settingsMain);
});
- teardown(function() { settingsMain.remove(); });
+ teardown(function() {
+ settingsMain.remove();
+ });
test('searchContents() triggers SearchManager', function() {
Polymer.dom.flush();
@@ -169,17 +175,22 @@ cr.define('settings_main_page', function() {
/**
* Asserts the visibility of the basic and advanced pages.
- * @param {string} Expected 'display' value for the basic page.
- * @param {string} Expected 'display' value for the advanced page.
+ * @param {string} expectedBasic 'display' value for the basic page.
+ * @param {string} expectedAdvanced 'display' value for the advanced page.
*/
function assertPageVisibility(expectedBasic, expectedAdvanced) {
Polymer.dom.flush();
var page = settingsMain.$$('settings-basic-page');
- assertEquals(
- expectedBasic, page.$$('#basicPage').style.display);
- assertEquals(
- expectedAdvanced,
- page.$$('#advancedPageTemplate').get().style.display);
+ assertEquals(expectedBasic, page.$$('#basicPage').style.display);
+
+ var advanced = page.$$('#advancedPage');
+ if (!advanced) {
+ assertEquals(expectedAdvanced, 'none');
+ } else if (advanced.hidden) {
+ assertEquals(expectedAdvanced, 'none');
+ } else {
+ assertEquals(expectedAdvanced, advanced.style.display);
+ }
}
// TODO(michaelpg): It would be better not to drill into
@@ -209,6 +220,7 @@ cr.define('settings_main_page', function() {
// Simulating searching while the advanced page is collapsed.
settingsMain.currentRouteChanged(settings.Route.BASIC);
Polymer.dom.flush();
+ assertPageVisibility('', 'none');
return assertPageVisibilityAfterSearch('', 'none');
});
@@ -256,21 +268,80 @@ cr.define('settings_main_page', function() {
assertPageVisibility('', 'none');
});
+ test('navigating to an advanced page expands advanced', function() {
+ settings.navigateTo(settings.Route.PRIVACY);
+ Polymer.dom.flush();
+ return Polymer.Base.async(function() {
+ assertToggleContainerVisible(true);
+ assertPageVisibility('', '');
+ });
+ });
+
test('navigating to a basic page does not collapse advanced', function() {
settings.navigateTo(settings.Route.PRIVACY);
Polymer.dom.flush();
+ return Promise.all([
+ Polymer.Base.async(function() {
+ assertToggleContainerVisible(true);
+ assertPageVisibility('', '');
+
+ settings.navigateTo(settings.Route.PEOPLE);
+ Polymer.dom.flush();
+ }),
+ Polymer.Base.async(function() {
+ assertPageVisibility('', '');
+ })
+ ]);
+ });
- assertToggleContainerVisible(true);
+ test('basic pageVisibility', function() {
+ Polymer.dom.flush();
+ var page = settingsMain.$$('settings-basic-page');
+ assertTrue(!!page);
+ return Polymer.Base.async(function() {
+ assertTrue(!!page.$$('settings-section[section="people"]'));
+ assertTrue(!!page.$$('settings-section[section="appearance"]'));
+ assertFalse(!!page.$$('settings-section[section="privacy"]'));
+ assertFalse(
+ !!page.$$('settings-section[section="passwordsAndForms"]'));
+ });
+ });
- settings.navigateTo(settings.Route.PEOPLE);
+ test('advanced pageVisibility', function() {
+ Polymer.dom.flush();
+ var page = settingsMain.$$('settings-basic-page');
+ var advancedToggle = page.$$('#advancedToggle');
+ assertTrue(!!advancedToggle);
+ MockInteractions.tap(advancedToggle);
Polymer.dom.flush();
+ return Polymer.Base.async(function() {
+ assertTrue(!!page.$$('settings-section[section="people"]'));
+ assertTrue(!!page.$$('settings-section[section="appearance"]'));
+ assertTrue(!!page.$$('settings-section[section="privacy"]'));
+ assertTrue(
+ !!page.$$('settings-section[section="passwordsAndForms"]'));
+ });
+ });
- assertPageVisibility('', '');
+ test('custom pageVisibility', function() {
+ Polymer.dom.flush();
+ var page = settingsMain.$$('settings-basic-page');
+ assertTrue(!!page);
+ Polymer.dom.flush();
+ return Promise.all([
+ Polymer.Base.async(function() {
+ assertTrue(!!page.$$('settings-section[section="people"]'));
+ assertTrue(!!page.$$('settings-section[section="appearance"]'));
+ }),
+ Polymer.Base.async(function() {
+ page.set('pageVisibility.appearance', false);
+ Polymer.dom.flush();
+ }),
+ Polymer.Base.async(function() {
+ assertTrue(!!page.$$('settings-section[section="people"]'));
+ assertFalse(!!page.$$('settings-section[section="appearance"]'));
+ })
+ ]);
});
});
- }
-
- return {
- registerTests: registerTests,
- };
});
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698