OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.h" |
6 #include "chrome/browser/browser_window.h" | 6 #include "chrome/browser/browser_window.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_browser_event_router.h" | 8 #include "chrome/browser/extensions/extension_browser_event_router.h" |
9 #include "chrome/browser/extensions/extension_tabs_module.h" | 9 #include "chrome/browser/extensions/extension_tabs_module.h" |
10 #include "chrome/browser/extensions/extensions_service.h" | 10 #include "chrome/browser/extensions/extensions_service.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 } | 98 } |
99 | 99 |
100 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserActionPopup) { | 100 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserActionPopup) { |
101 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("popup"))); | 101 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("popup"))); |
102 | 102 |
103 ResultCatcher catcher; | 103 ResultCatcher catcher; |
104 BrowserActionsContainer* browser_actions = | 104 BrowserActionsContainer* browser_actions = |
105 browser()->window()->GetBrowserWindowTesting()->GetToolbarView()-> | 105 browser()->window()->GetBrowserWindowTesting()->GetToolbarView()-> |
106 browser_actions(); | 106 browser_actions(); |
107 | 107 |
108 // This value is in api_test/popup/popup.html. | |
109 const int growFactor = 500; | |
110 ASSERT_GT(ExtensionPopup::kMinHeight + growFactor * 2, | |
Matt Perry
2009/10/22 00:16:19
I think you mean just growFactor*2 here.
| |
111 ExtensionPopup::kMaxHeight); | |
112 ASSERT_GT(ExtensionPopup::kMinWidth + growFactor * 2, | |
113 ExtensionPopup::kMaxWidth); | |
114 | |
115 // Our initial expected size. | |
116 int width = ExtensionPopup::kMinWidth; | |
117 int height = ExtensionPopup::kMinHeight; | |
118 | |
108 // Simulate a click on the browser action and verify the size of the resulting | 119 // Simulate a click on the browser action and verify the size of the resulting |
109 // popup. | 120 // popup. The first one tries to be 0x0, so it should be the min values. |
110 browser_actions->TestExecuteBrowserAction(0); | 121 browser_actions->TestExecuteBrowserAction(0); |
111 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); | 122 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); |
112 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 123 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
113 gfx::Rect bounds = browser_actions->TestGetPopup()->view()->bounds(); | 124 gfx::Rect bounds = browser_actions->TestGetPopup()->view()->bounds(); |
114 EXPECT_EQ(100, bounds.width()); | 125 EXPECT_EQ(width, bounds.width()); |
115 EXPECT_EQ(100, bounds.height()); | 126 EXPECT_EQ(height, bounds.height()); |
116 browser_actions->HidePopup(); | 127 browser_actions->HidePopup(); |
117 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); | 128 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); |
118 | 129 |
119 // Do it again, and verify the new bigger size (the popup grows each time it's | 130 // Do it again, and verify the new bigger size (the popup grows each time it's |
120 // opened). | 131 // opened). |
132 width = growFactor; | |
133 height = growFactor; | |
121 browser_actions->TestExecuteBrowserAction(0); | 134 browser_actions->TestExecuteBrowserAction(0); |
122 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); | 135 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); |
123 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 136 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
124 bounds = browser_actions->TestGetPopup()->view()->bounds(); | 137 bounds = browser_actions->TestGetPopup()->view()->bounds(); |
125 EXPECT_EQ(200, bounds.width()); | 138 EXPECT_EQ(width, bounds.width()); |
126 EXPECT_EQ(200, bounds.height()); | 139 EXPECT_EQ(height, bounds.height()); |
140 browser_actions->HidePopup(); | |
141 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); | |
142 | |
143 // One more time, but this time it should be constrained by the max values. | |
144 width = ExtensionPopup::kMaxWidth; | |
145 height = ExtensionPopup::kMaxHeight; | |
146 browser_actions->TestExecuteBrowserAction(0); | |
147 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); | |
148 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
149 bounds = browser_actions->TestGetPopup()->view()->bounds(); | |
150 EXPECT_EQ(width, bounds.width()); | |
151 EXPECT_EQ(height, bounds.height()); | |
127 browser_actions->HidePopup(); | 152 browser_actions->HidePopup(); |
128 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); | 153 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); |
129 } | 154 } |
OLD | NEW |