summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/browser_action_apitest.cc
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-28 16:18:21 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-28 16:18:21 +0000
commitd661abbc4db855ee738d94855006fb45f2d97726 (patch)
treeff0597b3e68f7d8d2721d32f584fa041a5cfd853 /chrome/browser/extensions/browser_action_apitest.cc
parentd0b6c6f6ae1c3c1cedb888a17363a47e92a32033 (diff)
downloadchromium_src-d661abbc4db855ee738d94855006fb45f2d97726.zip
chromium_src-d661abbc4db855ee738d94855006fb45f2d97726.tar.gz
chromium_src-d661abbc4db855ee738d94855006fb45f2d97726.tar.bz2
Constrain extension popups to a min/max size.
Also, fix some glitches in sizing the popups. BUG=25214 TEST=ExtensionApiTest.BrowserActionPopup Review URL: http://codereview.chromium.org/295051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30346 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/browser_action_apitest.cc')
-rw-r--r--chrome/browser/extensions/browser_action_apitest.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc
index a5bd470..d542c43 100644
--- a/chrome/browser/extensions/browser_action_apitest.cc
+++ b/chrome/browser/extensions/browser_action_apitest.cc
@@ -149,25 +149,50 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_BrowserActionPopup) {
browser()->window()->GetBrowserWindowTesting()->GetToolbarView()->
browser_actions();
+ // This value is in api_test/popup/popup.html.
+ const int growFactor = 500;
+ ASSERT_GT(ExtensionPopup::kMinHeight + growFactor * 2,
+ ExtensionPopup::kMaxHeight);
+ ASSERT_GT(ExtensionPopup::kMinWidth + growFactor * 2,
+ ExtensionPopup::kMaxWidth);
+
+ // Our initial expected size.
+ int width = ExtensionPopup::kMinWidth;
+ int height = ExtensionPopup::kMinHeight;
+
// Simulate a click on the browser action and verify the size of the resulting
- // popup.
+ // popup. The first one tries to be 0x0, so it should be the min values.
browser_actions->TestExecuteBrowserAction(0);
EXPECT_TRUE(browser_actions->TestGetPopup() != NULL);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
gfx::Rect bounds = browser_actions->TestGetPopup()->view()->bounds();
- EXPECT_EQ(100, bounds.width());
- EXPECT_EQ(100, bounds.height());
+ EXPECT_EQ(width, bounds.width());
+ EXPECT_EQ(height, bounds.height());
browser_actions->HidePopup();
EXPECT_TRUE(browser_actions->TestGetPopup() == NULL);
// Do it again, and verify the new bigger size (the popup grows each time it's
// opened).
+ width = growFactor;
+ height = growFactor;
+ browser_actions->TestExecuteBrowserAction(0);
+ EXPECT_TRUE(browser_actions->TestGetPopup() != NULL);
+ ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
+ bounds = browser_actions->TestGetPopup()->view()->bounds();
+ EXPECT_EQ(width, bounds.width());
+ EXPECT_EQ(height, bounds.height());
+ browser_actions->HidePopup();
+ EXPECT_TRUE(browser_actions->TestGetPopup() == NULL);
+
+ // One more time, but this time it should be constrained by the max values.
+ width = ExtensionPopup::kMaxWidth;
+ height = ExtensionPopup::kMaxHeight;
browser_actions->TestExecuteBrowserAction(0);
EXPECT_TRUE(browser_actions->TestGetPopup() != NULL);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
bounds = browser_actions->TestGetPopup()->view()->bounds();
- EXPECT_EQ(200, bounds.width());
- EXPECT_EQ(200, bounds.height());
+ EXPECT_EQ(width, bounds.width());
+ EXPECT_EQ(height, bounds.height());
browser_actions->HidePopup();
EXPECT_TRUE(browser_actions->TestGetPopup() == NULL);
}