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

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

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month 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
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/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.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"
11 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 11 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
12 #include "chrome/browser/ui/find_bar/find_notification_details.h" 12 #include "chrome/browser/ui/find_bar/find_notification_details.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/browser/ui/view_ids.h" 14 #include "chrome/browser/ui/view_ids.h"
15 #include "chrome/browser/ui/views/find_bar_host.h" 15 #include "chrome/browser/ui/views/find_bar_host.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/interactive_test_utils.h" 18 #include "chrome/test/base/interactive_test_utils.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "net/test/spawned_test_server/spawned_test_server.h"
23 #include "ui/base/clipboard/clipboard.h" 22 #include "ui/base/clipboard/clipboard.h"
24 #include "ui/events/keycodes/keyboard_codes.h" 23 #include "ui/events/keycodes/keyboard_codes.h"
25 #include "ui/views/focus/focus_manager.h" 24 #include "ui/views/focus/focus_manager.h"
26 #include "ui/views/view.h" 25 #include "ui/views/view.h"
27 26
28 using base::ASCIIToUTF16; 27 using base::ASCIIToUTF16;
29 using content::WebContents; 28 using content::WebContents;
30 29
31 namespace { 30 namespace {
32 31
33 static const char kSimplePage[] = "files/find_in_page/simple.html"; 32 static const char kSimplePage[] = "/find_in_page/simple.html";
34 33
35 class FindInPageTest : public InProcessBrowserTest { 34 class FindInPageTest : public InProcessBrowserTest {
36 public: 35 public:
37 FindInPageTest() { 36 FindInPageTest() {
38 FindBarHost::disable_animations_during_testing_ = true; 37 FindBarHost::disable_animations_during_testing_ = true;
39 } 38 }
40 39
41 base::string16 GetFindBarText() { 40 base::string16 GetFindBarText() {
42 FindBar* find_bar = browser()->GetFindBarController()->find_bar(); 41 FindBar* find_bar = browser()->GetFindBarController()->find_bar();
43 return find_bar->GetFindText(); 42 return find_bar->GetFindText();
44 } 43 }
45 44
46 base::string16 GetFindBarSelectedText() { 45 base::string16 GetFindBarSelectedText() {
47 FindBarTesting* find_bar = 46 FindBarTesting* find_bar =
48 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); 47 browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
49 return find_bar->GetFindSelectedText(); 48 return find_bar->GetFindSelectedText();
50 } 49 }
51 50
52 private: 51 private:
53 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); 52 DISALLOW_COPY_AND_ASSIGN(FindInPageTest);
54 }; 53 };
55 54
56 } // namespace 55 } // namespace
57 56
58 // Flaky because the test server fails to start? See: http://crbug.com/96594. 57 // Flaky because the test server fails to start? See: http://crbug.com/96594.
59 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { 58 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
60 ASSERT_TRUE(test_server()->Start()); 59 ASSERT_TRUE(embedded_test_server()->Start());
61 60
62 // First we navigate to our test page (tab A). 61 // First we navigate to our test page (tab A).
63 GURL url = test_server()->GetURL(kSimplePage); 62 GURL url = embedded_test_server()->GetURL(kSimplePage);
64 ui_test_utils::NavigateToURL(browser(), url); 63 ui_test_utils::NavigateToURL(browser(), url);
65 64
66 chrome::Find(browser()); 65 chrome::Find(browser());
67 66
68 // Open another tab (tab B). 67 // Open another tab (tab B).
69 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); 68 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED);
70 69
71 chrome::Find(browser()); 70 chrome::Find(browser());
72 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 71 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
73 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 72 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
(...skipping 10 matching lines...) Expand all
84 VIEW_ID_OMNIBOX)); 83 VIEW_ID_OMNIBOX));
85 // Check the location bar is focused. 84 // Check the location bar is focused.
86 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 85 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
87 86
88 // This used to crash until bug 1303709 was fixed. 87 // This used to crash until bug 1303709 was fixed.
89 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 88 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
90 browser(), ui::VKEY_ESCAPE, false, false, false, false)); 89 browser(), ui::VKEY_ESCAPE, false, false, false, false));
91 } 90 }
92 91
93 IN_PROC_BROWSER_TEST_F(FindInPageTest, NavigationByKeyEvent) { 92 IN_PROC_BROWSER_TEST_F(FindInPageTest, NavigationByKeyEvent) {
94 ASSERT_TRUE(test_server()->Start()); 93 ASSERT_TRUE(embedded_test_server()->Start());
95 // Make sure Chrome is in the foreground, otherwise sending input 94 // Make sure Chrome is in the foreground, otherwise sending input
96 // won't do anything and the test will hang. 95 // won't do anything and the test will hang.
97 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 96 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
98 // First we navigate to any page. 97 // First we navigate to any page.
99 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); 98 ui_test_utils::NavigateToURL(browser(),
99 embedded_test_server()->GetURL(kSimplePage));
100 // Show the Find bar. 100 // Show the Find bar.
101 browser()->GetFindBarController()->Show(); 101 browser()->GetFindBarController()->Show();
102 EXPECT_TRUE( 102 EXPECT_TRUE(
103 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 103 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
104 ui_test_utils::FindInPage( 104 ui_test_utils::FindInPage(
105 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"), 105 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"),
106 true, false, NULL, NULL); 106 true, false, NULL, NULL);
107 107
108 // The textfield should be focused after pressing [Enter] on the find button. 108 // The textfield should be focused after pressing [Enter] on the find button.
109 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false, 109 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
(...skipping 19 matching lines...) Expand all
129 129
130 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 130 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
131 // TODO(erg): linux_aura bringup: http://crbug.com/163931 131 // TODO(erg): linux_aura bringup: http://crbug.com/163931
132 #define MAYBE_FocusRestore DISABLED_FocusRestore 132 #define MAYBE_FocusRestore DISABLED_FocusRestore
133 #else 133 #else
134 #define MAYBE_FocusRestore FocusRestore 134 #define MAYBE_FocusRestore FocusRestore
135 #endif 135 #endif
136 136
137 // Flaky because the test server fails to start? See: http://crbug.com/96594. 137 // Flaky because the test server fails to start? See: http://crbug.com/96594.
138 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestore) { 138 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestore) {
139 ASSERT_TRUE(test_server()->Start()); 139 ASSERT_TRUE(embedded_test_server()->Start());
140 140
141 GURL url = test_server()->GetURL("title1.html"); 141 GURL url = embedded_test_server()->GetURL("/title1.html");
142 ui_test_utils::NavigateToURL(browser(), url); 142 ui_test_utils::NavigateToURL(browser(), url);
143 143
144 // Focus the location bar, open and close the find-in-page, focus should 144 // Focus the location bar, open and close the find-in-page, focus should
145 // return to the location bar. 145 // return to the location bar.
146 chrome::FocusLocationBar(browser()); 146 chrome::FocusLocationBar(browser());
147 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 147 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
148 // Ensure the creation of the find bar controller. 148 // Ensure the creation of the find bar controller.
149 browser()->GetFindBarController()->Show(); 149 browser()->GetFindBarController()->Show();
150 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 150 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
151 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 151 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
(...skipping 28 matching lines...) Expand all
180 FindBarController::kKeepSelectionOnPage, 180 FindBarController::kKeepSelectionOnPage,
181 FindBarController::kKeepResultsInFindBox); 181 FindBarController::kKeepResultsInFindBox);
182 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 182 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
183 } 183 }
184 184
185 185
186 // TODO(phajdan.jr): Disabling due to possible timing issues on XP 186 // TODO(phajdan.jr): Disabling due to possible timing issues on XP
187 // interactive_ui_tests. 187 // interactive_ui_tests.
188 // http://crbug.com/311363 188 // http://crbug.com/311363
189 IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_SelectionRestoreOnTabSwitch) { 189 IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_SelectionRestoreOnTabSwitch) {
190 ASSERT_TRUE(test_server()->Start()); 190 ASSERT_TRUE(embedded_test_server()->Start());
191 191
192 // Make sure Chrome is in the foreground, otherwise sending input 192 // Make sure Chrome is in the foreground, otherwise sending input
193 // won't do anything and the test will hang. 193 // won't do anything and the test will hang.
194 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 194 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
195 195
196 // First we navigate to any page in the current tab (tab A). 196 // First we navigate to any page in the current tab (tab A).
197 GURL url = test_server()->GetURL(kSimplePage); 197 GURL url = embedded_test_server()->GetURL(kSimplePage);
198 ui_test_utils::NavigateToURL(browser(), url); 198 ui_test_utils::NavigateToURL(browser(), url);
199 199
200 // Show the Find bar. 200 // Show the Find bar.
201 browser()->GetFindBarController()->Show(); 201 browser()->GetFindBarController()->Show();
202 202
203 // Search for "abc". 203 // Search for "abc".
204 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 204 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
205 browser(), ui::VKEY_A, false, false, false, false)); 205 browser(), ui::VKEY_A, false, false, false, false));
206 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 206 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
207 browser(), ui::VKEY_B, false, false, false, false)); 207 browser(), ui::VKEY_B, false, false, false, false));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 260 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
261 // TODO(erg): linux_aura bringup: http://crbug.com/163931 261 // TODO(erg): linux_aura bringup: http://crbug.com/163931
262 #define MAYBE_FocusRestoreOnTabSwitch DISABLED_FocusRestoreOnTabSwitch 262 #define MAYBE_FocusRestoreOnTabSwitch DISABLED_FocusRestoreOnTabSwitch
263 #else 263 #else
264 #define MAYBE_FocusRestoreOnTabSwitch FocusRestoreOnTabSwitch 264 #define MAYBE_FocusRestoreOnTabSwitch FocusRestoreOnTabSwitch
265 #endif 265 #endif
266 266
267 // Flaky because the test server fails to start? See: http://crbug.com/96594. 267 // Flaky because the test server fails to start? See: http://crbug.com/96594.
268 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) { 268 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) {
269 ASSERT_TRUE(test_server()->Start()); 269 ASSERT_TRUE(embedded_test_server()->Start());
270 270
271 // First we navigate to our test page (tab A). 271 // First we navigate to our test page (tab A).
272 GURL url = test_server()->GetURL(kSimplePage); 272 GURL url = embedded_test_server()->GetURL(kSimplePage);
273 ui_test_utils::NavigateToURL(browser(), url); 273 ui_test_utils::NavigateToURL(browser(), url);
274 274
275 chrome::Find(browser()); 275 chrome::Find(browser());
276 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 276 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
277 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 277 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
278 278
279 // Search for 'a'. 279 // Search for 'a'.
280 ui_test_utils::FindInPage( 280 ui_test_utils::FindInPage(
281 browser()->tab_strip_model()->GetActiveWebContents(), 281 browser()->tab_strip_model()->GetActiveWebContents(),
282 ASCIIToUTF16("a"), true, false, NULL, NULL); 282 ASCIIToUTF16("a"), true, false, NULL, NULL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 315 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
316 } 316 }
317 317
318 // FindInPage on Mac doesn't use prepopulated values. Search there is global. 318 // FindInPage on Mac doesn't use prepopulated values. Search there is global.
319 #if !defined(OS_MACOSX) && !defined(USE_AURA) 319 #if !defined(OS_MACOSX) && !defined(USE_AURA)
320 // Flaky because the test server fails to start? See: http://crbug.com/96594. 320 // Flaky because the test server fails to start? See: http://crbug.com/96594.
321 // This tests that whenever you clear values from the Find box and close it that 321 // This tests that whenever you clear values from the Find box and close it that
322 // it respects that and doesn't show you the last search, as reported in bug: 322 // it respects that and doesn't show you the last search, as reported in bug:
323 // http://crbug.com/40121. For Aura see bug http://crbug.com/292299. 323 // http://crbug.com/40121. For Aura see bug http://crbug.com/292299.
324 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) { 324 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) {
325 ASSERT_TRUE(test_server()->Start()); 325 ASSERT_TRUE(embedded_test_server()->Start());
326 326
327 // Make sure Chrome is in the foreground, otherwise sending input 327 // Make sure Chrome is in the foreground, otherwise sending input
328 // won't do anything and the test will hang. 328 // won't do anything and the test will hang.
329 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 329 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
330 330
331 // First we navigate to any page. 331 // First we navigate to any page.
332 GURL url = test_server()->GetURL(kSimplePage); 332 GURL url = embedded_test_server()->GetURL(kSimplePage);
333 ui_test_utils::NavigateToURL(browser(), url); 333 ui_test_utils::NavigateToURL(browser(), url);
334 334
335 // Show the Find bar. 335 // Show the Find bar.
336 browser()->GetFindBarController()->Show(); 336 browser()->GetFindBarController()->Show();
337 337
338 // Search for "a". 338 // Search for "a".
339 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 339 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
340 browser(), ui::VKEY_A, false, false, false, false)); 340 browser(), ui::VKEY_A, false, false, false, false));
341 341
342 // We should find "a" here. 342 // We should find "a" here.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Flaky on Win. http://crbug.com/92467 377 // Flaky on Win. http://crbug.com/92467
378 // Flaky on ChromeOS. http://crbug.com/118216 378 // Flaky on ChromeOS. http://crbug.com/118216
379 // Flaky on linux aura. http://crbug.com/163931 379 // Flaky on linux aura. http://crbug.com/163931
380 #if defined(TOOLKIT_VIEWS) 380 #if defined(TOOLKIT_VIEWS)
381 #define MAYBE_PasteWithoutTextChange DISABLED_PasteWithoutTextChange 381 #define MAYBE_PasteWithoutTextChange DISABLED_PasteWithoutTextChange
382 #else 382 #else
383 #define MAYBE_PasteWithoutTextChange PasteWithoutTextChange 383 #define MAYBE_PasteWithoutTextChange PasteWithoutTextChange
384 #endif 384 #endif
385 385
386 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_PasteWithoutTextChange) { 386 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_PasteWithoutTextChange) {
387 ASSERT_TRUE(test_server()->Start()); 387 ASSERT_TRUE(embedded_test_server()->Start());
388 388
389 // Make sure Chrome is in the foreground, otherwise sending input 389 // Make sure Chrome is in the foreground, otherwise sending input
390 // won't do anything and the test will hang. 390 // won't do anything and the test will hang.
391 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 391 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
392 392
393 // First we navigate to any page. 393 // First we navigate to any page.
394 GURL url = test_server()->GetURL(kSimplePage); 394 GURL url = embedded_test_server()->GetURL(kSimplePage);
395 ui_test_utils::NavigateToURL(browser(), url); 395 ui_test_utils::NavigateToURL(browser(), url);
396 396
397 // Show the Find bar. 397 // Show the Find bar.
398 browser()->GetFindBarController()->Show(); 398 browser()->GetFindBarController()->Show();
399 399
400 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 400 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
401 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 401 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
402 402
403 // Search for "a". 403 // Search for "a".
404 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 404 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 ui_test_utils::UrlLoadObserver observer( 472 ui_test_utils::UrlLoadObserver observer(
473 GURL("about:blank"), content::NotificationService::AllSources()); 473 GURL("about:blank"), content::NotificationService::AllSources());
474 474
475 // Send Ctrl-Enter, should cause navigation to about:blank. 475 // Send Ctrl-Enter, should cause navigation to about:blank.
476 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 476 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
477 browser(), ui::VKEY_RETURN, true, false, false, false)); 477 browser(), ui::VKEY_RETURN, true, false, false, false));
478 478
479 observer.Wait(); 479 observer.Wait();
480 } 480 }
481 #endif 481 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698