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
3 // found in the LICENSE file.
5 GEN('#include "chrome/test/data/webui/ntp4_browsertest.h"');
8 * TestFixture for NTP4 WebUI testing.
9 * @extends {testing.Test}
12 function NTP4WebUITest() {}
14 NTP4WebUITest
.prototype = {
15 __proto__
: testing
.Test
.prototype,
18 browsePreload
: 'chrome://newtab',
21 // Test loading new tab page and selecting each card doesn't have console
23 // TODO(samarth): delete these tests along with the NTP4 code.
24 TEST_F('NTP4WebUITest', 'DISABLED_TestBrowsePages', function() {
25 // This tests the ntp4 new tab page which is not used on touch builds.
26 var cardSlider
= ntp
.getCardSlider();
27 assertNotEquals(null, cardSlider
);
28 for (var i
= 0; i
< cardSlider
.cardCount
; i
++) {
29 cardSlider
.selectCard(i
);
30 expectEquals(i
, cardSlider
.currentCard
);
34 // http://crbug.com/118944
35 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasThumbnails', function() {
36 var mostVisited
= document
.querySelectorAll('.most-visited');
37 assertEquals(8, mostVisited
.length
, 'There should be 8 most visited tiles.');
39 var apps
= document
.querySelectorAll('.app');
40 if (loadTimeData
.getBoolean('showApps'))
41 assertGE(apps
.length
, 1, 'There should be at least one app.');
43 assertEquals(0, apps
.length
, 'There should be no apps.');
46 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasNavDots', function() {
47 var navDots
= document
.querySelectorAll('.dot');
48 if (loadTimeData
.getBoolean('showApps'))
49 assertGE(navDots
.length
, 2, 'There should be at least two navdots.');
51 assertEquals(1, navDots
.length
, 'There should be exactly one navdot.');
54 // http://crbug.com/118514
55 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasSelectedPageAndDot', function() {
56 var selectedDot
= document
.querySelectorAll('.dot.selected');
57 assertEquals(1, selectedDot
.length
,
58 'There should be exactly one selected dot.');
60 var selectedTilePage
= document
.querySelectorAll('.tile-page.selected-card');
61 assertEquals(1, selectedTilePage
.length
,
62 'There should be exactly one selected tile page.');
65 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasNoLoginNameWhenSignedOut', function() {
66 var userName
= document
.querySelector('#login-status-header .profile-name');
67 assertEquals(null, userName
, 'Login name shouldn\'t exist when signed out.');
71 * Test fixture for NTP4 WebUI testing with login.
72 * @extends {NTP4WebUITest}
75 function NTP4LoggedInWebUITest() {}
77 NTP4LoggedInWebUITest
.prototype = {
78 __proto__
: NTP4WebUITest
.prototype,
81 typedefCppFixture
: 'NTP4LoggedInWebUITest',
84 testGenPreamble: function() {
85 GEN(' SetLoginName("user@gmail.com");');
89 // The following test is irrelevant to Chrome on Chrome OS.
90 GEN('#if !defined(OS_CHROMEOS)');
92 TEST_F('NTP4LoggedInWebUITest', 'DISABLED_NTPHasLoginNameWhenSignedIn',
94 var userName
= document
.querySelector('#login-status-header .profile-name');
95 assertNotEquals(userName
, null, 'The logged-in user name can\'t be found.');
96 assertEquals('user@gmail.com', userName
.textContent
,
97 'The user name should be present on the new tab.');