diff options
-rw-r--r-- | chrome/browser/views/constrained_window_impl_interactive_uitest.cc | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc index 999ada1..3674403 100644 --- a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc +++ b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc @@ -15,6 +15,9 @@ #include "chrome/views/event.h" #include "net/base/net_util.h" +const int kRightCloseButtonOffset = 55; +const int kBottomCloseButtonOffset = 25; + class InteractiveConstrainedWindowTest : public UITest { protected: InteractiveConstrainedWindowTest() { @@ -72,8 +75,8 @@ TEST_F(InteractiveConstrainedWindowTest, TestOpenAndResizeTo) { ASSERT_TRUE(popup_window->SimulateOSClick( popup_link_point, ChromeViews::Event::EF_LEFT_BUTTON_DOWN)); - // No idea how to wait here other then sleeping. This timeout used to be lower, - // then we started hitting it before it was done. :( + // No idea how to wait here other then sleeping. This timeout used to be + // lower, then we started hitting it before it was done. :( Sleep(5000); // The actual content will be LESS than (200, 200) because resizeTo @@ -87,3 +90,54 @@ TEST_F(InteractiveConstrainedWindowTest, TestOpenAndResizeTo) { ASSERT_LT(rect.height(), 200); } +TEST_F(InteractiveConstrainedWindowTest, ClickingXClosesConstrained) { + // Clicking X on a constrained window should close the window instead of + // unconstrain it. + scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + scoped_ptr<WindowProxy> window( + automation()->GetWindowForBrowser(browser.get())); + ASSERT_TRUE(window.get()); + + scoped_ptr<TabProxy> tab(browser->GetTab(0)); + ASSERT_TRUE(tab.get()); + + std::wstring filename(test_data_directory_); + file_util::AppendToPath(&filename, L"constrained_files"); + file_util::AppendToPath(&filename, + L"constrained_window.html"); + ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); + + // Wait for the animation to finish. + Sleep(1000); + + // Calculate the center of the "X" + gfx::Rect tab_view_bounds; + ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, + &tab_view_bounds, true)); + gfx::Point constrained_close_button; + constrained_close_button.set_x( + tab_view_bounds.x() + tab_view_bounds.width() - kRightCloseButtonOffset); + constrained_close_button.set_y( + tab_view_bounds.y() + tab_view_bounds.height() - + kBottomCloseButtonOffset); + + // Click that X. + POINT click_point(constrained_close_button.ToPOINT()); + ASSERT_TRUE(window->SimulateOSClick(click_point, + ChromeViews::Event::EF_LEFT_BUTTON_DOWN)); + + // Check that there is only one constrained window. (There would have been + // two pre-click). + int constrained_window_count; + EXPECT_TRUE(tab->WaitForChildWindowCountToChange( + 2, &constrained_window_count, 5000)); + EXPECT_EQ(constrained_window_count, 1); + + // Check that there is still only one window (so we know we didn't activate + // the constrained popup.) + int browser_window_count; + EXPECT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count)); + EXPECT_EQ(browser_window_count, 1); +} |