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

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

Issue 553042: Attempt to fix a flaky test (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | « no previous file | chrome/test/data/find_in_page/move_if_obscuring.html » ('j') | 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/keyboard_codes.h" 5 #include "base/keyboard_codes.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_window.h" 8 #include "chrome/browser/browser_window.h"
9 #include "chrome/browser/find_bar_controller.h" 9 #include "chrome/browser/find_bar_controller.h"
10 #include "chrome/browser/find_notification_details.h" 10 #include "chrome/browser/find_notification_details.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 browser()->ShowFindBar(); 565 browser()->ShowFindBar();
566 566
567 gfx::Point start_position; 567 gfx::Point start_position;
568 gfx::Point position; 568 gfx::Point position;
569 bool fully_visible = false; 569 bool fully_visible = false;
570 570
571 // Make sure it is open. 571 // Make sure it is open.
572 EXPECT_TRUE(GetFindBarWindowInfo(&start_position, &fully_visible)); 572 EXPECT_TRUE(GetFindBarWindowInfo(&start_position, &fully_visible));
573 EXPECT_TRUE(fully_visible); 573 EXPECT_TRUE(fully_visible);
574 574
575 // Search for 'dream' which the Find box is obscuring. 575 // Search for 'Chromium' which the Find box is obscuring.
576 int ordinal = 0; 576 int ordinal = 0;
577 TabContents* tab = browser()->GetSelectedTabContents(); 577 TabContents* tab = browser()->GetSelectedTabContents();
578 EXPECT_EQ(1, FindInPageWchar(tab, L"dream", 578 int index = 0;
579 kFwd, kIgnoreCase, &ordinal)); 579 for (; index < 30; ++index) {
Paweł Hajdan Jr. 2010/01/21 20:41:55 nit: Could you make 30 a constant (kIterations)?
580 EXPECT_EQ(1, ordinal); 580 EXPECT_EQ(30, FindInPageWchar(tab, L"Chromium",
581 kFwd, kIgnoreCase, &ordinal));
581 582
582 // Make sure Find box has moved. 583 // Check the position.
584 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
585 EXPECT_TRUE(fully_visible);
586
587 // If the Find box has moved then we are done.
588 if (position.x() != start_position.x())
589 break;
590 }
591
592 // We should not have reached the end.
593 ASSERT_GT(30, index);
594
595 // Search backwards once to get the Find box to move back.
596 EXPECT_EQ(30, FindInPageWchar(tab, L"Chromium",
597 kBack, kIgnoreCase, &ordinal));
598 // Check the position.
583 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 599 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
584 EXPECT_TRUE(fully_visible); 600 EXPECT_TRUE(fully_visible);
585 EXPECT_EQ(start_position.y(), position.y());
586 if (start_position.x() == position.x()) {
587 // Failure case. Try to gather more data.
588 std::string debug_msg = "Position check failed once. ";
589
590 // First see if flushing the message loop has any effect.
591 MessageLoop::current()->RunAllPending();
592
593 if (!GetFindBarWindowInfo(&position, &fully_visible)) {
594 debug_msg += "Get failed. ";
595 } else {
596 if (start_position.x() == position.x())
597 debug_msg += "Position check failed again. ";
598 else
599 debug_msg += "They now differ. ";
600 }
601 // Force the failure.
602 EXPECT_STREQ("", debug_msg.c_str());
603 }
604 EXPECT_NE(start_position.x(), position.x());
605
606 // Search for 'Too much' which the Find box is not obscuring.
607 EXPECT_EQ(1, FindInPageWchar(tab, L"Too much",
608 kFwd, kIgnoreCase, &ordinal));
609 EXPECT_EQ(1, ordinal);
610 601
611 // Make sure Find box has moved back to its original location. 602 // Make sure Find box has moved back to its original location.
612 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 603 EXPECT_EQ(position.x(), start_position.x());
613 EXPECT_TRUE(fully_visible);
614 EXPECT_EQ(start_position, position);
615 } 604 }
616 605
617 // Make sure F3 in a new tab works if Find has previous string to search for. 606 // Make sure F3 in a new tab works if Find has previous string to search for.
618 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, 607 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
619 FindNextInNewTabUsesPrepopulate) { 608 FindNextInNewTabUsesPrepopulate) {
620 HTTPTestServer* server = StartHTTPServer(); 609 HTTPTestServer* server = StartHTTPServer();
621 610
622 // First we navigate to any page. 611 // First we navigate to any page.
623 GURL url = server->TestServerPageW(kSimplePage); 612 GURL url = server->TestServerPageW(kSimplePage);
624 ui_test_utils::NavigateToURL(browser(), url); 613 ui_test_utils::NavigateToURL(browser(), url);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 // Find "given". 785 // Find "given".
797 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal); 786 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal);
798 787
799 // Switch back to first tab. 788 // Switch back to first tab.
800 browser()->SelectTabContentsAt(0, false); 789 browser()->SelectTabContentsAt(0, false);
801 browser()->GetFindBarController()->EndFindSession(); 790 browser()->GetFindBarController()->EndFindSession();
802 // Simulate F3. 791 // Simulate F3.
803 ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal); 792 ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal);
804 EXPECT_EQ(tab1->find_text(), WideToUTF16(L"Default")); 793 EXPECT_EQ(tab1->find_text(), WideToUTF16(L"Default"));
805 } 794 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/find_in_page/move_if_obscuring.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698