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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 browser()->GetFindBarController()->Show(); | 220 browser()->GetFindBarController()->Show(); |
221 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 221 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
222 | 222 |
223 // The buttons should be disabled as there is no text entered in the find bar | 223 // The buttons should be disabled as there is no text entered in the find bar |
224 // and no search has been issued yet. | 224 // and no search has been issued yet. |
225 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false, | 225 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false, |
226 false, false, false)); | 226 false, false, false)); |
227 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_CLOSE_BUTTON)); | 227 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_CLOSE_BUTTON)); |
228 } | 228 } |
229 | 229 |
230 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 230 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
231 // TODO(erg): linux_aura bringup: http://crbug.com/163931 | |
232 #define MAYBE_FocusRestore DISABLED_FocusRestore | |
233 #else | |
234 #define MAYBE_FocusRestore FocusRestore | |
235 #endif | |
236 | |
237 // Flaky because the test server fails to start? See: http://crbug.com/96594. | |
238 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestore) { | |
239 ASSERT_TRUE(embedded_test_server()->Start()); | 231 ASSERT_TRUE(embedded_test_server()->Start()); |
240 | 232 |
241 GURL url = embedded_test_server()->GetURL("/title1.html"); | 233 GURL url = embedded_test_server()->GetURL("/title1.html"); |
242 ui_test_utils::NavigateToURL(browser(), url); | 234 ui_test_utils::NavigateToURL(browser(), url); |
243 | 235 |
244 // Focus the location bar, open and close the find-in-page, focus should | 236 // Focus the location bar, open and close the find-in-page, focus should |
245 // return to the location bar. | 237 // return to the location bar. |
246 chrome::FocusLocationBar(browser()); | 238 chrome::FocusLocationBar(browser()); |
247 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 239 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
248 // Ensure the creation of the find bar controller. | 240 // Ensure the creation of the find bar controller. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 browser()->tab_strip_model()->ActivateTabAt(0, true); | 336 browser()->tab_strip_model()->ActivateTabAt(0, true); |
345 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 337 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
346 EXPECT_EQ(ASCIIToUTF16("bc"), GetFindBarSelectedText()); | 338 EXPECT_EQ(ASCIIToUTF16("bc"), GetFindBarSelectedText()); |
347 | 339 |
348 // Select tab B. Find bar should select "de". | 340 // Select tab B. Find bar should select "de". |
349 browser()->tab_strip_model()->ActivateTabAt(1, true); | 341 browser()->tab_strip_model()->ActivateTabAt(1, true); |
350 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 342 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
351 EXPECT_EQ(ASCIIToUTF16("de"), GetFindBarSelectedText()); | 343 EXPECT_EQ(ASCIIToUTF16("de"), GetFindBarSelectedText()); |
352 } | 344 } |
353 | 345 |
354 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 346 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestoreOnTabSwitch) { |
355 // TODO(erg): linux_aura bringup: http://crbug.com/163931 | |
356 #define MAYBE_FocusRestoreOnTabSwitch DISABLED_FocusRestoreOnTabSwitch | |
357 #else | |
358 #define MAYBE_FocusRestoreOnTabSwitch FocusRestoreOnTabSwitch | |
359 #endif | |
360 | |
361 // Flaky because the test server fails to start? See: http://crbug.com/96594. | |
362 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) { | |
363 ASSERT_TRUE(embedded_test_server()->Start()); | 347 ASSERT_TRUE(embedded_test_server()->Start()); |
364 | 348 |
365 // First we navigate to our test page (tab A). | 349 // First we navigate to our test page (tab A). |
366 GURL url = embedded_test_server()->GetURL(kSimplePage); | 350 GURL url = embedded_test_server()->GetURL(kSimplePage); |
367 ui_test_utils::NavigateToURL(browser(), url); | 351 ui_test_utils::NavigateToURL(browser(), url); |
368 | 352 |
369 chrome::Find(browser()); | 353 chrome::Find(browser()); |
370 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 354 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
371 | 355 |
372 // Search for 'a'. | 356 // Search for 'a'. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 531 |
548 ui_test_utils::UrlLoadObserver observer( | 532 ui_test_utils::UrlLoadObserver observer( |
549 GURL("about:blank"), content::NotificationService::AllSources()); | 533 GURL("about:blank"), content::NotificationService::AllSources()); |
550 | 534 |
551 // Send Ctrl-Enter, should cause navigation to about:blank. | 535 // Send Ctrl-Enter, should cause navigation to about:blank. |
552 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 536 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
553 browser(), ui::VKEY_RETURN, true, false, false, false)); | 537 browser(), ui::VKEY_RETURN, true, false, false, false)); |
554 | 538 |
555 observer.Wait(); | 539 observer.Wait(); |
556 } | 540 } |
OLD | NEW |