| 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 #include "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" |
| 7 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/prefs/pref_value_store.h" | |
| 10 #include "chrome/browser/signin/signin_manager.h" | |
| 11 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 10 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 12 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/json_pref_store.h" | |
| 14 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/test/automation/automation_proxy.h" | 14 #include "chrome/test/automation/automation_proxy.h" |
| 17 #include "chrome/test/automation/browser_proxy.h" | 15 #include "chrome/test/automation/browser_proxy.h" |
| 18 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 19 #include "chrome/test/automation/window_proxy.h" | 17 #include "googleurl/src/gurl.h" |
| 20 #include "chrome/test/base/testing_pref_service.h" | |
| 21 | 18 |
| 22 class NewTabUITest : public UITest { | 19 class NewTabUITest : public UITest { |
| 23 public: | 20 public: |
| 24 NewTabUITest() { | 21 NewTabUITest() { |
| 25 dom_automation_enabled_ = true; | 22 dom_automation_enabled_ = true; |
| 26 // Set home page to the empty string so that we can set the home page using | |
| 27 // preferences. | |
| 28 set_homepage(""); | |
| 29 | |
| 30 // Setup the DEFAULT_THEME profile (has fake history entries). | 23 // Setup the DEFAULT_THEME profile (has fake history entries). |
| 31 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 24 set_template_user_data(UITest::ComputeTypicalUserDataSource( |
| 32 UITestBase::DEFAULT_THEME)); | 25 UITestBase::DEFAULT_THEME)); |
| 33 } | 26 } |
| 34 }; | 27 }; |
| 35 | 28 |
| 36 #if defined(OS_WIN) | 29 // Bug 87200: Disable ChromeHangInNTP for Windows and ChromeOS |
| 37 // Bug 87200: Disable NTPHasThumbnails for Windows | 30 #if defined(OS_WIN) || defined(OS_CHROMEOS) |
| 38 #define MAYBE_NTPHasThumbnails DISABLED_NTPHasThumbnails | |
| 39 #elif defined(OS_LINUX) | |
| 40 // This test is flaky on Linux and CrOS: http://crbug/30367 | |
| 41 #define MAYBE_NTPHasThumbnails DISABLED_NTPHasThumbnails | |
| 42 #elif defined(OS_MACOSX) | |
| 43 // Acting flaky on Mac: http://crbug.com/87200 | |
| 44 #define MAYBE_NTPHasThumbnails DISABLED_NTPHasThumbnails | |
| 45 #else | |
| 46 #define MAYBE_NTPHasThumbnails NTPHasThumbnails | |
| 47 #endif | |
| 48 TEST_F(NewTabUITest, MAYBE_NTPHasThumbnails) { | |
| 49 // Switch to the "new tab" tab, which should be any new tab after the | |
| 50 // first (the first is about:blank). | |
| 51 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | |
| 52 ASSERT_TRUE(window.get()); | |
| 53 | |
| 54 // Bring up a new tab page. | |
| 55 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); | |
| 56 | |
| 57 scoped_refptr<TabProxy> tab = window->GetActiveTab(); | |
| 58 ASSERT_TRUE(tab.get()); | |
| 59 | |
| 60 // TopSites should return at least 3 non-filler pages. | |
| 61 // 8 - 3 = max 5 filler pages. | |
| 62 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", | |
| 63 L"window.domAutomationController.send(" | |
| 64 L"document.getElementsByClassName('filler').length <= 5)", | |
| 65 TestTimeouts::action_max_timeout_ms())); | |
| 66 } | |
| 67 | |
| 68 // Sometimes hangs: http://crbug.com/70157 | |
| 69 TEST_F(NewTabUITest, DISABLED_NTPHasLoginName) { | |
| 70 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | |
| 71 ASSERT_TRUE(window.get()); | |
| 72 | |
| 73 ASSERT_TRUE(window->SetStringPreference(prefs::kGoogleServicesUsername, | |
| 74 "user@gmail.com")); | |
| 75 // Bring up a new tab page. | |
| 76 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); | |
| 77 | |
| 78 scoped_refptr<TabProxy> tab = window->GetActiveTab(); | |
| 79 ASSERT_TRUE(tab.get()); | |
| 80 | |
| 81 std::wstring displayed_username; | |
| 82 // The login span should be eventually populated and have the | |
| 83 // correct value. | |
| 84 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", | |
| 85 L"window.domAutomationController.send(" | |
| 86 L"document.getElementById('login-username').innerText.length > 0)", | |
| 87 TestTimeouts::action_max_timeout_ms())); | |
| 88 | |
| 89 ASSERT_TRUE(tab->ExecuteAndExtractString( | |
| 90 L"", | |
| 91 L"window.domAutomationController.send(" | |
| 92 L"document.getElementById('login-username').innerText)", | |
| 93 &displayed_username)); | |
| 94 | |
| 95 EXPECT_EQ(L"user@gmail.com", displayed_username); | |
| 96 } | |
| 97 | |
| 98 // Bug 87200: Disable ChromeHangInNTP for Windows | |
| 99 #if defined(OS_WIN) | |
| 100 #define MAYBE_ChromeHangInNTP DISABLED_ChromeHangInNTP | |
| 101 #elif defined(OS_CHROMEOS) | |
| 102 #define MAYBE_ChromeHangInNTP DISABLED_ChromeHangInNTP | 31 #define MAYBE_ChromeHangInNTP DISABLED_ChromeHangInNTP |
| 103 #elif defined(OS_MACOSX) | 32 #elif defined(OS_MACOSX) |
| 104 // Acting flaky on Mac: http://crbug.com/87200 | 33 // Acting flaky on Mac: http://crbug.com/87200 |
| 105 #define MAYBE_ChromeHangInNTP DISABLED_ChromeHangInNTP | 34 #define MAYBE_ChromeHangInNTP DISABLED_ChromeHangInNTP |
| 106 #else | 35 #else |
| 107 #define MAYBE_ChromeHangInNTP ChromeHangInNTP | 36 #define MAYBE_ChromeHangInNTP ChromeHangInNTP |
| 108 #endif | 37 #endif |
| 109 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. | 38 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. |
| 110 // See http://crbug.com/59859. | 39 // See http://crbug.com/59859. |
| 111 TEST_F(NewTabUITest, MAYBE_ChromeHangInNTP) { | 40 TEST_F(NewTabUITest, MAYBE_ChromeHangInNTP) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 92 |
| 164 // Navigate to chrome://hang/ to stall the process. | 93 // Navigate to chrome://hang/ to stall the process. |
| 165 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); | 94 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); |
| 166 | 95 |
| 167 // Visit a normal URL in another NTP that hasn't committed. | 96 // Visit a normal URL in another NTP that hasn't committed. |
| 168 ASSERT_TRUE(window->RunCommandAsync(IDC_NEW_TAB)); | 97 ASSERT_TRUE(window->RunCommandAsync(IDC_NEW_TAB)); |
| 169 scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); | 98 scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); |
| 170 ASSERT_TRUE(tab2.get()); | 99 ASSERT_TRUE(tab2.get()); |
| 171 ASSERT_TRUE(tab2->NavigateToURL(GURL("data:text/html,hello world"))); | 100 ASSERT_TRUE(tab2->NavigateToURL(GURL("data:text/html,hello world"))); |
| 172 } | 101 } |
| OLD | NEW |