| OLD | NEW |
| 1 // Copyright (c) 2010 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 #include "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
| 6 | 6 |
| 7 #include "base/test/test_timeouts.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/dom_ui/new_tab_ui.h" | 9 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 9 #include "chrome/browser/prefs/pref_value_store.h" | 10 #include "chrome/browser/prefs/pref_value_store.h" |
| 10 #include "chrome/browser/sync/signin_manager.h" | 11 #include "chrome/browser/sync/signin_manager.h" |
| 11 #include "chrome/common/json_pref_store.h" | 12 #include "chrome/common/json_pref_store.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/automation/browser_proxy.h" | 15 #include "chrome/test/automation/browser_proxy.h" |
| 15 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 16 #include "chrome/test/automation/window_proxy.h" | 17 #include "chrome/test/automation/window_proxy.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 42 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); | 43 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
| 43 | 44 |
| 44 scoped_refptr<TabProxy> tab = window->GetActiveTab(); | 45 scoped_refptr<TabProxy> tab = window->GetActiveTab(); |
| 45 ASSERT_TRUE(tab.get()); | 46 ASSERT_TRUE(tab.get()); |
| 46 | 47 |
| 47 // TopSites should return at least 3 non-filler pages. | 48 // TopSites should return at least 3 non-filler pages. |
| 48 // 8 - 3 = max 5 filler pages. | 49 // 8 - 3 = max 5 filler pages. |
| 49 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", | 50 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", |
| 50 L"window.domAutomationController.send(" | 51 L"window.domAutomationController.send(" |
| 51 L"document.getElementsByClassName('filler').length <= 5)", | 52 L"document.getElementsByClassName('filler').length <= 5)", |
| 52 action_max_timeout_ms())); | 53 TestTimeouts::action_max_timeout_ms())); |
| 53 } | 54 } |
| 54 | 55 |
| 55 TEST_F(NewTabUITest, NTPHasLoginName) { | 56 TEST_F(NewTabUITest, NTPHasLoginName) { |
| 56 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 57 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 57 ASSERT_TRUE(window.get()); | 58 ASSERT_TRUE(window.get()); |
| 58 | 59 |
| 59 ASSERT_TRUE(window->SetStringPreference(prefs::kGoogleServicesUsername, | 60 ASSERT_TRUE(window->SetStringPreference(prefs::kGoogleServicesUsername, |
| 60 "user@gmail.com")); | 61 "user@gmail.com")); |
| 61 // Bring up a new tab page. | 62 // Bring up a new tab page. |
| 62 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); | 63 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
| 63 int load_time; | 64 int load_time; |
| 64 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); | 65 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
| 65 | 66 |
| 66 scoped_refptr<TabProxy> tab = window->GetActiveTab(); | 67 scoped_refptr<TabProxy> tab = window->GetActiveTab(); |
| 67 ASSERT_TRUE(tab.get()); | 68 ASSERT_TRUE(tab.get()); |
| 68 | 69 |
| 69 std::wstring displayed_username; | 70 std::wstring displayed_username; |
| 70 // The login span should be eventually populated and have the | 71 // The login span should be eventually populated and have the |
| 71 // correct value. | 72 // correct value. |
| 72 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", | 73 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", |
| 73 L"window.domAutomationController.send(" | 74 L"window.domAutomationController.send(" |
| 74 L"document.getElementById('login-username').innerText.length > 0)", | 75 L"document.getElementById('login-username').innerText.length > 0)", |
| 75 action_max_timeout_ms())); | 76 TestTimeouts::action_max_timeout_ms())); |
| 76 | 77 |
| 77 ASSERT_TRUE(tab->ExecuteAndExtractString( | 78 ASSERT_TRUE(tab->ExecuteAndExtractString( |
| 78 L"", | 79 L"", |
| 79 L"window.domAutomationController.send(" | 80 L"window.domAutomationController.send(" |
| 80 L"document.getElementById('login-username').innerText)", | 81 L"document.getElementById('login-username').innerText)", |
| 81 &displayed_username)); | 82 &displayed_username)); |
| 82 | 83 |
| 83 EXPECT_EQ(L"user@gmail.com", displayed_username); | 84 EXPECT_EQ(L"user@gmail.com", displayed_username); |
| 84 } | 85 } |
| 85 | 86 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); | 145 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); |
| 145 | 146 |
| 146 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); | 147 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
| 147 ASSERT_TRUE(migrated); | 148 ASSERT_TRUE(migrated); |
| 148 ASSERT_EQ(NewTabUI::current_pref_version(), | 149 ASSERT_EQ(NewTabUI::current_pref_version(), |
| 149 prefs->GetInteger(prefs::kNTPPrefVersion)); | 150 prefs->GetInteger(prefs::kNTPPrefVersion)); |
| 150 | 151 |
| 151 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); | 152 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
| 152 ASSERT_FALSE(migrated); | 153 ASSERT_FALSE(migrated); |
| 153 } | 154 } |
| OLD | NEW |