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

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui_uitest.cc

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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 "base/test/test_timeouts.h"
8 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/dom_ui/new_tab_ui.h" 10 #include "chrome/browser/dom_ui/new_tab_ui.h"
10 #include "chrome/browser/prefs/pref_value_store.h" 11 #include "chrome/browser/prefs/pref_value_store.h"
11 #include "chrome/browser/sync/signin_manager.h" 12 #include "chrome/browser/sync/signin_manager.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/json_pref_store.h" 14 #include "chrome/common/json_pref_store.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/test/automation/browser_proxy.h" 17 #include "chrome/test/automation/browser_proxy.h"
17 #include "chrome/test/automation/tab_proxy.h" 18 #include "chrome/test/automation/tab_proxy.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ASSERT_TRUE(window.get()); 59 ASSERT_TRUE(window.get());
59 60
60 ASSERT_TRUE(window->SetStringPreference(prefs::kGoogleServicesUsername, 61 ASSERT_TRUE(window->SetStringPreference(prefs::kGoogleServicesUsername,
61 "user@gmail.com")); 62 "user@gmail.com"));
62 // Bring up a new tab page. 63 // Bring up a new tab page.
63 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); 64 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB));
64 65
65 scoped_refptr<TabProxy> tab = window->GetActiveTab(); 66 scoped_refptr<TabProxy> tab = window->GetActiveTab();
66 ASSERT_TRUE(tab.get()); 67 ASSERT_TRUE(tab.get());
67 68
68 std::wstring displayed_username;
69 // The login span should be eventually populated and have the 69 // The login span should be eventually populated and have the
70 // correct value. 70 // correct value.
71 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", 71 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"",
72 L"window.domAutomationController.send(" 72 L"window.domAutomationController.send("
73 L"document.getElementById('login-username').innerText.length > 0)", 73 L"document.getElementById('login-username').innerText.length > 0)",
74 TestTimeouts::action_max_timeout_ms())); 74 TestTimeouts::action_max_timeout_ms()));
75 75
76 string16 displayed_username;
76 ASSERT_TRUE(tab->ExecuteAndExtractString( 77 ASSERT_TRUE(tab->ExecuteAndExtractString(
77 L"", 78 string16(),
78 L"window.domAutomationController.send(" 79 ASCIIToUTF16("window.domAutomationController.send("
79 L"document.getElementById('login-username').innerText)", 80 "document.getElementById('login-username').innerText)"),
80 &displayed_username)); 81 &displayed_username));
81 82
82 EXPECT_EQ(L"user@gmail.com", displayed_username); 83 EXPECT_EQ(ASCIIToUTF16("user@gmail.com"), displayed_username);
83 } 84 }
84 85
85 // Loads about:hang into two NTP tabs, ensuring we don't crash. 86 // Loads about:hang into two NTP tabs, ensuring we don't crash.
86 // See http://crbug.com/59859. 87 // See http://crbug.com/59859.
87 TEST_F(NewTabUITest, AboutHangInNTP) { 88 TEST_F(NewTabUITest, AboutHangInNTP) {
88 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 89 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
89 ASSERT_TRUE(window.get()); 90 ASSERT_TRUE(window.get());
90 91
91 // Bring up a new tab page. 92 // Bring up a new tab page.
92 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); 93 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 146
146 // Go to the "new tab page" using its old url, rather than chrome://newtab. 147 // Go to the "new tab page" using its old url, rather than chrome://newtab.
147 scoped_refptr<TabProxy> tab = window->GetTab(0); 148 scoped_refptr<TabProxy> tab = window->GetTab(0);
148 ASSERT_TRUE(tab.get()); 149 ASSERT_TRUE(tab.get());
149 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("chrome-internal:"))); 150 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("chrome-internal:")));
150 int load_time; 151 int load_time;
151 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); 152 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
152 153
153 // Ensure there are some thumbnails loaded in the page. 154 // Ensure there are some thumbnails loaded in the page.
154 int thumbnails_count = -1; 155 int thumbnails_count = -1;
155 ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", 156 ASSERT_TRUE(tab->ExecuteAndExtractInt(
156 L"window.domAutomationController.send(" 157 string16(),
157 L"document.getElementsByClassName('thumbnail-container').length)", 158 ASCIIToUTF16("window.domAutomationController.send("
159 "document.getElementsByClassName('thumbnail-container').length)"),
158 &thumbnails_count)); 160 &thumbnails_count));
159 EXPECT_GT(thumbnails_count, 0); 161 EXPECT_GT(thumbnails_count, 0);
160 } 162 }
161 163
162 // Flaky on XP bots: http://crbug.com/51726 164 // Flaky on XP bots: http://crbug.com/51726
163 TEST_F(NewTabUITest, FLAKY_UpdateUserPrefsVersion) { 165 TEST_F(NewTabUITest, FLAKY_UpdateUserPrefsVersion) {
164 // PrefService with JSON user-pref file only, no enforced or advised prefs. 166 // PrefService with JSON user-pref file only, no enforced or advised prefs.
165 scoped_ptr<PrefService> prefs(new TestingPrefService); 167 scoped_ptr<PrefService> prefs(new TestingPrefService);
166 168
167 // Does the migration 169 // Does the migration
168 NewTabUI::RegisterUserPrefs(prefs.get()); 170 NewTabUI::RegisterUserPrefs(prefs.get());
169 171
170 ASSERT_EQ(NewTabUI::current_pref_version(), 172 ASSERT_EQ(NewTabUI::current_pref_version(),
171 prefs->GetInteger(prefs::kNTPPrefVersion)); 173 prefs->GetInteger(prefs::kNTPPrefVersion));
172 174
173 // Reset the version 175 // Reset the version
174 prefs->ClearPref(prefs::kNTPPrefVersion); 176 prefs->ClearPref(prefs::kNTPPrefVersion);
175 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); 177 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion));
176 178
177 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); 179 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get());
178 ASSERT_TRUE(migrated); 180 ASSERT_TRUE(migrated);
179 ASSERT_EQ(NewTabUI::current_pref_version(), 181 ASSERT_EQ(NewTabUI::current_pref_version(),
180 prefs->GetInteger(prefs::kNTPPrefVersion)); 182 prefs->GetInteger(prefs::kNTPPrefVersion));
181 183
182 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); 184 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get());
183 ASSERT_FALSE(migrated); 185 ASSERT_FALSE(migrated);
184 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698