Index: chrome/test/data/webui/ntp4.js |
diff --git a/chrome/test/data/webui/ntp4.js b/chrome/test/data/webui/ntp4.js |
index 09fc4656b2eff3884bbb1c8548e3d83c45d2c368..91b9e5ec28992ed8a569b132b38d938006201263 100644 |
--- a/chrome/test/data/webui/ntp4.js |
+++ b/chrome/test/data/webui/ntp4.js |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+GEN('#include "chrome/test/data/webui/ntp4_browsertest.h"'); |
+ |
/** |
* TestFixture for NTP4 WebUI testing. |
* @extends {testing.Test} |
@@ -21,11 +23,71 @@ NTP4WebUITest.prototype = { |
// Test loading new tab page and selecting each card doesn't have console |
// errors. |
TEST_F('NTP4WebUITest', 'TestBrowsePages', function() { |
-// This tests the ntp4 new tab page which is not used on touch builds. |
+ // This tests the ntp4 new tab page which is not used on touch builds. |
var cardSlider = ntp.getCardSlider(); |
assertNotEquals(null, cardSlider); |
- for (var i = 0; i < cardSlider.cardCount; ++i) { |
+ for (var i = 0; i < cardSlider.cardCount; i++) { |
cardSlider.selectCard(i); |
expectEquals(i, cardSlider.currentCard); |
} |
}); |
+ |
+TEST_F('NTP4WebUITest', 'NTPHasThumbnails', function() { |
+ var mostVisited = document.querySelectorAll('.most-visited'); |
+ assertEquals(8, mostVisited.length, 'There should be 8 most visited tiles.'); |
+ |
+ var apps = document.querySelectorAll('.app'); |
+ assertGE(apps.length, 1, 'There should be at least one app.'); |
+}); |
+ |
+TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() { |
+ var navDots = document.querySelectorAll('.dot'); |
+ assertGE(navDots.length, 2, 'There should be at least two navdots.'); |
+}); |
+ |
+TEST_F('NTP4WebUITest', 'NTPHasSelectedPageAndDot', function() { |
+ var selectedDot = document.querySelectorAll('.dot.selected'); |
+ assertEquals(1, selectedDot.length, 'There should be only one selected dot.'); |
+ |
+ var selectedTilePage = document.querySelectorAll('.tile-page.selected-card'); |
+ assertEquals( |
+ 1, selectedTilePage.length, |
+ 'There should be only one selected tile page.'); |
+}); |
+ |
+TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() { |
+ assertEquals( |
+ null, document.querySelector('#login-status-header .profile-name'), |
Dan Beam
2012/03/08 19:23:18
to make the indent work here just make a var like
Danh Nguyen
2012/03/08 21:35:16
Done.
|
+ 'Login name shouldn\'t exist when signed out.'); |
+}); |
+ |
+/** |
+ * Test fixture for NTP4 WebUI testing with login. |
+ * @extends {NTP4WebUITest} |
+ * @constructor |
+ */ |
+function NTP4LoggedInWebUITest() {} |
+ |
+NTP4LoggedInWebUITest.prototype = { |
+ __proto__: NTP4WebUITest.prototype, |
+ |
+ /** |
+ * Specifies C++ class for login setup. |
Sheridan Rawlins
2012/03/08 19:10:30
nit: candidate for /** @override */
Danh Nguyen
2012/03/08 21:35:16
Done.
|
+ */ |
+ typedefCppFixture: 'NTP4LoggedInWebUITest', |
+ |
+ /** |
+ * Inserts C++ statement to set up login. |
Sheridan Rawlins
2012/03/08 19:10:30
nit: candidate for /** @override */
Danh Nguyen
2012/03/08 21:35:16
Done.
|
+ */ |
+ testGenPreamble: function() { |
+ GEN(' SetLoginName("user@gmail.com");'); |
+ }, |
+}; |
+ |
+TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() { |
+ var userName = document.querySelector('#login-status-header .profile-name'); |
+ assertTrue(userName != null); |
+ assertEquals( |
+ 'user@gmail.com', userName.textContent, |
+ 'The user name should be present on the new tab.'); |
Sheridan Rawlins
2012/03/08 19:10:30
Would this fit in 2 lines without going over the 8
Dan Beam
2012/03/08 19:23:18
try to follow scr's example everywhere in this cas
Danh Nguyen
2012/03/08 21:35:16
Done.
|
+}); |