| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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"'); | 5 GEN('#include "chrome/test/data/webui/ntp4_browsertest.h"'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * TestFixture for NTP4 WebUI testing. | 8 * TestFixture for NTP4 WebUI testing. |
| 9 * @extends {testing.Test} | 9 * @extends {testing.Test} |
| 10 * @constructor | 10 * @constructor |
| 11 */ | 11 */ |
| 12 function NTP4WebUITest() {} | 12 function NTP4WebUITest() {} |
| 13 | 13 |
| 14 NTP4WebUITest.prototype = { | 14 NTP4WebUITest.prototype = { |
| 15 __proto__: testing.Test.prototype, | 15 __proto__: testing.Test.prototype, |
| 16 | 16 |
| 17 /** @override */ | 17 /** @override */ |
| 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 // TODO(samarth): delete these tests along with the NTP4 code. |
| 24 TEST_F('NTP4WebUITest', 'DISABLED_TestBrowsePages', function() { |
| 24 // This tests the ntp4 new tab page which is not used on touch builds. | 25 // This tests the ntp4 new tab page which is not used on touch builds. |
| 25 var cardSlider = ntp.getCardSlider(); | 26 var cardSlider = ntp.getCardSlider(); |
| 26 assertNotEquals(null, cardSlider); | 27 assertNotEquals(null, cardSlider); |
| 27 for (var i = 0; i < cardSlider.cardCount; i++) { | 28 for (var i = 0; i < cardSlider.cardCount; i++) { |
| 28 cardSlider.selectCard(i); | 29 cardSlider.selectCard(i); |
| 29 expectEquals(i, cardSlider.currentCard); | 30 expectEquals(i, cardSlider.currentCard); |
| 30 } | 31 } |
| 31 }); | 32 }); |
| 32 | 33 |
| 33 // http://crbug.com/118944 | 34 // http://crbug.com/118944 |
| 34 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasThumbnails', function() { | 35 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasThumbnails', function() { |
| 35 var mostVisited = document.querySelectorAll('.most-visited'); | 36 var mostVisited = document.querySelectorAll('.most-visited'); |
| 36 assertEquals(8, mostVisited.length, 'There should be 8 most visited tiles.'); | 37 assertEquals(8, mostVisited.length, 'There should be 8 most visited tiles.'); |
| 37 | 38 |
| 38 var apps = document.querySelectorAll('.app'); | 39 var apps = document.querySelectorAll('.app'); |
| 39 if (loadTimeData.getBoolean('showApps')) | 40 if (loadTimeData.getBoolean('showApps')) |
| 40 assertGE(apps.length, 1, 'There should be at least one app.'); | 41 assertGE(apps.length, 1, 'There should be at least one app.'); |
| 41 else | 42 else |
| 42 assertEquals(0, apps.length, 'There should be no apps.'); | 43 assertEquals(0, apps.length, 'There should be no apps.'); |
| 43 }); | 44 }); |
| 44 | 45 |
| 45 TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() { | 46 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasNavDots', function() { |
| 46 var navDots = document.querySelectorAll('.dot'); | 47 var navDots = document.querySelectorAll('.dot'); |
| 47 if (loadTimeData.getBoolean('showApps')) | 48 if (loadTimeData.getBoolean('showApps')) |
| 48 assertGE(navDots.length, 2, 'There should be at least two navdots.'); | 49 assertGE(navDots.length, 2, 'There should be at least two navdots.'); |
| 49 else | 50 else |
| 50 assertEquals(1, navDots.length, 'There should be exactly one navdot.'); | 51 assertEquals(1, navDots.length, 'There should be exactly one navdot.'); |
| 51 }); | 52 }); |
| 52 | 53 |
| 53 // http://crbug.com/118514 | 54 // http://crbug.com/118514 |
| 54 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasSelectedPageAndDot', function() { | 55 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasSelectedPageAndDot', function() { |
| 55 var selectedDot = document.querySelectorAll('.dot.selected'); | 56 var selectedDot = document.querySelectorAll('.dot.selected'); |
| 56 assertEquals(1, selectedDot.length, | 57 assertEquals(1, selectedDot.length, |
| 57 'There should be exactly one selected dot.'); | 58 'There should be exactly one selected dot.'); |
| 58 | 59 |
| 59 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card'); | 60 var selectedTilePage = document.querySelectorAll('.tile-page.selected-card'); |
| 60 assertEquals(1, selectedTilePage.length, | 61 assertEquals(1, selectedTilePage.length, |
| 61 'There should be exactly one selected tile page.'); | 62 'There should be exactly one selected tile page.'); |
| 62 }); | 63 }); |
| 63 | 64 |
| 64 TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() { | 65 TEST_F('NTP4WebUITest', 'DISABLED_NTPHasNoLoginNameWhenSignedOut', function() { |
| 65 var userName = document.querySelector('#login-status-header .profile-name'); | 66 var userName = document.querySelector('#login-status-header .profile-name'); |
| 66 assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.'); | 67 assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.'); |
| 67 }); | 68 }); |
| 68 | 69 |
| 69 /** | 70 /** |
| 70 * Test fixture for NTP4 WebUI testing with login. | 71 * Test fixture for NTP4 WebUI testing with login. |
| 71 * @extends {NTP4WebUITest} | 72 * @extends {NTP4WebUITest} |
| 72 * @constructor | 73 * @constructor |
| 73 */ | 74 */ |
| 74 function NTP4LoggedInWebUITest() {} | 75 function NTP4LoggedInWebUITest() {} |
| 75 | 76 |
| 76 NTP4LoggedInWebUITest.prototype = { | 77 NTP4LoggedInWebUITest.prototype = { |
| 77 __proto__: NTP4WebUITest.prototype, | 78 __proto__: NTP4WebUITest.prototype, |
| 78 | 79 |
| 79 /** @override */ | 80 /** @override */ |
| 80 typedefCppFixture: 'NTP4LoggedInWebUITest', | 81 typedefCppFixture: 'NTP4LoggedInWebUITest', |
| 81 | 82 |
| 82 /** @override */ | 83 /** @override */ |
| 83 testGenPreamble: function() { | 84 testGenPreamble: function() { |
| 84 GEN(' SetLoginName("user@gmail.com");'); | 85 GEN(' SetLoginName("user@gmail.com");'); |
| 85 }, | 86 }, |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 // The following test is irrelevant to Chrome on Chrome OS. | 89 // The following test is irrelevant to Chrome on Chrome OS. |
| 89 GEN('#if !defined(OS_CHROMEOS)'); | 90 GEN('#if !defined(OS_CHROMEOS)'); |
| 90 | 91 |
| 91 TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() { | 92 TEST_F('NTP4LoggedInWebUITest', 'DISABLED_NTPHasLoginNameWhenSignedIn', |
| 93 function() { |
| 92 var userName = document.querySelector('#login-status-header .profile-name'); | 94 var userName = document.querySelector('#login-status-header .profile-name'); |
| 93 assertNotEquals(userName, null, 'The logged-in user name can\'t be found.'); | 95 assertNotEquals(userName, null, 'The logged-in user name can\'t be found.'); |
| 94 assertEquals('user@gmail.com', userName.textContent, | 96 assertEquals('user@gmail.com', userName.textContent, |
| 95 'The user name should be present on the new tab.'); | 97 'The user name should be present on the new tab.'); |
| 96 }); | 98 }); |
| 97 | 99 |
| 98 GEN('#endif'); | 100 GEN('#endif'); |
| OLD | NEW |