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 /** | 5 /** |
6 * TestFixture for NTP4 WebUI testing. | 6 * TestFixture for NTP4 WebUI testing. |
7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function NTP4WebUITest() {} | 10 function NTP4WebUITest() {} |
11 | 11 |
12 NTP4WebUITest.prototype = { | 12 NTP4WebUITest.prototype = { |
13 __proto__: testing.Test.prototype, | 13 __proto__: testing.Test.prototype, |
14 | 14 |
15 /** | 15 /** |
16 * Browse to the newtab page & call preLoad(). | 16 * Browse to the newtab page & call preLoad(). |
17 */ | 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. |
Sheridan Rawlins
2012/03/07 22:25:36
spacing seems off - should be 2 spaces; see javasc
Danh Nguyen
2012/03/08 16:44:19
I'm not sure how that happened. I must have messe
| |
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) { |
Sheridan Rawlins
2012/03/07 22:25:36
arv@chromium.org prefers i++ in JavaScript.
Dan Beam
2012/03/07 22:49:45
Then why'd you write it this way, scr@? :P http://
Danh Nguyen
2012/03/08 16:44:19
Easy fix. :-) Done.
| |
28 cardSlider.selectCard(i); | 28 cardSlider.selectCard(i); |
29 expectEquals(i, cardSlider.currentCard); | 29 expectEquals(i, cardSlider.currentCard); |
30 } | |
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 assertGE(apps.length, 1, 'There should be at least one app.'); | |
39 }); | |
40 | |
41 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() { | |
42 var navDots = document.querySelectorAll('.dot'); | |
43 assertGE(navDots.length, 2, 'There should be at least two navdots.'); | |
44 }); | |
45 | |
46 TEST_F('NTP4WebUITest', 'NTPHasSelectedPageAndDot', function() { | |
47 var selectedDot = document.querySelectorAll('.dot.selected'); | |
48 assertEquals(1, selectedDot.length, 'There should be only one selected dot.'); | |
49 | |
50 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card'); | |
51 assertEquals(1, selectedTilePage.length, | |
52 'There should be only one selected tile page.'); | |
Sheridan Rawlins
2012/03/07 22:25:36
alignment is off.
Dan Beam
2012/03/07 22:49:45
scr: you might want to explain how it's off
Sheridan Rawlins
2012/03/07 23:00:38
Sho 'nuff.
Please either start a new line after t
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
53 }); | |
54 | |
55 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() { | |
56 assertEquals(null, | |
Sheridan Rawlins
2012/03/07 22:25:36
alignment is off - either move null down or indent
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
57 document.querySelector('#login-status-header .profile-name'), | |
58 'Login name shouldn\'t exist when signed out.'); | |
59 }); | |
60 | |
61 /** | |
62 * Test fixture for NTP4 WebUI testing with login. | |
Sheridan Rawlins
2012/03/07 22:25:36
@extends {NTP4WebUITest}
@constructor
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
63 */ | |
64 function NTP4LoggedInWebUITest() {} | |
65 | |
66 NTP4LoggedInWebUITest.prototype = { | |
67 __proto__: NTP4WebUITest.prototype, | |
68 | |
69 // C++ class for login setup. | |
Sheridan Rawlins
2012/03/07 22:25:36
JSDoc style comments for members/methods please.
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
70 typedefCppFixture: 'NTP4LoggedInWebUITest', | |
71 | |
72 // Inserts C++ statement to set up login. | |
Sheridan Rawlins
2012/03/07 22:25:36
JSDoc style comments.
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
73 testGenPreamble: function() { | |
74 print(' SetLoginName("user@gmail.com");'); | |
Sheridan Rawlins
2012/03/07 22:25:36
Please use GEN - print is v8, but node.js uses con
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
30 } | 75 } |
76 }; | |
77 | |
78 GEN('#include "chrome/test/data/webui/ntp4_test.h"'); | |
Sheridan Rawlins
2012/03/07 22:25:36
Move to the top please so it is closer to the desi
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
79 | |
80 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() { | |
81 userName = document.querySelector('#login-status-header .profile-name'); | |
Sheridan Rawlins
2012/03/07 22:25:36
var
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
82 assertTrue(userName != null); | |
83 assertEquals('user@gmail.com', userName.firstChild.wholeText, | |
Dan Beam
2012/03/07 22:49:45
what's wholeText? I've only ever heard of innerTex
Danh Nguyen
2012/03/08 16:44:19
https://developer.mozilla.org/en/DOM/Text.wholeTex
| |
84 'The user name should be present on the new tab.'); | |
Sheridan Rawlins
2012/03/07 22:25:36
alignment is off.
Sheridan Rawlins
2012/03/07 23:00:38
(See previous alignment comments for style suggest
Danh Nguyen
2012/03/08 16:44:19
Done.
Danh Nguyen
2012/03/08 16:44:19
Done.
Danh Nguyen
2012/03/08 16:44:19
Done.
| |
31 }); | 85 }); |
OLD | NEW |