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 TEST_F('NTP4WebUITest', 'TestBrowsePages', function() {
24 // This tests the ntp4 new tab page which is not used on touch builds.
25 var cardSlider = ntp.getCardSlider();
26 assertNotEquals(null, cardSlider);
27 for (var i = 0; i < cardSlider.cardCount; i++) {
28 cardSlider.selectCard(i);
29 expectEquals(i, cardSlider.currentCard);
33 // http://crbug.com/118944
34 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasThumbnails', function() {
35 var mostVisited = document.querySelectorAll('.most-visited');
36 assertEquals(8, mostVisited.length, 'There should be 8 most visited tiles.');
38 var apps = document.querySelectorAll('.app');
39 if (loadTimeData.getBoolean('showApps'))
40 assertGE(apps.length, 1, 'There should be at least one app.');
42 assertEquals(0, apps.length, 'There should be no apps.');
45 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() {
46 var navDots = document.querySelectorAll('.dot');
47 if (loadTimeData.getBoolean('showApps'))
48 assertGE(navDots.length, 2, 'There should be at least two navdots.');
50 assertEquals(1, navDots.length, 'There should be exactly one navdot.');
53 // http://crbug.com/118514
54 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasSelectedPageAndDot', function() {
55 var selectedDot = document.querySelectorAll('.dot.selected');
56 assertEquals(1, selectedDot.length,
57 'There should be exactly one selected dot.');
59 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card');
60 assertEquals(1, selectedTilePage.length,
61 'There should be exactly one selected tile page.');
64 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() {
65 var userName = document.querySelector('#login-status-header .profile-name');
66 assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.');
70 * Test fixture for NTP4 WebUI testing with login.
71 * @extends {NTP4WebUITest}
74 function NTP4LoggedInWebUITest() {}
76 NTP4LoggedInWebUITest.prototype = {
77 __proto__: NTP4WebUITest.prototype,
80 typedefCppFixture: 'NTP4LoggedInWebUITest',
83 testGenPreamble: function() {
84 GEN(' SetLoginName("user@gmail.com");');
88 // The following test is irrelevant to Chrome on Chrome OS.
89 GEN('#if !defined(OS_CHROMEOS)');
91 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() {
92 var userName = document.querySelector('#login-status-header .profile-name');
93 assertNotEquals(userName, null, 'The logged-in user name can\'t be found.');
94 assertEquals('user@gmail.com', userName.textContent,
95 'The user name should be present on the new tab.');