OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/panels/base_panel_browser_test.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 void MockAutoHidingDesktopBarImpl::NotifyVisibilityChange( | 140 void MockAutoHidingDesktopBarImpl::NotifyVisibilityChange( |
141 AutoHidingDesktopBar::Alignment alignment, | 141 AutoHidingDesktopBar::Alignment alignment, |
142 AutoHidingDesktopBar::Visibility visibility) { | 142 AutoHidingDesktopBar::Visibility visibility) { |
143 observer_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); | 143 observer_->OnAutoHidingDesktopBarVisibilityChanged(alignment, visibility); |
144 } | 144 } |
145 | 145 |
146 void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { | 146 void MockAutoHidingDesktopBarImpl::NotifyThicknessChange() { |
147 observer_->OnAutoHidingDesktopBarThicknessChanged(); | 147 observer_->OnAutoHidingDesktopBarThicknessChanged(); |
148 } | 148 } |
149 | 149 |
150 bool ExistsPanel(Panel* panel) { | |
151 const PanelManager::Panels& panels = PanelManager::GetInstance()->panels(); | |
152 return find(panels.begin(), panels.end(), panel) != panels.end(); | |
153 } | |
154 | |
150 } // namespace | 155 } // namespace |
151 | 156 |
152 BasePanelBrowserTest::BasePanelBrowserTest() | 157 BasePanelBrowserTest::BasePanelBrowserTest() |
153 : InProcessBrowserTest(), | 158 : InProcessBrowserTest(), |
154 testing_work_area_(0, 0, kTestingWorkAreaWidth, | 159 testing_work_area_(0, 0, kTestingWorkAreaWidth, |
155 kTestingWorkAreaHeight) { | 160 kTestingWorkAreaHeight) { |
156 #if defined(OS_MACOSX) | 161 #if defined(OS_MACOSX) |
157 FindBarBridge::disable_animations_during_testing_ = true; | 162 FindBarBridge::disable_animations_during_testing_ = true; |
158 #endif | 163 #endif |
159 } | 164 } |
160 | 165 |
161 BasePanelBrowserTest::~BasePanelBrowserTest() { | 166 BasePanelBrowserTest::~BasePanelBrowserTest() { |
162 } | 167 } |
163 | 168 |
164 void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 169 void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
165 EnableDOMAutomation(); | 170 EnableDOMAutomation(); |
166 } | 171 } |
167 | 172 |
168 void BasePanelBrowserTest::SetUpOnMainThread() { | 173 void BasePanelBrowserTest::SetUpOnMainThread() { |
169 InProcessBrowserTest::SetUpOnMainThread(); | 174 InProcessBrowserTest::SetUpOnMainThread(); |
170 | 175 |
171 // Setup the work area and desktop bar so that we have consistent testing | 176 // Setup the work area and desktop bar so that we have consistent testing |
172 // environment for all panel related tests. | 177 // environment for all panel related tests. |
173 PanelManager* panel_manager = PanelManager::GetInstance(); | 178 PanelManager* panel_manager = PanelManager::GetInstance(); |
174 mock_auto_hiding_desktop_bar_ = new MockAutoHidingDesktopBarImpl( | 179 mock_auto_hiding_desktop_bar_ = new MockAutoHidingDesktopBarImpl( |
175 panel_manager); | 180 panel_manager); |
176 panel_manager->set_auto_hiding_desktop_bar(mock_auto_hiding_desktop_bar_); | 181 panel_manager->set_auto_hiding_desktop_bar(mock_auto_hiding_desktop_bar_); |
177 panel_manager->SetWorkAreaForTesting(testing_work_area_); | 182 // Do not use the testing work area if it is empty since we're going to |
183 // use the actual work area in some testing scenarios. | |
184 if (!testing_work_area_.IsEmpty()) | |
185 panel_manager->SetWorkAreaForTesting(testing_work_area_); | |
178 panel_manager->enable_auto_sizing(false); | 186 panel_manager->enable_auto_sizing(false); |
179 panel_manager->remove_delays_for_testing(); | 187 panel_manager->remove_delays_for_testing(); |
180 // This is needed so the subsequently created panels can be activated. | 188 // This is needed so the subsequently created panels can be activated. |
181 // On a Mac, it transforms background-only test process into foreground one. | 189 // On a Mac, it transforms background-only test process into foreground one. |
182 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 190 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
183 } | 191 } |
184 | 192 |
193 void BasePanelBrowserTest::WaitForPanelAdded(Panel* panel) { | |
194 if (ExistsPanel(panel)) | |
195 return; | |
196 ui_test_utils::WindowedNotificationObserver signal( | |
jennb
2011/11/11 23:02:43
Should create the signal first, then do the 'if (E
| |
197 chrome::NOTIFICATION_PANEL_ADDED, | |
198 content::Source<Panel>(panel)); | |
199 signal.Wait(); | |
200 EXPECT_TRUE(ExistsPanel(panel)); | |
201 } | |
202 | |
203 void BasePanelBrowserTest::WaitForPanelRemoved(Panel* panel) { | |
204 if (!ExistsPanel(panel)) | |
205 return; | |
206 ui_test_utils::WindowedNotificationObserver signal( | |
207 chrome::NOTIFICATION_PANEL_REMOVED, | |
208 content::Source<Panel>(panel)); | |
209 signal.Wait(); | |
210 EXPECT_FALSE(ExistsPanel(panel)); | |
211 } | |
212 | |
185 void BasePanelBrowserTest::WaitForPanelActiveState( | 213 void BasePanelBrowserTest::WaitForPanelActiveState( |
186 Panel* panel, ActiveState expected_state) { | 214 Panel* panel, ActiveState expected_state) { |
187 DCHECK(expected_state == SHOW_AS_ACTIVE || | 215 DCHECK(expected_state == SHOW_AS_ACTIVE || |
188 expected_state == SHOW_AS_INACTIVE); | 216 expected_state == SHOW_AS_INACTIVE); |
189 ui_test_utils::WindowedNotificationObserver signal( | 217 ui_test_utils::WindowedNotificationObserver signal( |
190 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 218 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
191 content::Source<Panel>(panel)); | 219 content::Source<Panel>(panel)); |
192 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) | 220 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) |
193 return; // Already in required state. | 221 return; // Already in required state. |
194 signal.Wait(); | 222 signal.Wait(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 std::string error; | 353 std::string error; |
326 scoped_refptr<Extension> extension = Extension::Create( | 354 scoped_refptr<Extension> extension = Extension::Create( |
327 full_path, location, *input_value, | 355 full_path, location, *input_value, |
328 Extension::STRICT_ERROR_CHECKS, &error); | 356 Extension::STRICT_ERROR_CHECKS, &error); |
329 EXPECT_TRUE(extension.get()); | 357 EXPECT_TRUE(extension.get()); |
330 EXPECT_STREQ("", error.c_str()); | 358 EXPECT_STREQ("", error.c_str()); |
331 browser()->GetProfile()->GetExtensionService()-> | 359 browser()->GetProfile()->GetExtensionService()-> |
332 OnExtensionInstalled(extension.get(), false, -1); | 360 OnExtensionInstalled(extension.get(), false, -1); |
333 return extension; | 361 return extension; |
334 } | 362 } |
OLD | NEW |