OLD | NEW |
---|---|
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(). |
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 }); | |
Dan Beam
2012/03/08 17:58:33
btw, these do work, but I was doing this rather th
Danh Nguyen
2012/03/08 18:46:14
This is the logged out test. The logged in test i
| |
57 | |
58 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() { | |
59 assertEquals( | |
60 null, document.querySelector('#login-status-header .profile-name'), | |
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 /* | |
Dan Beam
2012/03/08 17:58:33
If these are jsDoc comments, you need /** instead
Danh Nguyen
2012/03/08 18:46:14
Done.
| |
75 * Specifies C++ class for login setup. | |
76 */ | |
77 typedefCppFixture: 'NTP4LoggedInWebUITest', | |
78 | |
79 /* | |
80 * Inserts C++ statement to set up login. | |
81 */ | |
82 testGenPreamble: function() { | |
83 GEN(' SetLoginName("user@gmail.com");'); | |
84 } | |
Dan Beam
2012/03/08 17:58:33
nit: personally I prefer , at the end of object li
Danh Nguyen
2012/03/08 18:46:14
Done.
| |
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.'); | |
93 }); | |
OLD | NEW |