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

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: Fixed nits and an assertion. 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 var apps = document.querySelectorAll('.app');
38 if (window.templateData.showApps)
39 assertGE(apps.length, 1, 'There should be at least one app.');
40 else
41 assertEquals(0, apps.length, 'There should be no apps.');
42 });
43
44 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() {
45 var navDots = document.querySelectorAll('.dot');
46 if (window.templateData.showApps)
47 assertGE(navDots.length, 2, 'There should be at least two navdots.');
48 else
49 assertEquals(1, navDots.length, 'There should be only one navdot.');
Evan Stade 2012/03/15 15:54:34 this is not quite true, there is an optional sugge
50 });
51
52 TEST_F('NTP4WebUITest', 'NTPHasSelectedPageAndDot', function() {
53 var selectedDot = document.querySelectorAll('.dot.selected');
54 assertEquals(1, selectedDot.length, 'There should be only one selected dot.');
55
56 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card');
57 assertEquals(1, selectedTilePage.length,
58 'There should be only one selected tile page.');
Evan Stade 2012/03/15 15:54:34 this string doesn't make sense if the length is ac
59 });
60
61 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() {
62 var userName = document.querySelector('#login-status-header .profile-name');
63 assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.');
64 });
65
66 /**
67 * Test fixture for NTP4 WebUI testing with login.
68 * @extends {NTP4WebUITest}
69 * @constructor
70 */
71 function NTP4LoggedInWebUITest() {}
72
73 NTP4LoggedInWebUITest.prototype = {
74 __proto__: NTP4WebUITest.prototype,
75
76 /** @override */
77 typedefCppFixture: 'NTP4LoggedInWebUITest',
78
79 /** @override */
80 testGenPreamble: function() {
81 GEN(' SetLoginName("user@gmail.com");');
82 },
83 };
84
85 // The following test is irrelevant to Chrome on Chrome OS.
86 GEN('#if !defined(OS_CHROMEOS)');
87
88 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() {
89 var userName = document.querySelector('#login-status-header .profile-name');
90 assertNotEquals(userName, null, 'The logged-in user name can\'t be found.');
91 assertEquals('user@gmail.com', userName.textContent,
92 'The user name should be present on the new tab.');
93 });
94
95 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