Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6735)

Unified Diff: chrome/test/data/webui/ntp4.js

Issue 9625020: Ported NTP4 UI tests to WebUI. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Missed changes to the .gypi file when renaming test files. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..066933d41f8ce0717f5595567a5c71f44f27b95a 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.');
+});
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
+
+TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() {
+ assertEquals(
+ null, document.querySelector('#login-status-header .profile-name'),
+ '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,
+
+ /*
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.
+ * Specifies C++ class for login setup.
+ */
+ typedefCppFixture: 'NTP4LoggedInWebUITest',
+
+ /*
+ * Inserts C++ statement to set up login.
+ */
+ testGenPreamble: function() {
+ GEN(' SetLoginName("user@gmail.com");');
+ }
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.
+};
+
+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.');
+});

Powered by Google App Engine
This is Rietveld 408576698