OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
Dan Beam
2012/03/15 00:12:55
nit: we don't use 2 spaces, only 1 between sentenc
| |
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) { | |
Dan Beam
2012/03/15 00:12:55
nit: no curlies when both conditional and body of
Danh Nguyen
2012/03/15 15:42:09
Done.
| |
39 assertGE(apps.length, 1, 'There should be at least one app.'); | |
40 } | |
41 else { | |
Dan Beam
2012/03/15 00:12:55
nit: if you do need curlies, we "cuddle" them, i.e
Danh Nguyen
2012/03/15 15:42:09
Done.
| |
42 assertGE(apps.length, 0, 'There should be no app.'); | |
Dan Beam
2012/03/15 00:12:55
nit: no apps.
Danh Nguyen
2012/03/15 15:42:09
Done.
| |
43 } | |
44 }); | |
45 | |
46 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() { | |
47 var navDots = document.querySelectorAll('.dot'); | |
48 if (window.templateData.showApps) { | |
49 assertGE(navDots.length, 2, 'There should be at least two navdots.'); | |
50 } | |
51 else { | |
52 assertGE(navDots.length, 0, 'There should be no navdot.'); | |
Dan Beam
2012/03/15 00:12:55
nit: no navdots.
Dan Beam
2012/03/15 00:13:27
whoops, sorry, this should be assertEquals()
Danh Nguyen
2012/03/15 15:42:09
Fixed.
Danh Nguyen
2012/03/15 15:42:09
Actually on ChromeOS in the browser tests' setting
| |
53 } | |
54 }); | |
55 | |
56 TEST_F('NTP4WebUITest', 'NTPHasSelectedPageAndDot', function() { | |
Dan Beam
2012/03/15 00:15:25
and this should also be wrapped with showApps as n
Danh Nguyen
2012/03/15 15:42:09
On ChromeOS there is only one navdot and it's sele
| |
57 var selectedDot = document.querySelectorAll('.dot.selected'); | |
58 assertEquals(1, selectedDot.length, 'There should be only one selected dot.'); | |
59 | |
60 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card'); | |
61 assertEquals(1, selectedTilePage.length, | |
62 'There should be only one selected tile page.'); | |
63 }); | |
64 | |
65 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() { | |
66 var userName = document.querySelector('#login-status-header .profile-name'); | |
67 assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.'); | |
68 }); | |
69 | |
70 /** | |
71 * Test fixture for NTP4 WebUI testing with login. | |
72 * @extends {NTP4WebUITest} | |
73 * @constructor | |
74 */ | |
75 function NTP4LoggedInWebUITest() {} | |
76 | |
77 NTP4LoggedInWebUITest.prototype = { | |
78 __proto__: NTP4WebUITest.prototype, | |
79 | |
80 /** @override */ | |
81 typedefCppFixture: 'NTP4LoggedInWebUITest', | |
82 | |
83 /** @override */ | |
84 testGenPreamble: function() { | |
85 GEN(' SetLoginName("user@gmail.com");'); | |
86 }, | |
87 }; | |
88 | |
89 // The following test is irrelevant to Chrome on Chrome OS. | |
90 GEN('#if !defined(OS_CHROMEOS)'); | |
91 | |
92 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() { | |
93 var userName = document.querySelector('#login-status-header .profile-name'); | |
94 assertNotEquals(userName, null, 'The logged-in user name can\'t be found.'); | |
95 assertEquals('user@gmail.com', userName.textContent, | |
96 'The user name should be present on the new tab.'); | |
97 }); | |
98 | |
99 GEN('#endif'); | |
OLD | NEW |