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

Side by Side Diff: chrome/test/data/webui/settings/basic_page_browsertest.js

Issue 2022893003: [MD settings] scroll to section find host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: closure fix Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @fileoverview Suite of tests for the Settings basic page. */ 5 /** @fileoverview Suite of tests for the Settings basic page. */
6 6
7 GEN_INCLUDE(['settings_page_browsertest.js']); 7 GEN_INCLUDE(['settings_page_browsertest.js']);
8 8
9 /** 9 /**
10 * @constructor 10 * @constructor
11 * @extends {SettingsPageBrowserTest} 11 * @extends {SettingsPageBrowserTest}
12 */ 12 */
13 function SettingsBasicPageBrowserTest() {} 13 function SettingsBasicPageBrowserTest() {}
14 14
15 SettingsBasicPageBrowserTest.prototype = { 15 SettingsBasicPageBrowserTest.prototype = {
16 __proto__: SettingsPageBrowserTest.prototype 16 __proto__: SettingsPageBrowserTest.prototype
17 }; 17 };
18 18
19 // Times out on debug builders and may time out on memory bots because 19 // Times out on debug builders and may time out on memory bots because
20 // the Settings page can take several seconds to load in a Release build 20 // the Settings page can take several seconds to load in a Release build
21 // and several times that in a Debug build. See https://crbug.com/558434. 21 // and several times that in a Debug build. See https://crbug.com/558434.
22 GEN('#if defined(MEMORY_SANITIZER) || !defined(NDEBUG)'); 22 GEN('#if defined(MEMORY_SANITIZER) || !defined(NDEBUG)');
23 GEN('#define MAYBE_Load DISABLED_Load'); 23 GEN('#define MAYBE_Load DISABLED_Load');
24 GEN('#else'); 24 GEN('#else');
25 GEN('#define MAYBE_Load Load'); 25 GEN('#define MAYBE_Load Load');
26 GEN('#endif'); 26 GEN('#endif');
27 27
28 TEST_F('SettingsBasicPageBrowserTest', 'MAYBE_Load', function() { 28 TEST_F('SettingsBasicPageBrowserTest', 'MAYBE_Load', function() {
michaelpg 2016/06/06 20:13:04 Load is no longer an appropriate name for this tes
29 // Assign |self| to |this| instead of binding since 'this' in suite() 29 // Assign |self| to |this| instead of binding since 'this' in suite()
30 // and test() will be a Mocha 'Suite' or 'Test' instance. 30 // and test() will be a Mocha 'Suite' or 'Test' instance.
31 var self = this; 31 var self = this;
32 32
33 // Register mocha tests. 33 // Register mocha tests.
34 suite('SettingsPage', function() { 34 suite('SettingsPage', function() {
35 test('load page', function() { 35 test('load page', function() {
36 // This will fail if there are any asserts or errors in the Settings page. 36 // This will fail if there are any asserts or errors in the Settings page.
37 }); 37 });
38 38
39 test('basic pages', function() { 39 test('basic pages', function() {
40 var page = self.getPage('basic'); 40 var page = self.getPage('basic');
41 var sections = ['appearance', 'onStartup', 'people', 'search']; 41 var sections = ['appearance', 'onStartup', 'people', 'search'];
42 expectTrue(!!self.getSection(page, 'appearance')); 42 expectTrue(!!self.getSection(page, 'appearance'));
43 if (!cr.isChromeOS) 43 if (!cr.isChromeOS)
44 sections.push('defaultBrowser'); 44 sections.push('defaultBrowser');
45 else 45 else
46 sections = sections.concat(['internet', 'device']); 46 sections = sections.concat(['internet', 'device']);
47 47
48 for (var i = 0; i < sections.length; i++) { 48 for (var i = 0; i < sections.length; i++) {
49 var section = self.getSection(page, sections[i]); 49 var section = self.getSection(page, sections[i]);
50 expectTrue(!!section); 50 expectTrue(!!section);
51 self.verifySubpagesHidden(section); 51 self.verifySubpagesHidden(section);
52 } 52 }
53 }); 53 });
54
55 // This test checks for a regression that occurred with scrollToSection_
56 // failing to find its host element.
57 test('scroll to section', function() {
58 // Setting the page and section will cause a scrollToSection_.
59 self.getPage('basic').currentRoute = {
michaelpg 2016/06/06 20:13:03 Since this is a test of the entire page, why not t
60 page: 'basic',
61 section: 'onStartup',
62 subpage: [],
63 };
64
65 return new Promise(function(resolve, reject) {
66 var intervalId = window.setInterval(function() {
67 var page = self.getPage('basic');
68 if (self.getSection(page, page.currentRoute.section)) {
michaelpg 2016/06/06 20:13:04 Why not actually *check* page.scroller.scrollTop t
69 window.clearInterval(intervalId);
70 resolve();
71 }
72 }, 55);
michaelpg 2016/06/06 20:13:03 This is an unnecessary use of setInterval when set
73 }.bind(self));
74 });
54 }); 75 });
55 76
56 // Run all registered tests. 77 // Run all registered tests.
57 mocha.run(); 78 mocha.run();
58 }); 79 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698