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

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

Issue 2383563004: MD Settings: Tests for URL navigation on load. (Closed)
Patch Set: comment 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/test/BUILD.gn ('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_page_url_browsertest.js
diff --git a/chrome/test/data/webui/settings/settings_page_url_browsertest.js b/chrome/test/data/webui/settings/settings_page_url_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..ef253c471333afad2c7ec3dfaecc10fc8a253f92
--- /dev/null
+++ b/chrome/test/data/webui/settings/settings_page_url_browsertest.js
@@ -0,0 +1,159 @@
+// 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.
+
+/** @fileoverview Tests various settings URLs. */
+
+GEN_INCLUDE(['settings_page_browsertest.js']);
+
+/**
+ * @constructor
+ * @extends {SettingsPageBrowserTest}
+*/
+function SettingsPageURLBrowserTest() {}
+
+SettingsPageURLBrowserTest.prototype = {
+ __proto__: SettingsPageBrowserTest.prototype,
+
+ /** @return {number} Height of the cr-toolbar. */
+ getToolbarHeight: function() {
+ var toolbar = assert(document.querySelector('* /deep/ cr-toolbar'));
+ assertGT(toolbar.offsetHeight, 0);
+ return toolbar.offsetHeight;
+ },
+
+ /**
+ * Tests that the page opens with the section visible and at the top of the
+ * scroller.
+ * @param {string} pageName
+ * @param {string} sectionName
+ */
+ runSectionTest: function(pageName, sectionName) {
+ var page = this.getPage(pageName);
+ var section = assert(this.getSection(page, sectionName));
+
+ // Section starts at the top of the main page.
+ assertEquals(
+ this.getToolbarHeight(), section.getBoundingClientRect().top);
+ assertGT(section.offsetHeight, 0);
+
+ this.verifySubpagesHidden(section);
+ },
+
+ /**
+ * Tests that the page opens with the subpage visible and filling the page.
+ * May take several frames to complete. Returns a Promise which resolves on
+ * success, making this function a suitable parameter for test().
+ * @param {string} pageName
+ * @param {string} sectionName
+ * @return {!Promise} Test promise.
+ */
+ runSubpageTestAsync: function(pageName, sectionName) {
+ var page = this.getPage(pageName);
+
+ // Wait for expand animation to complete, leaving the page spanning the
+ // available vertical space.
+ var promise = new Promise(function(resolve, reject) {
+ (function keepChecking() {
+ if (page.getBoundingClientRect().bottom == window.innerHeight)
+ resolve();
+ else
+ requestAnimationFrame(keepChecking);
+ })();
+ });
+
+ return promise.then(function() {
+ assertEquals(page.getBoundingClientRect().bottom, window.innerHeight);
+
+ // Section extends at least to the bottom of the window.
+ var section = assert(this.getSection(page, sectionName));
+ assertGT(section.offsetHeight, 0);
+ assertEquals(
+ this.getToolbarHeight(), section.getBoundingClientRect().top);
+ assertGE(section.getBoundingClientRect().bottom, window.innerHeight);
+
+ // Subpage is stamped.
+ var pages = section.querySelector('* /deep/ settings-animated-pages');
+ assertTrue(!!pages);
+ var path = this.browsePreload.slice('chrome://md-settings'.length);
+ var subpage = pages.querySelector(
+ 'settings-subpage[route-path="' + path + '"]');
+ assertTrue(!!subpage);
+
+ // Subpage starts at the top of the main page.
+ assertEquals(
+ this.getToolbarHeight(), subpage.getBoundingClientRect().top);
+ assertGT(subpage.offsetHeight, 0);
+ }.bind(this));
+ },
+};
+
+// We're loading the whole MD Settings page and running animations, so disable
+// problematic builders. See https://crbug.com/558434.
+GEN('#if defined(MEMORY_SANITIZER) || defined(ADDRESS_SANITIZER) || ' +
+ '!defined(NDEBUG)');
+GEN('#define MAYBE_Load DISABLED_Load');
+GEN('#else');
+GEN('#define MAYBE_Load Load');
+GEN('#endif');
+
+// Loads a basic page section.
+function SettingsPageURLOnStartupTest() {}
+SettingsPageURLOnStartupTest.prototype = {
+ __proto__: SettingsPageURLBrowserTest.prototype,
+
+ /** @override */
+ browsePreload: 'chrome://md-settings/onStartup',
+};
+
+TEST_F('SettingsPageURLOnStartupTest', 'MAYBE_Load', function() {
+ test('scrolled to onStartup section',
+ this.runSectionTest.bind(this, 'basic', 'onStartup'));
+ mocha.run();
+});
+
+// Loads an advanced page section.
+function SettingsPageURLResetTest() {}
+SettingsPageURLResetTest.prototype = {
+ __proto__: SettingsPageURLBrowserTest.prototype,
+
+ /** @override */
+ browsePreload: 'chrome://md-settings/reset',
+};
+
+TEST_F('SettingsPageURLResetTest', 'MAYBE_Load', function() {
+ test('scrolled to reset section',
+ this.runSectionTest.bind(this, 'advanced', 'reset'));
+ mocha.run();
+});
+
+// Loads a basic page subpage.
+function SettingsPageURLSearchEnginesTest() {}
+SettingsPageURLSearchEnginesTest.prototype = {
+ __proto__: SettingsPageURLBrowserTest.prototype,
+
+ /** @override */
+ browsePreload: 'chrome://md-settings/searchEngines',
+};
+
+TEST_F('SettingsPageURLSearchEnginesTest', 'MAYBE_Load', function() {
+ test('opened searchEngines subpage',
+ this.runSubpageTestAsync.bind(this, 'basic', 'search'));
+ mocha.run();
+});
+
+// Loads an advanced page subpage.
+function SettingsPageURLSiteSettingsTest() {}
+SettingsPageURLSiteSettingsTest.prototype = {
+ __proto__: SettingsPageURLBrowserTest.prototype,
+
+ /** @override */
+ browsePreload: 'chrome://md-settings/siteSettings',
+};
+
+TEST_F('SettingsPageURLSiteSettingsTest', 'MAYBE_Load', function() {
+ test('opened siteSettings subpage',
+ this.runSubpageTestAsync.bind(
+ this, 'advanced', 'privacy'));
+ mocha.run();
+});
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698