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

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: More updates per review comments. 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 /**
16 * Browse to the newtab page & call preLoad(). 18 * Browse to the newtab page & call preLoad().
Sheridan Rawlins 2012/03/08 19:10:30 /** @override */ would say it all and be easier to
Danh Nguyen 2012/03/08 21:35:16 Done.
17 */ 19 */
18 browsePreload: 'chrome://newtab', 20 browsePreload: 'chrome://newtab',
19 }; 21 };
20 22
21 // Test loading new tab page and selecting each card doesn't have console 23 // Test loading new tab page and selecting each card doesn't have console
22 // errors. 24 // errors.
23 TEST_F('NTP4WebUITest', 'TestBrowsePages', function() { 25 TEST_F('NTP4WebUITest', 'TestBrowsePages', function() {
24 // This tests the ntp4 new tab page which is not used on touch builds. 26 // This tests the ntp4 new tab page which is not used on touch builds.
25 var cardSlider = ntp.getCardSlider(); 27 var cardSlider = ntp.getCardSlider();
26 assertNotEquals(null, cardSlider); 28 assertNotEquals(null, cardSlider);
27 for (var i = 0; i < cardSlider.cardCount; ++i) { 29 for (var i = 0; i < cardSlider.cardCount; i++) {
28 cardSlider.selectCard(i); 30 cardSlider.selectCard(i);
29 expectEquals(i, cardSlider.currentCard); 31 expectEquals(i, cardSlider.currentCard);
30 } 32 }
31 }); 33 });
34
35 TEST_F('NTP4WebUITest', 'NTPHasThumbnails', function() {
36 var mostVisited = document.querySelectorAll('.most-visited');
37 assertEquals(8, mostVisited.length, 'There should be 8 most visited tiles.');
38
39 var apps = document.querySelectorAll('.app');
40 assertGE(apps.length, 1, 'There should be at least one app.');
41 });
42
43 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() {
44 var navDots = document.querySelectorAll('.dot');
45 assertGE(navDots.length, 2, 'There should be at least two navdots.');
46 });
47
48 TEST_F('NTP4WebUITest', 'NTPHasSelectedPageAndDot', function() {
49 var selectedDot = document.querySelectorAll('.dot.selected');
50 assertEquals(1, selectedDot.length, 'There should be only one selected dot.');
51
52 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card');
53 assertEquals(
54 1, selectedTilePage.length,
55 'There should be only one selected tile page.');
56 });
57
58 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() {
59 assertEquals(
60 null, document.querySelector('#login-status-header .profile-name'),
Dan Beam 2012/03/08 19:23:18 to make the indent work here just make a var like
Danh Nguyen 2012/03/08 21:35:16 Done.
61 '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 /**
75 * Specifies C++ class for login setup.
Sheridan Rawlins 2012/03/08 19:10:30 nit: candidate for /** @override */
Danh Nguyen 2012/03/08 21:35:16 Done.
76 */
77 typedefCppFixture: 'NTP4LoggedInWebUITest',
78
79 /**
80 * Inserts C++ statement to set up login.
Sheridan Rawlins 2012/03/08 19:10:30 nit: candidate for /** @override */
Danh Nguyen 2012/03/08 21:35:16 Done.
81 */
82 testGenPreamble: function() {
83 GEN(' SetLoginName("user@gmail.com");');
84 },
85 };
86
87 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() {
88 var userName = document.querySelector('#login-status-header .profile-name');
89 assertTrue(userName != null);
90 assertEquals(
91 'user@gmail.com', userName.textContent,
92 'The user name should be present on the new tab.');
Sheridan Rawlins 2012/03/08 19:10:30 Would this fit in 2 lines without going over the 8
Dan Beam 2012/03/08 19:23:18 try to follow scr's example everywhere in this cas
Danh Nguyen 2012/03/08 21:35:16 Done.
93 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698