summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-25 22:10:37 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-25 22:10:37 +0000
commitc62b56cde3acdd5d16896795739d7ce894c6e1a7 (patch)
tree1688a190c976011d51e2b06c947504510c3cde23 /chrome
parent96cddc36d4f3d2e785da49757514f2691d914c59 (diff)
downloadchromium_src-c62b56cde3acdd5d16896795739d7ce894c6e1a7.zip
chromium_src-c62b56cde3acdd5d16896795739d7ce894c6e1a7.tar.gz
chromium_src-c62b56cde3acdd5d16896795739d7ce894c6e1a7.tar.bz2
Create a unit test for making sure constrined popup windows close when their X is clicked. Currently this unit test fails. It should.
BUGS=1341975 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/constrained_window_impl_interactive_uitest.cc58
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);
+}