diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 01:27:51 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 01:27:51 +0000 |
commit | 73333786fdb1f3b9fb5b4a8d2afda653b0e648c2 (patch) | |
tree | aaede316d84f6264dc705b1577031895fa065941 /chrome/browser/extensions/browser_action_apitest.cc | |
parent | 098267f02562f5636c4e7dd6fc4c52175862cf94 (diff) | |
download | chromium_src-73333786fdb1f3b9fb5b4a8d2afda653b0e648c2.zip chromium_src-73333786fdb1f3b9fb5b4a8d2afda653b0e648c2.tar.gz chromium_src-73333786fdb1f3b9fb5b4a8d2afda653b0e648c2.tar.bz2 |
[Mac] Port browser action popup test to mac.
BUG=29710
TEST=none
Review URL: http://codereview.chromium.org/506069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/browser_action_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/browser_action_apitest.cc | 89 |
1 files changed, 35 insertions, 54 deletions
diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc index 1713b23..0ef8f9b 100644 --- a/chrome/browser/extensions/browser_action_apitest.cc +++ b/chrome/browser/extensions/browser_action_apitest.cc @@ -8,6 +8,8 @@ #include <gtk/gtk.h> #endif +#include "base/gfx/rect.h" +#include "base/gfx/size.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/extensions/browser_action_test_util.h" @@ -20,20 +22,26 @@ #include "chrome/common/extensions/extension_action.h" #include "chrome/test/ui_test_utils.h" -#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) -#include "chrome/browser/views/browser_actions_container.h" -#include "chrome/browser/views/extensions/extension_popup.h" -#include "chrome/browser/views/toolbar_view.h" -#endif - class BrowserActionApiTest : public ExtensionApiTest { public: BrowserActionApiTest() {} virtual ~BrowserActionApiTest() {} + protected: BrowserActionTestUtil GetBrowserActionsBar() { return BrowserActionTestUtil(browser()); } + +// TODO(estade): http://crbug.com/29710 port to Linux +#if !defined(TOOLKIT_GTK) + gfx::Rect OpenPopup(int index) { + ResultCatcher catcher; + GetBrowserActionsBar().Press(index); + EXPECT_TRUE(GetBrowserActionsBar().HasPopup()); + EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); + return GetBrowserActionsBar().GetPopupBounds(); + } +#endif // !defined(TOOLKIT_GTK) }; IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, Basic) { @@ -133,63 +141,36 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TabSpecificBrowserActionState) { EXPECT_EQ("hi!", GetBrowserActionsBar().GetTooltip(0)); } -// TODO(estade): http://crbug.com/29710 port to Mac & Linux -#if defined(OS_WIN) +// TODO(estade): http://crbug.com/29710 port to Linux +#if !defined(TOOLKIT_GTK) IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopup) { ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( "browser_action/popup"))); ResultCatcher catcher; - // This value is in api_test/popup/popup.html. + // The extension's popup's size grows by |growFactor| each click. 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; - - BrowserActionsContainer* browser_actions = - browser()->window()->GetBrowserWindowTesting()->GetToolbarView()-> - browser_actions(); - ASSERT_TRUE(browser_actions); + gfx::Size minSize = BrowserActionTestUtil::GetMinPopupSize(); + gfx::Size maxSize = BrowserActionTestUtil::GetMaxPopupSize(); + + // Ensure that two clicks will exceed the maximum allowed size. + ASSERT_GT(minSize.height() + growFactor * 2, maxSize.height()); + ASSERT_GT(minSize.width() + growFactor * 2, maxSize.width()); + // Simulate a click on the browser action and verify the size of the resulting // popup. The first one tries to be 0x0, so it should be the min values. - GetBrowserActionsBar().Press(0); - EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); - ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); - gfx::Rect 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); - - // 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); + gfx::Rect bounds = OpenPopup(0); + EXPECT_EQ(minSize, bounds.size()); + EXPECT_TRUE(GetBrowserActionsBar().HidePopup()); + + bounds = OpenPopup(0); + EXPECT_EQ(gfx::Size(growFactor, growFactor), bounds.size()); + EXPECT_TRUE(GetBrowserActionsBar().HidePopup()); // 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(width, bounds.width()); - EXPECT_EQ(height, bounds.height()); - browser_actions->HidePopup(); - EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); + bounds = OpenPopup(0); + EXPECT_EQ(maxSize, bounds.size()); + EXPECT_TRUE(GetBrowserActionsBar().HidePopup()); } -#endif // defined(OS_WIN) +#endif // !defined(TOOLKIT_GTK) |