| 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/string16.h" | 6 #include "base/string16.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); | 743 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); |
| 744 | 744 |
| 745 int moved_x_coord = FindInPageTillBoxMoves(tab, start_position.x(), | 745 int moved_x_coord = FindInPageTillBoxMoves(tab, start_position.x(), |
| 746 L"Chromium", kMoveIterations); | 746 L"Chromium", kMoveIterations); |
| 747 // The find box should have moved. | 747 // The find box should have moved. |
| 748 EXPECT_TRUE(moved_x_coord != start_position.x()); | 748 EXPECT_TRUE(moved_x_coord != start_position.x()); |
| 749 | 749 |
| 750 // Search for something guaranteed not to be obscured by the Find box. | 750 // Search for something guaranteed not to be obscured by the Find box. |
| 751 EXPECT_EQ(1, FindInPageWchar(tab, L"Done", | 751 EXPECT_EQ(1, FindInPageWchar(tab, L"Done", |
| 752 kFwd, kIgnoreCase, &ordinal)); | 752 kFwd, kIgnoreCase, &ordinal)); |
| 753 |
| 754 // Drain MessageLoop so that find bar position settles. |
| 755 ui_test_utils::RunAllPendingInMessageLoop(); |
| 756 |
| 753 // Check the position. | 757 // Check the position. |
| 754 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 758 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 755 EXPECT_TRUE(fully_visible); | 759 EXPECT_TRUE(fully_visible); |
| 756 | 760 |
| 757 // Make sure Find box has moved back to its original location. | 761 // Make sure Find box has moved back to its original location. |
| 758 EXPECT_EQ(position.x(), start_position.x()); | 762 EXPECT_EQ(position.x(), start_position.x()); |
| 759 | 763 |
| 760 // Move the find box again. | 764 // Move the find box again. |
| 761 moved_x_coord = FindInPageTillBoxMoves(tab, start_position.x(), | 765 moved_x_coord = FindInPageTillBoxMoves(tab, start_position.x(), |
| 762 L"Chromium", kMoveIterations); | 766 L"Chromium", kMoveIterations); |
| 763 EXPECT_TRUE(moved_x_coord != start_position.x()); | 767 EXPECT_TRUE(moved_x_coord != start_position.x()); |
| 764 | 768 |
| 765 // Search for an invalid string. | 769 // Search for an invalid string. |
| 766 EXPECT_EQ(0, FindInPageWchar(tab, L"WeirdSearchString", | 770 EXPECT_EQ(0, FindInPageWchar(tab, L"WeirdSearchString", |
| 767 kFwd, kIgnoreCase, &ordinal)); | 771 kFwd, kIgnoreCase, &ordinal)); |
| 768 | 772 |
| 773 // Drain MessageLoop so that find bar position settles. |
| 774 ui_test_utils::RunAllPendingInMessageLoop(); |
| 775 |
| 769 // Check the position. | 776 // Check the position. |
| 770 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 777 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 771 EXPECT_TRUE(fully_visible); | 778 EXPECT_TRUE(fully_visible); |
| 772 | 779 |
| 773 // Make sure Find box has moved back to its original location. | 780 // Make sure Find box has moved back to its original location. |
| 774 EXPECT_EQ(position.x(), start_position.x()); | 781 EXPECT_EQ(position.x(), start_position.x()); |
| 775 } | 782 } |
| 776 | 783 |
| 777 #if defined(OS_MACOSX) | 784 #if defined(OS_MACOSX) |
| 778 // FindNextInNewTabUsesPrepopulate times-out, at least on Mac. | 785 // FindNextInNewTabUsesPrepopulate times-out, at least on Mac. |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 ui_test_utils::RunAllPendingInMessageLoop(); // Needed on Linux. | 1251 ui_test_utils::RunAllPendingInMessageLoop(); // Needed on Linux. |
| 1245 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); | 1252 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); |
| 1246 | 1253 |
| 1247 ui_test_utils::NavigateToURLWithDisposition( | 1254 ui_test_utils::NavigateToURLWithDisposition( |
| 1248 browser(), url, NEW_FOREGROUND_TAB, | 1255 browser(), url, NEW_FOREGROUND_TAB, |
| 1249 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1256 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 1250 browser()->CloseTab(); | 1257 browser()->CloseTab(); |
| 1251 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); | 1258 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); |
| 1252 EXPECT_EQ(position, position2); | 1259 EXPECT_EQ(position, position2); |
| 1253 } | 1260 } |
| OLD | NEW |