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

Side by Side Diff: chrome/browser/views/find_bar_win_browsertest.cc

Issue 115832: Fix 12729: Find box doesn't unregister Esc accelerator.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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
« no previous file with comments | « chrome/browser/views/find_bar_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/find_bar_controller.h" 7 #include "chrome/browser/find_bar_controller.h"
8 #include "chrome/browser/find_notification_details.h" 8 #include "chrome/browser/find_notification_details.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/browser/tab_contents/tab_contents_view.h" 11 #include "chrome/browser/tab_contents/tab_contents_view.h"
12 #include "chrome/browser/views/find_bar_win.h" 12 #include "chrome/browser/views/find_bar_win.h"
13 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
14 #include "chrome/test/in_process_browser_test.h" 14 #include "chrome/test/in_process_browser_test.h"
15 #include "chrome/test/ui_test_utils.h" 15 #include "chrome/test/ui_test_utils.h"
16 #include "views/focus/focus_manager.h"
16 17
17 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; 18 const std::wstring kSimplePage = L"404_is_enough_for_us.html";
18 const std::wstring kFramePage = L"files/find_in_page/frames.html"; 19 const std::wstring kFramePage = L"files/find_in_page/frames.html";
19 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; 20 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html";
20 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; 21 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html";
21 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; 22 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html";
22 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; 23 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html";
23 const std::wstring kEndState = L"files/find_in_page/end_state.html"; 24 const std::wstring kEndState = L"files/find_in_page/end_state.html";
24 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; 25 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html";
25 const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html"; 26 const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html";
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 GetFindBarWindowInfo(&position, &fully_visible); 513 GetFindBarWindowInfo(&position, &fully_visible);
513 EXPECT_EQ(start_position, position); 514 EXPECT_EQ(start_position, position);
514 EXPECT_TRUE(fully_visible); 515 EXPECT_TRUE(fully_visible);
515 } 516 }
516 517
517 // Make sure F3 in a new tab works if Find has previous string to search for. 518 // Make sure F3 in a new tab works if Find has previous string to search for.
518 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, 519 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
519 FindNextInNewTabUsesPrepopulate) { 520 FindNextInNewTabUsesPrepopulate) {
520 HTTPTestServer* server = StartHTTPServer(); 521 HTTPTestServer* server = StartHTTPServer();
521 522
522 // First we navigate to our special focus tracking page. 523 // First we navigate to any page.
523 GURL url = server->TestServerPageW(kSimplePage); 524 GURL url = server->TestServerPageW(kSimplePage);
524 ui_test_utils::NavigateToURL(browser(), url); 525 ui_test_utils::NavigateToURL(browser(), url);
525 526
526 // Search for 'no_match'. No matches should be found. 527 // Search for 'no_match'. No matches should be found.
527 int ordinal = 0; 528 int ordinal = 0;
528 EXPECT_EQ(0, FindInPage(L"no_match", FWD, IGNORE_CASE, &ordinal)); 529 EXPECT_EQ(0, FindInPage(L"no_match", FWD, IGNORE_CASE, &ordinal));
529 EXPECT_EQ(0, ordinal); 530 EXPECT_EQ(0, ordinal);
530 531
531 // Open another tab (tab B). 532 // Open another tab (tab B).
532 browser()->NewTab(); 533 browser()->NewTab();
533 ui_test_utils::NavigateToURL(browser(), url); 534 ui_test_utils::NavigateToURL(browser(), url);
534 535
535 // Simulate what happens when you press F3 for FindNext. We should get a 536 // Simulate what happens when you press F3 for FindNext. We should get a
536 // response here (a hang means search was aborted). 537 // response here (a hang means search was aborted).
537 EXPECT_EQ(0, FindInPage(std::wstring(), FWD, IGNORE_CASE, &ordinal)); 538 EXPECT_EQ(0, FindInPage(std::wstring(), FWD, IGNORE_CASE, &ordinal));
538 EXPECT_EQ(0, ordinal); 539 EXPECT_EQ(0, ordinal);
539 540
540 // Open another tab (tab C). 541 // Open another tab (tab C).
541 browser()->NewTab(); 542 browser()->NewTab();
542 ui_test_utils::NavigateToURL(browser(), url); 543 ui_test_utils::NavigateToURL(browser(), url);
543 544
544 // Simulate what happens when you press F3 for FindNext. We should get a 545 // Simulate what happens when you press F3 for FindNext. We should get a
545 // response here (a hang means search was aborted). 546 // response here (a hang means search was aborted).
546 EXPECT_EQ(0, FindInPage(std::wstring(), FWD, IGNORE_CASE, &ordinal)); 547 EXPECT_EQ(0, FindInPage(std::wstring(), FWD, IGNORE_CASE, &ordinal));
547 EXPECT_EQ(0, ordinal); 548 EXPECT_EQ(0, ordinal);
548 } 549 }
550
551 // Make sure Find box grabs the Esc accelerator and restores it again.
552 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) {
553 HTTPTestServer* server = StartHTTPServer();
554
555 // First we navigate to any page.
556 GURL url = server->TestServerPageW(kSimplePage);
557 ui_test_utils::NavigateToURL(browser(), url);
558
559 views::FocusManager* focus_manager = views::FocusManager::GetFocusManager(
560 browser()->window()->GetNativeHandle());
561
562 // See where Escape is registered.
563 views::Accelerator escape(VK_ESCAPE, false, false, false);
564 views::AcceleratorTarget* old_target =
565 focus_manager->GetTargetForAccelerator(escape);
566 EXPECT_TRUE(old_target != NULL);
567
568 // Open the Find box.
569 browser()->ShowFindBar();
570
571 // Our Find bar should be the new target.
572 views::AcceleratorTarget* new_target =
573 focus_manager->GetTargetForAccelerator(escape);
574
575 EXPECT_TRUE(new_target != NULL);
576 EXPECT_NE(new_target, old_target);
577
578 // Close the Find box.
579 browser()->find_bar()->EndFindSession();
580
581 // The accelerator for Escape should be back to what it was before.
582 EXPECT_EQ(old_target, focus_manager->GetTargetForAccelerator(escape));
583 }
OLDNEW
« no previous file with comments | « chrome/browser/views/find_bar_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698