Index: chrome/browser/history/redirect_uitest.cc |
=================================================================== |
--- chrome/browser/history/redirect_uitest.cc (revision 56644) |
+++ chrome/browser/history/redirect_uitest.cc (working copy) |
@@ -13,10 +13,14 @@ |
#include "base/string_util.h" |
#include "base/string16.h" |
#include "base/utf_string_conversions.h" |
+#include "chrome/browser/view_ids.h" |
+#include "chrome/test/automation/browser_proxy.h" |
#include "chrome/test/automation/tab_proxy.h" |
+#include "chrome/test/automation/window_proxy.h" |
#include "chrome/test/ui/ui_test.h" |
#include "net/base/net_util.h" |
#include "net/test/test_server.h" |
+#include "views/event.h" |
namespace { |
@@ -105,6 +109,8 @@ |
// Tests to make sure a location change when a pending redirect exists isn't |
// flagged as a redirect. |
+#if defined(OS_WIN) || defined(OS_LINUX) |
+// SimulateOSClick is broken on the Mac: http://crbug.com/45162 |
TEST_F(RedirectTest, ClientCancelled) { |
FilePath first_path(test_data_directory_); |
first_path = first_path.AppendASCII("cancelled_redirect_test.html"); |
@@ -113,10 +119,26 @@ |
NavigateToURLBlockUntilNavigationsComplete(first_url, 1); |
- NavigateToURL(GURL("javascript:click()")); // User initiated location change. |
- |
+ scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); |
+ ASSERT_TRUE(browser.get()); |
+ scoped_refptr<WindowProxy> window = browser->GetWindow(); |
+ ASSERT_TRUE(window.get()); |
scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
ASSERT_TRUE(tab_proxy.get()); |
+ int64 last_nav_time = 0; |
+ EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&last_nav_time)); |
+ // Simulate a click to force to make a user-initiated location change; |
+ // otherwise, a non user-initiated in-page location change will be treated |
+ // as client redirect and the redirect will be recoreded, which can cause |
+ // this test failed. |
+ gfx::Rect tab_view_bounds; |
+ ASSERT_TRUE(browser->BringToFront()); |
+ ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, |
+ true)); |
+ ASSERT_TRUE( |
+ window->SimulateOSClick(tab_view_bounds.CenterPoint(), |
+ views::Event::EF_LEFT_BUTTON_DOWN)); |
+ EXPECT_TRUE(tab_proxy->WaitForNavigation(last_nav_time)); |
std::vector<GURL> redirects; |
ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); |
@@ -140,6 +162,7 @@ |
StringToLowerASCII(current_path.value())); |
EXPECT_EQ(final_ref, current_url.ref()); |
} |
+#endif |
// Tests a client->server->server redirect |
TEST_F(RedirectTest, ClientServerServer) { |