OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/old_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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const gfx::Rect kTestingPrimaryScreenArea = gfx::Rect(0, 0, 800, 600); | 48 const gfx::Rect kTestingPrimaryScreenArea = gfx::Rect(0, 0, 800, 600); |
49 const gfx::Rect kTestingWorkArea = gfx::Rect(0, 0, 800, 580); | 49 const gfx::Rect kTestingWorkArea = gfx::Rect(0, 0, 800, 580); |
50 | 50 |
51 struct MockDesktopBar { | 51 struct MockDesktopBar { |
52 bool auto_hiding_enabled; | 52 bool auto_hiding_enabled; |
53 DisplaySettingsProvider::DesktopBarVisibility visibility; | 53 DisplaySettingsProvider::DesktopBarVisibility visibility; |
54 int thickness; | 54 int thickness; |
55 }; | 55 }; |
56 | 56 |
57 class MockDisplaySettingsProviderImpl : | 57 class MockDisplaySettingsProviderImpl : |
58 public OldBasePanelBrowserTest::MockDisplaySettingsProvider { | 58 public BasePanelBrowserTest::MockDisplaySettingsProvider { |
59 public: | 59 public: |
60 explicit MockDisplaySettingsProviderImpl(PanelManager* panel_manager); | 60 explicit MockDisplaySettingsProviderImpl(PanelManager* panel_manager); |
61 virtual ~MockDisplaySettingsProviderImpl() { } | 61 virtual ~MockDisplaySettingsProviderImpl() { } |
62 | 62 |
63 // Overridden from DisplaySettingsProvider: | 63 // Overridden from DisplaySettingsProvider: |
64 virtual gfx::Rect GetPrimaryScreenArea() const OVERRIDE; | 64 virtual gfx::Rect GetPrimaryScreenArea() const OVERRIDE; |
65 virtual gfx::Rect GetWorkArea() const OVERRIDE; | 65 virtual gfx::Rect GetWorkArea() const OVERRIDE; |
66 virtual bool IsAutoHidingDesktopBarEnabled( | 66 virtual bool IsAutoHidingDesktopBarEnabled( |
67 DesktopBarAlignment alignment) OVERRIDE; | 67 DesktopBarAlignment alignment) OVERRIDE; |
68 virtual int GetDesktopBarThickness( | 68 virtual int GetDesktopBarThickness( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 OnAutoHidingDesktopBarChanged(); | 180 OnAutoHidingDesktopBarChanged(); |
181 } | 181 } |
182 | 182 |
183 bool ExistsPanel(Panel* panel) { | 183 bool ExistsPanel(Panel* panel) { |
184 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); | 184 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
185 return std::find(panels.begin(), panels.end(), panel) != panels.end(); | 185 return std::find(panels.begin(), panels.end(), panel) != panels.end(); |
186 } | 186 } |
187 | 187 |
188 } // namespace | 188 } // namespace |
189 | 189 |
190 const FilePath::CharType* OldBasePanelBrowserTest::kTestDir = | 190 const FilePath::CharType* BasePanelBrowserTest::kTestDir = |
191 FILE_PATH_LITERAL("panels"); | 191 FILE_PATH_LITERAL("panels"); |
192 | 192 |
193 OldBasePanelBrowserTest::OldBasePanelBrowserTest() | 193 BasePanelBrowserTest::BasePanelBrowserTest() |
194 : InProcessBrowserTest(), | 194 : InProcessBrowserTest(), |
195 mock_display_settings_enabled_(true) { | 195 mock_display_settings_enabled_(true) { |
196 #if defined(OS_MACOSX) | 196 #if defined(OS_MACOSX) |
197 FindBarBridge::disable_animations_during_testing_ = true; | 197 FindBarBridge::disable_animations_during_testing_ = true; |
198 #endif | 198 #endif |
199 } | 199 } |
200 | 200 |
201 OldBasePanelBrowserTest::~OldBasePanelBrowserTest() { | 201 BasePanelBrowserTest::~BasePanelBrowserTest() { |
202 } | 202 } |
203 | 203 |
204 bool OldBasePanelBrowserTest::SkipTestIfIceWM() { | 204 bool BasePanelBrowserTest::SkipTestIfIceWM() { |
205 #if defined(OS_LINUX) | 205 #if defined(OS_LINUX) |
206 return ui::GuessWindowManager() == ui::WM_ICE_WM; | 206 return ui::GuessWindowManager() == ui::WM_ICE_WM; |
207 #else | 207 #else |
208 return false; | 208 return false; |
209 #endif | 209 #endif |
210 } | 210 } |
211 | 211 |
212 bool OldBasePanelBrowserTest::SkipTestIfCompizWM() { | 212 bool BasePanelBrowserTest::SkipTestIfCompizWM() { |
213 #if defined(OS_LINUX) | 213 #if defined(OS_LINUX) |
214 return ui::GuessWindowManager() == ui::WM_COMPIZ; | 214 return ui::GuessWindowManager() == ui::WM_COMPIZ; |
215 #else | 215 #else |
216 return false; | 216 return false; |
217 #endif | 217 #endif |
218 } | 218 } |
219 | 219 |
220 void OldBasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 220 void BasePanelBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
221 EnableDOMAutomation(); | 221 EnableDOMAutomation(); |
222 command_line->AppendSwitch(switches::kEnablePanels); | 222 command_line->AppendSwitch(switches::kEnablePanels); |
223 } | 223 } |
224 | 224 |
225 void OldBasePanelBrowserTest::SetUpOnMainThread() { | 225 void BasePanelBrowserTest::SetUpOnMainThread() { |
226 InProcessBrowserTest::SetUpOnMainThread(); | 226 InProcessBrowserTest::SetUpOnMainThread(); |
227 | 227 |
228 // Setup the work area and desktop bar so that we have consistent testing | 228 // Setup the work area and desktop bar so that we have consistent testing |
229 // environment for all panel related tests. | 229 // environment for all panel related tests. |
230 PanelManager* panel_manager = PanelManager::GetInstance(); | 230 PanelManager* panel_manager = PanelManager::GetInstance(); |
231 if (mock_display_settings_enabled_) { | 231 if (mock_display_settings_enabled_) { |
232 mock_display_settings_provider_ = | 232 mock_display_settings_provider_ = |
233 new MockDisplaySettingsProviderImpl(panel_manager); | 233 new MockDisplaySettingsProviderImpl(panel_manager); |
234 SetTestingAreas(kTestingPrimaryScreenArea, kTestingWorkArea); | 234 SetTestingAreas(kTestingPrimaryScreenArea, kTestingWorkArea); |
235 } | 235 } |
236 | 236 |
237 panel_manager->enable_auto_sizing(false); | 237 panel_manager->enable_auto_sizing(false); |
238 | 238 |
239 PanelManager::shorten_time_intervals_for_testing(); | 239 PanelManager::shorten_time_intervals_for_testing(); |
240 | 240 |
241 // This is needed so the subsequently created panels can be activated. | 241 // This is needed so the subsequently created panels can be activated. |
242 // On a Mac, it transforms background-only test process into foreground one. | 242 // On a Mac, it transforms background-only test process into foreground one. |
243 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 243 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
244 } | 244 } |
245 | 245 |
246 void OldBasePanelBrowserTest::WaitForPanelActiveState( | 246 void BasePanelBrowserTest::WaitForPanelActiveState( |
247 Panel* panel, ActiveState expected_state) { | 247 Panel* panel, ActiveState expected_state) { |
248 DCHECK(expected_state == SHOW_AS_ACTIVE || | 248 DCHECK(expected_state == SHOW_AS_ACTIVE || |
249 expected_state == SHOW_AS_INACTIVE); | 249 expected_state == SHOW_AS_INACTIVE); |
250 ui_test_utils::WindowedNotificationObserver signal( | 250 ui_test_utils::WindowedNotificationObserver signal( |
251 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 251 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
252 content::Source<Panel>(panel)); | 252 content::Source<Panel>(panel)); |
253 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) | 253 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) |
254 return; // Already in required state. | 254 return; // Already in required state. |
255 signal.Wait(); | 255 signal.Wait(); |
256 // Verify that transition happened in the desired direction. | 256 // Verify that transition happened in the desired direction. |
257 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)); | 257 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)); |
258 } | 258 } |
259 | 259 |
260 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { | 260 void BasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { |
261 scoped_ptr<NativePanelTesting> panel_testing( | 261 scoped_ptr<NativePanelTesting> panel_testing( |
262 NativePanelTesting::Create(panel->native_panel())); | 262 NativePanelTesting::Create(panel->native_panel())); |
263 ui_test_utils::WindowedNotificationObserver signal( | 263 ui_test_utils::WindowedNotificationObserver signal( |
264 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 264 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
265 content::Source<Panel>(panel)); | 265 content::Source<Panel>(panel)); |
266 if (panel_testing->IsWindowSizeKnown()) | 266 if (panel_testing->IsWindowSizeKnown()) |
267 return; | 267 return; |
268 signal.Wait(); | 268 signal.Wait(); |
269 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); | 269 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); |
270 } | 270 } |
271 | 271 |
272 void OldBasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { | 272 void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { |
273 scoped_ptr<NativePanelTesting> panel_testing( | 273 scoped_ptr<NativePanelTesting> panel_testing( |
274 NativePanelTesting::Create(panel->native_panel())); | 274 NativePanelTesting::Create(panel->native_panel())); |
275 ui_test_utils::WindowedNotificationObserver signal( | 275 ui_test_utils::WindowedNotificationObserver signal( |
276 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 276 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
277 content::Source<Panel>(panel)); | 277 content::Source<Panel>(panel)); |
278 if (!panel_testing->IsAnimatingBounds()) | 278 if (!panel_testing->IsAnimatingBounds()) |
279 return; | 279 return; |
280 signal.Wait(); | 280 signal.Wait(); |
281 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); | 281 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); |
282 } | 282 } |
283 | 283 |
284 void OldBasePanelBrowserTest::WaitForExpansionStateChanged( | 284 void BasePanelBrowserTest::WaitForExpansionStateChanged( |
285 Panel* panel, Panel::ExpansionState expansion_state) { | 285 Panel* panel, Panel::ExpansionState expansion_state) { |
286 ui_test_utils::WindowedNotificationObserver signal( | 286 ui_test_utils::WindowedNotificationObserver signal( |
287 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, | 287 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
288 content::Source<Panel>(panel)); | 288 content::Source<Panel>(panel)); |
289 if (panel->expansion_state() == expansion_state) | 289 if (panel->expansion_state() == expansion_state) |
290 return; | 290 return; |
291 signal.Wait(); | 291 signal.Wait(); |
292 EXPECT_EQ(expansion_state, panel->expansion_state()); | 292 EXPECT_EQ(expansion_state, panel->expansion_state()); |
293 } | 293 } |
294 | 294 |
295 Panel* OldBasePanelBrowserTest::CreatePanelWithParams( | 295 Panel* BasePanelBrowserTest::CreatePanelWithParams( |
296 const CreatePanelParams& params) { | 296 const CreatePanelParams& params) { |
297 #if defined(OS_MACOSX) | 297 #if defined(OS_MACOSX) |
298 // Opening panels on a Mac causes NSWindowController of the Panel window | 298 // Opening panels on a Mac causes NSWindowController of the Panel window |
299 // to be autoreleased. We need a pool drained after it's done so the test | 299 // to be autoreleased. We need a pool drained after it's done so the test |
300 // can close correctly. The NSWindowController of the Panel window controls | 300 // can close correctly. The NSWindowController of the Panel window controls |
301 // lifetime of the Browser object so we want to release it as soon as | 301 // lifetime of the Browser object so we want to release it as soon as |
302 // possible. In real Chrome, this is done by message pump. | 302 // possible. In real Chrome, this is done by message pump. |
303 // On non-Mac platform, this is an empty class. | 303 // On non-Mac platform, this is an empty class. |
304 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 304 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
305 #endif | 305 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
323 static_cast<PanelBrowserWindow*>(panel_browser->window()); | 323 static_cast<PanelBrowserWindow*>(panel_browser->window()); |
324 Panel* panel = panel_browser_window->panel(); | 324 Panel* panel = panel_browser_window->panel(); |
325 | 325 |
326 if (!PanelManager::GetInstance()->auto_sizing_enabled() || | 326 if (!PanelManager::GetInstance()->auto_sizing_enabled() || |
327 params.bounds.width() || params.bounds.height()) { | 327 params.bounds.width() || params.bounds.height()) { |
328 EXPECT_FALSE(panel->auto_resizable()); | 328 EXPECT_FALSE(panel->auto_resizable()); |
329 } else { | 329 } else { |
330 EXPECT_TRUE(panel->auto_resizable()); | 330 EXPECT_TRUE(panel->auto_resizable()); |
331 } | 331 } |
332 | 332 |
| 333 #if defined(OS_LINUX) |
| 334 // On bots, we might have a simple window manager which always activates new |
| 335 // windows, and can't always deactivate them. Keep track of the previously |
| 336 // active window so we can activate that window back to ensure the new window |
| 337 // is inactive. |
| 338 Browser* last_active_browser_to_restore = NULL; |
| 339 if (params.expected_active_state == SHOW_AS_INACTIVE && |
| 340 ui::GuessWindowManager() == ui::WM_ICE_WM) { |
| 341 last_active_browser_to_restore = BrowserList::GetLastActive(); |
| 342 EXPECT_TRUE(last_active_browser_to_restore); |
| 343 EXPECT_NE(last_active_browser_to_restore, panel_browser); |
| 344 } |
| 345 #endif |
| 346 |
333 if (params.show_flag == SHOW_AS_ACTIVE) { | 347 if (params.show_flag == SHOW_AS_ACTIVE) { |
334 panel->Show(); | 348 panel->Show(); |
335 } else { | 349 } else { |
336 panel->ShowInactive(); | 350 panel->ShowInactive(); |
337 } | 351 } |
338 | 352 |
339 if (params.wait_for_fully_created) { | 353 if (params.wait_for_fully_created) { |
340 MessageLoopForUI::current()->RunAllPending(); | 354 MessageLoopForUI::current()->RunAllPending(); |
341 | 355 |
342 #if defined(OS_LINUX) | 356 #if defined(OS_LINUX) |
343 // On bots, we might have a simple window manager which always activates new | 357 // Restore focus where it was. It will deactivate the new panel. |
344 // windows, and can't always deactivate them. Re-activate the main tabbed | 358 if (last_active_browser_to_restore) |
345 // browser to "deactivate" the newly created panel. | 359 last_active_browser_to_restore->window()->Activate(); |
346 if (params.expected_active_state == SHOW_AS_INACTIVE && | |
347 ui::GuessWindowManager() == ui::WM_ICE_WM) { | |
348 browser()->window()->Activate(); | |
349 } | |
350 #endif | 360 #endif |
351 // More waiting, because gaining or losing focus may require inter-process | 361 // More waiting, because gaining or losing focus may require inter-process |
352 // asynchronous communication, and it is not enough to just run the local | 362 // asynchronous communication, and it is not enough to just run the local |
353 // message loop to make sure this activity has completed. | 363 // message loop to make sure this activity has completed. |
354 WaitForPanelActiveState(panel, params.expected_active_state); | 364 WaitForPanelActiveState(panel, params.expected_active_state); |
355 | 365 |
356 // On Linux, window size is not available right away and we should wait | 366 // On Linux, window size is not available right away and we should wait |
357 // before moving forward with the test. | 367 // before moving forward with the test. |
358 WaitForWindowSizeAvailable(panel); | 368 WaitForWindowSizeAvailable(panel); |
359 | 369 |
360 // Wait for the bounds animations on creation to finish. | 370 // Wait for the bounds animations on creation to finish. |
361 WaitForBoundsAnimationFinished(panel); | 371 WaitForBoundsAnimationFinished(panel); |
362 } | 372 } |
363 | 373 |
364 return panel; | 374 return panel; |
365 } | 375 } |
366 | 376 |
367 Panel* OldBasePanelBrowserTest::CreatePanelWithBounds( | 377 Panel* BasePanelBrowserTest::CreatePanelWithBounds( |
368 const std::string& panel_name, const gfx::Rect& bounds) { | 378 const std::string& panel_name, const gfx::Rect& bounds) { |
369 CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); | 379 CreatePanelParams params(panel_name, bounds, SHOW_AS_ACTIVE); |
370 return CreatePanelWithParams(params); | 380 return CreatePanelWithParams(params); |
371 } | 381 } |
372 | 382 |
373 Panel* OldBasePanelBrowserTest::CreatePanel(const std::string& panel_name) { | 383 Panel* BasePanelBrowserTest::CreatePanel(const std::string& panel_name) { |
374 CreatePanelParams params(panel_name, gfx::Rect(), SHOW_AS_ACTIVE); | 384 CreatePanelParams params(panel_name, gfx::Rect(), SHOW_AS_ACTIVE); |
375 return CreatePanelWithParams(params); | 385 return CreatePanelWithParams(params); |
376 } | 386 } |
377 | 387 |
378 Panel* OldBasePanelBrowserTest::CreateDockedPanel(const std::string& name, | 388 Panel* BasePanelBrowserTest::CreateDockedPanel(const std::string& name, |
379 const gfx::Rect& bounds) { | 389 const gfx::Rect& bounds) { |
380 Panel* panel = CreatePanelWithBounds(name, bounds); | 390 Panel* panel = CreatePanelWithBounds(name, bounds); |
381 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); | 391 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); |
382 return panel; | 392 return panel; |
383 } | 393 } |
384 | 394 |
385 Panel* OldBasePanelBrowserTest::CreateDetachedPanel(const std::string& name, | 395 Panel* BasePanelBrowserTest::CreateDetachedPanel(const std::string& name, |
386 const gfx::Rect& bounds) { | 396 const gfx::Rect& bounds) { |
387 Panel* panel = CreatePanelWithBounds(name, bounds); | 397 Panel* panel = CreatePanelWithBounds(name, bounds); |
388 panel->manager()->MovePanelToStrip(panel, | 398 panel->manager()->MovePanelToStrip(panel, |
389 PanelStrip::DETACHED, | 399 PanelStrip::DETACHED, |
390 PanelStrip::DEFAULT_POSITION); | 400 PanelStrip::DEFAULT_POSITION); |
391 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 401 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
392 // The panel is first created as docked panel, which ignores the specified | 402 // The panel is first created as docked panel, which ignores the specified |
393 // origin in |bounds|. We need to reposition the panel after it becomes | 403 // origin in |bounds|. We need to reposition the panel after it becomes |
394 // detached. | 404 // detached. |
395 panel->SetPanelBounds(bounds); | 405 panel->SetPanelBounds(bounds); |
396 WaitForBoundsAnimationFinished(panel); | 406 WaitForBoundsAnimationFinished(panel); |
397 return panel; | 407 return panel; |
398 } | 408 } |
399 | 409 |
400 void OldBasePanelBrowserTest::CreateTestTabContents(Browser* browser) { | 410 void BasePanelBrowserTest::CreateTestTabContents(Browser* browser) { |
401 TabContentsWrapper* tab_contents = | 411 TabContentsWrapper* tab_contents = |
402 new TabContentsWrapper( | 412 new TabContentsWrapper( |
403 WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); | 413 WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); |
404 browser->AddTab(tab_contents, content::PAGE_TRANSITION_LINK); | 414 browser->AddTab(tab_contents, content::PAGE_TRANSITION_LINK); |
405 } | 415 } |
406 | 416 |
407 scoped_refptr<Extension> OldBasePanelBrowserTest::CreateExtension( | 417 scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( |
408 const FilePath::StringType& path, | 418 const FilePath::StringType& path, |
409 Extension::Location location, | 419 Extension::Location location, |
410 const DictionaryValue& extra_value) { | 420 const DictionaryValue& extra_value) { |
411 #if defined(OS_WIN) | 421 #if defined(OS_WIN) |
412 FilePath full_path(FILE_PATH_LITERAL("c:\\")); | 422 FilePath full_path(FILE_PATH_LITERAL("c:\\")); |
413 #else | 423 #else |
414 FilePath full_path(FILE_PATH_LITERAL("/")); | 424 FilePath full_path(FILE_PATH_LITERAL("/")); |
415 #endif | 425 #endif |
416 full_path = full_path.Append(path); | 426 full_path = full_path.Append(path); |
417 | 427 |
418 scoped_ptr<DictionaryValue> input_value(extra_value.DeepCopy()); | 428 scoped_ptr<DictionaryValue> input_value(extra_value.DeepCopy()); |
419 input_value->SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | 429 input_value->SetString(extension_manifest_keys::kVersion, "1.0.0.0"); |
420 input_value->SetString(extension_manifest_keys::kName, "Sample Extension"); | 430 input_value->SetString(extension_manifest_keys::kName, "Sample Extension"); |
421 | 431 |
422 std::string error; | 432 std::string error; |
423 scoped_refptr<Extension> extension = Extension::Create( | 433 scoped_refptr<Extension> extension = Extension::Create( |
424 full_path, location, *input_value, Extension::NO_FLAGS, &error); | 434 full_path, location, *input_value, Extension::NO_FLAGS, &error); |
425 EXPECT_TRUE(extension.get()); | 435 EXPECT_TRUE(extension.get()); |
426 EXPECT_STREQ("", error.c_str()); | 436 EXPECT_STREQ("", error.c_str()); |
427 browser()->profile()->GetExtensionService()-> | 437 browser()->profile()->GetExtensionService()-> |
428 OnExtensionInstalled(extension.get(), false, StringOrdinal()); | 438 OnExtensionInstalled(extension.get(), false, StringOrdinal()); |
429 return extension; | 439 return extension; |
430 } | 440 } |
431 | 441 |
432 void OldBasePanelBrowserTest::SetTestingAreas( | 442 void BasePanelBrowserTest::SetTestingAreas(const gfx::Rect& primary_screen_area, |
433 const gfx::Rect& primary_screen_area, | 443 const gfx::Rect& work_area) { |
434 const gfx::Rect& work_area) { | |
435 DCHECK(primary_screen_area.Contains(work_area)); | 444 DCHECK(primary_screen_area.Contains(work_area)); |
436 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); | 445 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); |
437 mock_display_settings_provider_->SetWorkArea( | 446 mock_display_settings_provider_->SetWorkArea( |
438 work_area.IsEmpty() ? primary_screen_area : work_area); | 447 work_area.IsEmpty() ? primary_screen_area : work_area); |
439 } | 448 } |
440 | 449 |
441 void OldBasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { | 450 void BasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { |
442 // Closing a panel may involve several async tasks. Need to use | 451 // Closing a panel may involve several async tasks. Need to use |
443 // message pump and wait for the notification. | 452 // message pump and wait for the notification. |
444 PanelManager* manager = PanelManager::GetInstance(); | 453 PanelManager* manager = PanelManager::GetInstance(); |
445 int panel_count = manager->num_panels(); | 454 int panel_count = manager->num_panels(); |
446 ui_test_utils::WindowedNotificationObserver signal( | 455 ui_test_utils::WindowedNotificationObserver signal( |
447 chrome::NOTIFICATION_PANEL_CLOSED, | 456 chrome::NOTIFICATION_PANEL_CLOSED, |
448 content::Source<Panel>(panel)); | 457 content::Source<Panel>(panel)); |
449 panel->Close(); | 458 panel->Close(); |
450 signal.Wait(); | 459 signal.Wait(); |
451 // Now we have one less panel. | 460 // Now we have one less panel. |
452 EXPECT_EQ(panel_count - 1, manager->num_panels()); | 461 EXPECT_EQ(panel_count - 1, manager->num_panels()); |
453 | 462 |
454 #if defined(OS_MACOSX) | 463 #if defined(OS_MACOSX) |
455 // Mac window controllers may be autoreleased, and in the non-test | 464 // Mac window controllers may be autoreleased, and in the non-test |
456 // environment, may actually depend on the autorelease pool being recycled | 465 // environment, may actually depend on the autorelease pool being recycled |
457 // with the run loop in order to perform important work. Replicate this in | 466 // with the run loop in order to perform important work. Replicate this in |
458 // the test environment. | 467 // the test environment. |
459 AutoreleasePool()->Recycle(); | 468 AutoreleasePool()->Recycle(); |
460 | 469 |
461 // Make sure that everything has a chance to run. | 470 // Make sure that everything has a chance to run. |
462 chrome::testing::NSRunLoopRunAllPending(); | 471 chrome::testing::NSRunLoopRunAllPending(); |
463 #endif // OS_MACOSX | 472 #endif // OS_MACOSX |
464 } | 473 } |
465 | 474 |
466 void OldBasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( | 475 void BasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( |
467 Panel* panel, | 476 Panel* panel, |
468 const gfx::Point& position) { | 477 const gfx::Point& position) { |
469 ui_test_utils::WindowedNotificationObserver signal( | 478 ui_test_utils::WindowedNotificationObserver signal( |
470 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, | 479 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
471 content::Source<Panel>(panel)); | 480 content::Source<Panel>(panel)); |
472 MoveMouse(position); | 481 MoveMouse(position); |
473 signal.Wait(); | 482 signal.Wait(); |
474 } | 483 } |
475 | 484 |
476 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 485 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
477 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 486 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
478 } | 487 } |
479 | 488 |
480 std::string OldBasePanelBrowserTest::MakePanelName(int index) { | 489 std::string BasePanelBrowserTest::MakePanelName(int index) { |
481 std::string panel_name("Panel"); | 490 std::string panel_name("Panel"); |
482 return panel_name + base::IntToString(index); | 491 return panel_name + base::IntToString(index); |
483 } | 492 } |
OLD | NEW |