Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1440)

Unified Diff: chrome/browser/extensions/browser_action_apitest.cc

Issue 295051: Constrain extension popups to a min/max size (Closed)
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/views/browser_bubble.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/browser_action_apitest.cc
diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc
index 13b73d8694d04f8914fff8e770e963e0646b1a1b..4128da1c2df293a3b7a43dab63a4f04d9d8401e7 100644
--- a/chrome/browser/extensions/browser_action_apitest.cc
+++ b/chrome/browser/extensions/browser_action_apitest.cc
@@ -105,25 +105,50 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, 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,
Matt Perry 2009/10/22 00:16:19 I think you mean just growFactor*2 here.
+ 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);
}
« no previous file with comments | « no previous file | chrome/browser/views/browser_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698