Chromium Code Reviews| Index: chrome/browser/views/find_bar_host_browsertest.cc |
| =================================================================== |
| --- chrome/browser/views/find_bar_host_browsertest.cc (revision 36660) |
| +++ chrome/browser/views/find_bar_host_browsertest.cc (working copy) |
| @@ -572,46 +572,35 @@ |
| EXPECT_TRUE(GetFindBarWindowInfo(&start_position, &fully_visible)); |
| EXPECT_TRUE(fully_visible); |
| - // Search for 'dream' which the Find box is obscuring. |
| + // Search for 'Chromium' which the Find box is obscuring. |
| int ordinal = 0; |
| TabContents* tab = browser()->GetSelectedTabContents(); |
| - EXPECT_EQ(1, FindInPageWchar(tab, L"dream", |
| - kFwd, kIgnoreCase, &ordinal)); |
| - EXPECT_EQ(1, ordinal); |
| + int index = 0; |
| + for (; index < 30; ++index) { |
|
Paweł Hajdan Jr.
2010/01/21 20:41:55
nit: Could you make 30 a constant (kIterations)?
|
| + EXPECT_EQ(30, FindInPageWchar(tab, L"Chromium", |
| + kFwd, kIgnoreCase, &ordinal)); |
| - // Make sure Find box has moved. |
| - EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| - EXPECT_TRUE(fully_visible); |
| - EXPECT_EQ(start_position.y(), position.y()); |
| - if (start_position.x() == position.x()) { |
| - // Failure case. Try to gather more data. |
| - std::string debug_msg = "Position check failed once. "; |
| + // Check the position. |
| + EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| + EXPECT_TRUE(fully_visible); |
| - // First see if flushing the message loop has any effect. |
| - MessageLoop::current()->RunAllPending(); |
| - |
| - if (!GetFindBarWindowInfo(&position, &fully_visible)) { |
| - debug_msg += "Get failed. "; |
| - } else { |
| - if (start_position.x() == position.x()) |
| - debug_msg += "Position check failed again. "; |
| - else |
| - debug_msg += "They now differ. "; |
| - } |
| - // Force the failure. |
| - EXPECT_STREQ("", debug_msg.c_str()); |
| + // If the Find box has moved then we are done. |
| + if (position.x() != start_position.x()) |
| + break; |
| } |
| - EXPECT_NE(start_position.x(), position.x()); |
| - // Search for 'Too much' which the Find box is not obscuring. |
| - EXPECT_EQ(1, FindInPageWchar(tab, L"Too much", |
| - kFwd, kIgnoreCase, &ordinal)); |
| - EXPECT_EQ(1, ordinal); |
| + // We should not have reached the end. |
| + ASSERT_GT(30, index); |
| - // Make sure Find box has moved back to its original location. |
| + // Search backwards once to get the Find box to move back. |
| + EXPECT_EQ(30, FindInPageWchar(tab, L"Chromium", |
| + kBack, kIgnoreCase, &ordinal)); |
| + // Check the position. |
| EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| EXPECT_TRUE(fully_visible); |
| - EXPECT_EQ(start_position, position); |
| + |
| + // Make sure Find box has moved back to its original location. |
| + EXPECT_EQ(position.x(), start_position.x()); |
| } |
| // Make sure F3 in a new tab works if Find has previous string to search for. |