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

Side by Side Diff: chrome/browser/ui/views/find_bar_host_interactive_uitest.cc

Issue 14295003: Re-enable a few find in page tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Leave last test disabled Created 7 years, 8 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) 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 "base/process_util.h" 5 #include "base/process_util.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_tabstrip.h" 10 #include "chrome/browser/ui/browser_tabstrip.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/base/clipboard/clipboard.h" 24 #include "ui/base/clipboard/clipboard.h"
25 #include "ui/base/keycodes/keyboard_codes.h" 25 #include "ui/base/keycodes/keyboard_codes.h"
26 #include "ui/views/focus/focus_manager.h" 26 #include "ui/views/focus/focus_manager.h"
27 #include "ui/views/view.h" 27 #include "ui/views/view.h"
28 #include "ui/views/views_delegate.h" 28 #include "ui/views/views_delegate.h"
29 29
30 using content::WebContents; 30 using content::WebContents;
31 31
32 namespace { 32 namespace {
33 33
34 // The delay waited after sending an OS simulated event.
35 static const int kActionDelayMs = 500;
36 static const char kSimplePage[] = "files/find_in_page/simple.html"; 34 static const char kSimplePage[] = "files/find_in_page/simple.html";
37 35
38 void Checkpoint(const char* message, const base::TimeTicks& start_time) {
39 LOG(INFO) << message << " : "
40 << (base::TimeTicks::Now() - start_time).InMilliseconds()
41 << " ms" << std::flush;
42 }
43
44 class FindInPageTest : public InProcessBrowserTest { 36 class FindInPageTest : public InProcessBrowserTest {
45 public: 37 public:
46 FindInPageTest() { 38 FindInPageTest() {
47 FindBarHost::disable_animations_during_testing_ = true; 39 FindBarHost::disable_animations_during_testing_ = true;
48 } 40 }
49 41
50 string16 GetFindBarText() { 42 string16 GetFindBarText() {
51 FindBarTesting* find_bar = 43 FindBarTesting* find_bar =
52 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); 44 browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
53 return find_bar->GetFindText(); 45 return find_bar->GetFindText();
54 } 46 }
55 47
56 string16 GetFindBarSelectedText() { 48 string16 GetFindBarSelectedText() {
57 FindBarTesting* find_bar = 49 FindBarTesting* find_bar =
58 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); 50 browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
59 return find_bar->GetFindSelectedText(); 51 return find_bar->GetFindSelectedText();
60 } 52 }
61 53
62 private: 54 private:
63 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); 55 DISALLOW_COPY_AND_ASSIGN(FindInPageTest);
64 }; 56 };
65 57
66 } // namespace 58 } // namespace
67 59
68 // Fails often on Win, CrOS. http://crbug.com/145476, http://crbug.com/128724 60 // Flaky because the test server fails to start? See: http://crbug.com/96594.
msw 2013/04/18 16:11:57 http://crbug.com/145476 looks related, but I'm not
Finnur 2013/04/19 10:55:45 Yeah, it is hard to say. There was a suspected CL
69 #if defined(OS_WIN) || defined(OS_CHROMEOS) 61 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
70 #define MAYBE_CrashEscHandlers DISABLED_CrashEscHandlers
71 #else
72 #define MAYBE_CrashEscHandlers CrashEscHandlers
73 #endif
74 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) {
75 ASSERT_TRUE(test_server()->Start()); 62 ASSERT_TRUE(test_server()->Start());
76 63
77 // First we navigate to our test page (tab A). 64 // First we navigate to our test page (tab A).
78 GURL url = test_server()->GetURL(kSimplePage); 65 GURL url = test_server()->GetURL(kSimplePage);
79 ui_test_utils::NavigateToURL(browser(), url); 66 ui_test_utils::NavigateToURL(browser(), url);
80 67
81 chrome::Find(browser()); 68 chrome::Find(browser());
82 69
83 // Open another tab (tab B). 70 // Open another tab (tab B).
84 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED); 71 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED);
(...skipping 13 matching lines...) Expand all
98 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), 85 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(),
99 VIEW_ID_OMNIBOX)); 86 VIEW_ID_OMNIBOX));
100 // Check the location bar is focused. 87 // Check the location bar is focused.
101 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 88 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
102 89
103 // This used to crash until bug 1303709 was fixed. 90 // This used to crash until bug 1303709 was fixed.
104 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 91 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
105 browser(), ui::VKEY_ESCAPE, false, false, false, false)); 92 browser(), ui::VKEY_ESCAPE, false, false, false, false));
106 } 93 }
107 94
108 // Fails to start the test server on ChromeOS: http://crbug.com/168974 95 // Flaky because the test server fails to start? See: http://crbug.com/96594.
109 #if defined(OS_CHROMEOS) 96 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
110 #define MAYBE_FocusRestore DISABLED_FocusRestore
111 #else
112 #define MAYBE_FocusRestore FocusRestore
113 #endif
114 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestore) {
115 ASSERT_TRUE(test_server()->Start()); 97 ASSERT_TRUE(test_server()->Start());
116 98
117 GURL url = test_server()->GetURL("title1.html"); 99 GURL url = test_server()->GetURL("title1.html");
118 ui_test_utils::NavigateToURL(browser(), url); 100 ui_test_utils::NavigateToURL(browser(), url);
119 101
120 // Focus the location bar, open and close the find-in-page, focus should 102 // Focus the location bar, open and close the find-in-page, focus should
121 // return to the location bar. 103 // return to the location bar.
122 chrome::FocusLocationBar(browser()); 104 chrome::FocusLocationBar(browser());
123 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 105 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
124 // Ensure the creation of the find bar controller. 106 // Ensure the creation of the find bar controller.
(...skipping 26 matching lines...) Expand all
151 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 133 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
152 browser()->GetFindBarController()->Show(); 134 browser()->GetFindBarController()->Show();
153 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 135 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
154 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 136 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
155 browser()->GetFindBarController()->EndFindSession( 137 browser()->GetFindBarController()->EndFindSession(
156 FindBarController::kKeepSelectionOnPage, 138 FindBarController::kKeepSelectionOnPage,
157 FindBarController::kKeepResultsInFindBox); 139 FindBarController::kKeepResultsInFindBox);
158 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 140 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
159 } 141 }
160 142
161 // Fails often on Win, CrOS. http://crbug.com/145476, http://crbug.com/128724 143 // Flaky because the test server fails to start? See: http://crbug.com/96594.
162 #if defined(OS_WIN) || defined(OS_CHROMEOS) 144 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestoreOnTabSwitch) {
163 #define MAYBE_FocusRestoreOnTabSwitch DISABLED_FocusRestoreOnTabSwitch
164 #else
165 #define MAYBE_FocusRestoreOnTabSwitch FocusRestoreOnTabSwitch
166 #endif
167 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) {
168 ASSERT_TRUE(test_server()->Start()); 145 ASSERT_TRUE(test_server()->Start());
169 146
170 // First we navigate to our test page (tab A). 147 // First we navigate to our test page (tab A).
171 GURL url = test_server()->GetURL(kSimplePage); 148 GURL url = test_server()->GetURL(kSimplePage);
172 ui_test_utils::NavigateToURL(browser(), url); 149 ui_test_utils::NavigateToURL(browser(), url);
173 150
174 chrome::Find(browser()); 151 chrome::Find(browser());
175 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 152 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
176 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 153 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
177 154
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 browser()->tab_strip_model()->ActivateTabAt(0, true); 187 browser()->tab_strip_model()->ActivateTabAt(0, true);
211 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 188 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
212 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 189 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
213 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); 190 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
214 191
215 // Select tab B. Location bar should get focus. 192 // Select tab B. Location bar should get focus.
216 browser()->tab_strip_model()->ActivateTabAt(1, true); 193 browser()->tab_strip_model()->ActivateTabAt(1, true);
217 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 194 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
218 } 195 }
219 196
220 // Flaky on XP: http://crbug.com/152100 197 // Flaky because the test server fails to start? See: http://crbug.com/96594.
msw 2013/04/18 16:11:57 http://crbug.com/152100 doesn't look related.
Finnur 2013/04/19 10:55:45 Remember when you said you couldn't repro the flak
221 // Flaky on ChromiumOS: http://crbug.com/177487
222 #if defined(OS_WIN) || defined(OS_CHROMEOS)
223 #define MAYBE_PrepopulateRespectBlank DISABLED_PrepopulateRespectBlank
224 #else
225 #define MAYBE_PrepopulateRespectBlank PrepopulateRespectBlank
226 #endif
227 // This tests that whenever you clear values from the Find box and close it that 198 // This tests that whenever you clear values from the Find box and close it that
228 // it respects that and doesn't show you the last search, as reported in bug: 199 // it respects that and doesn't show you the last search, as reported in bug:
229 // http://crbug.com/40121. 200 // http://crbug.com/40121.
230 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_PrepopulateRespectBlank) { 201 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) {
231 #if defined(OS_MACOSX) 202 #if defined(OS_MACOSX)
232 // FindInPage on Mac doesn't use prepopulated values. Search there is global. 203 // FindInPage on Mac doesn't use prepopulated values. Search there is global.
233 return; 204 return;
234 #endif 205 #endif
235 base::TimeTicks start_time = base::TimeTicks::Now();
236 Checkpoint("Test starting", start_time);
237
238 ASSERT_TRUE(test_server()->Start()); 206 ASSERT_TRUE(test_server()->Start());
239 207
240 // Make sure Chrome is in the foreground, otherwise sending input 208 // Make sure Chrome is in the foreground, otherwise sending input
241 // won't do anything and the test will hang. 209 // won't do anything and the test will hang.
242 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 210 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
243 211
244 Checkpoint("Navigate", start_time);
245
246 // First we navigate to any page. 212 // First we navigate to any page.
247 GURL url = test_server()->GetURL(kSimplePage); 213 GURL url = test_server()->GetURL(kSimplePage);
248 ui_test_utils::NavigateToURL(browser(), url); 214 ui_test_utils::NavigateToURL(browser(), url);
249 215
250 Checkpoint("Show Find bar", start_time);
251
252 // Show the Find bar. 216 // Show the Find bar.
253 browser()->GetFindBarController()->Show(); 217 browser()->GetFindBarController()->Show();
254 218
255 Checkpoint("Search for 'a'", start_time);
256
257 // Search for "a". 219 // Search for "a".
258 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 220 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
259 browser(), ui::VKEY_A, false, false, false, false)); 221 browser(), ui::VKEY_A, false, false, false, false));
260 222
261 // We should find "a" here. 223 // We should find "a" here.
262 EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText()); 224 EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText());
263 225
264 Checkpoint("Delete 'a'", start_time);
265
266 // Delete "a". 226 // Delete "a".
267 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 227 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
268 browser(), ui::VKEY_BACK, false, false, false, false)); 228 browser(), ui::VKEY_BACK, false, false, false, false));
269 229
270 // Validate we have cleared the text. 230 // Validate we have cleared the text.
271 EXPECT_EQ(string16(), GetFindBarText()); 231 EXPECT_EQ(string16(), GetFindBarText());
272 232
273 Checkpoint("Close find bar", start_time);
274
275 // Close the Find box. 233 // Close the Find box.
276 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 234 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
277 browser(), ui::VKEY_ESCAPE, false, false, false, false)); 235 browser(), ui::VKEY_ESCAPE, false, false, false, false));
278 236
279 Checkpoint("Show Find bar", start_time);
280
281 // Show the Find bar. 237 // Show the Find bar.
282 browser()->GetFindBarController()->Show(); 238 browser()->GetFindBarController()->Show();
283 239
284 Checkpoint("Validate text", start_time);
285
286 // After the Find box has been reopened, it should not have been prepopulated 240 // After the Find box has been reopened, it should not have been prepopulated
287 // with "a" again. 241 // with "a" again.
288 EXPECT_EQ(string16(), GetFindBarText()); 242 EXPECT_EQ(string16(), GetFindBarText());
289 243
290 Checkpoint("Close Find bar", start_time);
291
292 // Close the Find box. 244 // Close the Find box.
293 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 245 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
294 browser(), ui::VKEY_ESCAPE, false, false, false, false)); 246 browser(), ui::VKEY_ESCAPE, false, false, false, false));
295 247
296 Checkpoint("FindNext", start_time);
297
298 // Press F3 to trigger FindNext. 248 // Press F3 to trigger FindNext.
299 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 249 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
300 browser(), ui::VKEY_F3, false, false, false, false)); 250 browser(), ui::VKEY_F3, false, false, false, false));
301 251
302 Checkpoint("Validate", start_time);
303
304 // After the Find box has been reopened, it should still have no prepopulate 252 // After the Find box has been reopened, it should still have no prepopulate
305 // value. 253 // value.
306 EXPECT_EQ(string16(), GetFindBarText()); 254 EXPECT_EQ(string16(), GetFindBarText());
307
308 Checkpoint("Test done", start_time);
309 } 255 }
310 256
311 // Flaky on Win. http://crbug.com/92467 257 // Flaky on Win. http://crbug.com/92467
312 // Flaky on ChromeOS. http://crbug.com/118216 258 // Flaky on ChromeOS. http://crbug.com/118216
313 #if defined(OS_WIN) || defined(OS_CHROMEOS) 259 #if defined(OS_WIN) || defined(OS_CHROMEOS)
314 #define MAYBE_PasteWithoutTextChange DISABLED_PasteWithoutTextChange 260 #define MAYBE_PasteWithoutTextChange DISABLED_PasteWithoutTextChange
315 #else 261 #else
316 #define MAYBE_PasteWithoutTextChange PasteWithoutTextChange 262 #define MAYBE_PasteWithoutTextChange PasteWithoutTextChange
317 #endif 263 #endif
318 264
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); 318 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source);
373 319
374 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 320 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
375 browser(), ui::VKEY_V, true, false, false, false)); 321 browser(), ui::VKEY_V, true, false, false, false));
376 322
377 ASSERT_NO_FATAL_FAILURE(observer.Wait()); 323 ASSERT_NO_FATAL_FAILURE(observer.Wait());
378 FindNotificationDetails details; 324 FindNotificationDetails details;
379 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); 325 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details));
380 EXPECT_TRUE(details.number_of_matches() > 0); 326 EXPECT_TRUE(details.number_of_matches() > 0);
381 } 327 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/find_bar_view.cc » ('j') | chrome/browser/ui/views/find_bar_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698