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

Side by Side Diff: chrome/test/data/webui/ntp4.js

Issue 9625020: Ported NTP4 UI tests to WebUI. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Excludes one irrelevant test for ChromeOS. Created 8 years, 9 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/webui/ntp4_browsertest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 GEN('#include "chrome/test/data/webui/ntp4_browsertest.h"');
6
5 /** 7 /**
6 * TestFixture for NTP4 WebUI testing. 8 * TestFixture for NTP4 WebUI testing.
7 * @extends {testing.Test} 9 * @extends {testing.Test}
8 * @constructor 10 * @constructor
9 */ 11 */
10 function NTP4WebUITest() {} 12 function NTP4WebUITest() {}
11 13
12 NTP4WebUITest.prototype = { 14 NTP4WebUITest.prototype = {
13 __proto__: testing.Test.prototype, 15 __proto__: testing.Test.prototype,
14 16
15 /** 17 /** @override */
16 * Browse to the newtab page & call preLoad().
17 */
18 browsePreload: 'chrome://newtab', 18 browsePreload: 'chrome://newtab',
19 }; 19 };
20 20
21 // Test loading new tab page and selecting each card doesn't have console 21 // Test loading new tab page and selecting each card doesn't have console
22 // errors. 22 // errors.
23 TEST_F('NTP4WebUITest', 'TestBrowsePages', function() { 23 TEST_F('NTP4WebUITest', 'TestBrowsePages', function() {
24 // This tests the ntp4 new tab page which is not used on touch builds. 24 // This tests the ntp4 new tab page which is not used on touch builds.
25 var cardSlider = ntp.getCardSlider(); 25 var cardSlider = ntp.getCardSlider();
26 assertNotEquals(null, cardSlider); 26 assertNotEquals(null, cardSlider);
27 for (var i = 0; i < cardSlider.cardCount; ++i) { 27 for (var i = 0; i < cardSlider.cardCount; i++) {
28 cardSlider.selectCard(i); 28 cardSlider.selectCard(i);
29 expectEquals(i, cardSlider.currentCard); 29 expectEquals(i, cardSlider.currentCard);
30 } 30 }
31 }); 31 });
32
33 TEST_F('NTP4WebUITest', 'NTPHasThumbnails', function() {
34 var mostVisited = document.querySelectorAll('.most-visited');
35 assertEquals(8, mostVisited.length, 'There should be 8 most visited tiles.');
36
37 if (window.templateData.showAppsPage) {
Dan Beam 2012/03/14 03:48:13 you should test the opposite of this case as well,
Danh Nguyen 2012/03/14 16:15:05 Done.
38 var apps = document.querySelectorAll('.app');
39 assertGE(apps.length, 1, 'There should be at least one app.');
40 }
41 });
42
43 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() {
44 if (window.templateData.showAppsPage) {
Dan Beam 2012/03/14 03:48:13 and here, there will be no nav dots in "bare-minim
Danh Nguyen 2012/03/14 16:15:05 Done.
45 var navDots = document.querySelectorAll('.dot');
46 assertGE(navDots.length, 2, 'There should be at least two navdots.');
47 }
48 });
49
50 TEST_F('NTP4WebUITest', 'NTPHasSelectedPageAndDot', function() {
51 var selectedDot = document.querySelectorAll('.dot.selected');
52 assertEquals(1, selectedDot.length, 'There should be only one selected dot.');
53
54 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card');
55 assertEquals(1, selectedTilePage.length,
56 'There should be only one selected tile page.');
57 });
58
59 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() {
60 var userName = document.querySelector('#login-status-header .profile-name');
61 assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.');
62 });
63
64 /**
65 * Test fixture for NTP4 WebUI testing with login.
66 * @extends {NTP4WebUITest}
67 * @constructor
68 */
69 function NTP4LoggedInWebUITest() {}
70
71 NTP4LoggedInWebUITest.prototype = {
72 __proto__: NTP4WebUITest.prototype,
73
74 /** @override */
75 typedefCppFixture: 'NTP4LoggedInWebUITest',
76
77 /** @override */
78 testGenPreamble: function() {
79 GEN(' SetLoginName("user@gmail.com");');
80 },
81 };
82
83 // The following test is irrelevant to Chrome on Chrome OS.
84 GEN('#if !defined(OS_CHROMEOS)');
85
86 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() {
87 var userName = document.querySelector('#login-status-header .profile-name');
88 assertNotEquals(userName, null, 'The logged-in user name can\'t be found.');
89 assertEquals('user@gmail.com', userName.textContent,
90 'The user name should be present on the new tab.');
91 });
92
93 GEN('#endif');
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/webui/ntp4_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698