| 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/base_panel_browser_test.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" | |
| 17 #include "chrome/browser/ui/panels/native_panel.h" | 16 #include "chrome/browser/ui/panels/native_panel.h" |
| 18 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 17 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 19 #include "chrome/browser/ui/panels/panel_strip.h" | 18 #include "chrome/browser/ui/panels/panel_strip.h" |
| 20 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h" | 19 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h" |
| 21 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" | 20 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 23 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/extensions/extension_manifest_constants.h" | 24 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 30 #include "content/public/test/web_contents_tester.h" | 28 #include "content/public/test/web_contents_tester.h" |
| 31 #include "sync/api/string_ordinal.h" | 29 #include "sync/api/string_ordinal.h" |
| 32 | 30 |
| 33 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
| 34 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 35 #include "ui/base/x/x11_util.h" | 33 #include "ui/base/x/x11_util.h" |
| 36 #endif | 34 #endif |
| 37 | 35 |
| 38 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 39 #include "base/mac/scoped_nsautorelease_pool.h" | 37 #include "base/mac/scoped_nsautorelease_pool.h" |
| 40 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | |
| 41 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 38 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
| 42 #endif | 39 #endif |
| 43 | 40 |
| 44 using content::WebContentsTester; | 41 using content::WebContentsTester; |
| 45 using extensions::Extension; | 42 using extensions::Extension; |
| 46 | 43 |
| 47 namespace { | 44 namespace { |
| 48 | 45 |
| 49 const gfx::Rect kTestingPrimaryScreenArea = gfx::Rect(0, 0, 800, 600); | 46 const gfx::Rect kTestingPrimaryScreenArea = gfx::Rect(0, 0, 800, 600); |
| 50 const gfx::Rect kTestingWorkArea = gfx::Rect(0, 0, 800, 580); | 47 const gfx::Rect kTestingWorkArea = gfx::Rect(0, 0, 800, 580); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 184 } |
| 188 | 185 |
| 189 } // namespace | 186 } // namespace |
| 190 | 187 |
| 191 const FilePath::CharType* BasePanelBrowserTest::kTestDir = | 188 const FilePath::CharType* BasePanelBrowserTest::kTestDir = |
| 192 FILE_PATH_LITERAL("panels"); | 189 FILE_PATH_LITERAL("panels"); |
| 193 | 190 |
| 194 BasePanelBrowserTest::BasePanelBrowserTest() | 191 BasePanelBrowserTest::BasePanelBrowserTest() |
| 195 : InProcessBrowserTest(), | 192 : InProcessBrowserTest(), |
| 196 mock_display_settings_enabled_(true) { | 193 mock_display_settings_enabled_(true) { |
| 197 #if defined(OS_MACOSX) | |
| 198 FindBarBridge::disable_animations_during_testing_ = true; | |
| 199 #endif | |
| 200 } | 194 } |
| 201 | 195 |
| 202 BasePanelBrowserTest::~BasePanelBrowserTest() { | 196 BasePanelBrowserTest::~BasePanelBrowserTest() { |
| 203 } | 197 } |
| 204 | 198 |
| 205 bool BasePanelBrowserTest::SkipTestIfIceWM() { | 199 bool BasePanelBrowserTest::SkipTestIfIceWM() { |
| 206 #if defined(OS_LINUX) | 200 #if defined(OS_LINUX) |
| 207 return ui::GuessWindowManager() == ui::WM_ICE_WM; | 201 return ui::GuessWindowManager() == ui::WM_ICE_WM; |
| 208 #else | 202 #else |
| 209 return false; | 203 return false; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 expected_active_state(show_flag), | 288 expected_active_state(show_flag), |
| 295 create_mode(PanelManager::CREATE_AS_DOCKED) { | 289 create_mode(PanelManager::CREATE_AS_DOCKED) { |
| 296 } | 290 } |
| 297 | 291 |
| 298 Panel* BasePanelBrowserTest::CreatePanelWithParams( | 292 Panel* BasePanelBrowserTest::CreatePanelWithParams( |
| 299 const CreatePanelParams& params) { | 293 const CreatePanelParams& params) { |
| 300 #if defined(OS_MACOSX) | 294 #if defined(OS_MACOSX) |
| 301 // Opening panels on a Mac causes NSWindowController of the Panel window | 295 // Opening panels on a Mac causes NSWindowController of the Panel window |
| 302 // to be autoreleased. We need a pool drained after it's done so the test | 296 // to be autoreleased. We need a pool drained after it's done so the test |
| 303 // can close correctly. The NSWindowController of the Panel window controls | 297 // can close correctly. The NSWindowController of the Panel window controls |
| 304 // lifetime of the Browser object so we want to release it as soon as | 298 // lifetime of the Panel object so we want to release it as soon as |
| 305 // possible. In real Chrome, this is done by message pump. | 299 // possible. In real Chrome, this is done by message pump. |
| 306 // On non-Mac platform, this is an empty class. | 300 // On non-Mac platform, this is an empty class. |
| 307 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 301 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 308 #endif | 302 #endif |
| 309 | 303 |
| 310 content::WindowedNotificationObserver observer( | 304 content::WindowedNotificationObserver observer( |
| 311 content::NOTIFICATION_LOAD_STOP, | 305 content::NOTIFICATION_LOAD_STOP, |
| 312 content::NotificationService::AllSources()); | 306 content::NotificationService::AllSources()); |
| 313 | 307 |
| 314 PanelManager* manager = PanelManager::GetInstance(); | 308 PanelManager* manager = PanelManager::GetInstance(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 WaitForBoundsAnimationFinished(panel); | 390 WaitForBoundsAnimationFinished(panel); |
| 397 return panel; | 391 return panel; |
| 398 } | 392 } |
| 399 | 393 |
| 400 // static | 394 // static |
| 401 NativePanelTesting* BasePanelBrowserTest::CreateNativePanelTesting( | 395 NativePanelTesting* BasePanelBrowserTest::CreateNativePanelTesting( |
| 402 Panel* panel) { | 396 Panel* panel) { |
| 403 return panel->native_panel()->CreateNativePanelTesting(); | 397 return panel->native_panel()->CreateNativePanelTesting(); |
| 404 } | 398 } |
| 405 | 399 |
| 406 void BasePanelBrowserTest::CreateTestTabContents(Browser* browser) { | |
| 407 TabContents* tab_contents = TabContents::Factory::CreateTabContents( | |
| 408 WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); | |
| 409 chrome::AddTab(browser, tab_contents, content::PAGE_TRANSITION_LINK); | |
| 410 } | |
| 411 | |
| 412 scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( | 400 scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension( |
| 413 const FilePath::StringType& path, | 401 const FilePath::StringType& path, |
| 414 Extension::Location location, | 402 Extension::Location location, |
| 415 const DictionaryValue& extra_value) { | 403 const DictionaryValue& extra_value) { |
| 416 #if defined(OS_WIN) | 404 #if defined(OS_WIN) |
| 417 FilePath full_path(FILE_PATH_LITERAL("c:\\")); | 405 FilePath full_path(FILE_PATH_LITERAL("c:\\")); |
| 418 #else | 406 #else |
| 419 FilePath full_path(FILE_PATH_LITERAL("/")); | 407 FilePath full_path(FILE_PATH_LITERAL("/")); |
| 420 #endif | 408 #endif |
| 421 full_path = full_path.Append(path); | 409 full_path = full_path.Append(path); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 466 } |
| 479 | 467 |
| 480 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 468 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
| 481 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 469 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
| 482 } | 470 } |
| 483 | 471 |
| 484 std::string BasePanelBrowserTest::MakePanelName(int index) { | 472 std::string BasePanelBrowserTest::MakePanelName(int index) { |
| 485 std::string panel_name("Panel"); | 473 std::string panel_name("Panel"); |
| 486 return panel_name + base::IntToString(index); | 474 return panel_name + base::IntToString(index); |
| 487 } | 475 } |
| OLD | NEW |