| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/values.h" | |
| 10 #include "chrome/browser/ui/panels/display_settings_provider.h" | |
| 11 #include "chrome/browser/ui/panels/panel.h" | |
| 12 #include "chrome/browser/ui/panels/panel_manager.h" | |
| 13 #include "chrome/test/base/in_process_browser_test.h" | |
| 14 #include "extensions/common/extension.h" | |
| 15 #include "extensions/common/manifest.h" | |
| 16 #include "ui/gfx/geometry/rect.h" | |
| 17 | |
| 18 class NativePanelTesting; | |
| 19 class StackedPanelCollection; | |
| 20 | |
| 21 class BasePanelBrowserTest : public InProcessBrowserTest { | |
| 22 public: | |
| 23 class MockDisplaySettingsProvider : public DisplaySettingsProvider { | |
| 24 public: | |
| 25 MockDisplaySettingsProvider() { } | |
| 26 ~MockDisplaySettingsProvider() override {} | |
| 27 | |
| 28 virtual void SetPrimaryDisplay( | |
| 29 const gfx::Rect& display_area, const gfx::Rect& work_area) = 0; | |
| 30 virtual void SetSecondaryDisplay( | |
| 31 const gfx::Rect& display_area, const gfx::Rect& work_area) = 0; | |
| 32 virtual void EnableAutoHidingDesktopBar(DesktopBarAlignment alignment, | |
| 33 bool enabled, | |
| 34 int thickness) = 0; | |
| 35 virtual void SetDesktopBarVisibility(DesktopBarAlignment alignment, | |
| 36 DesktopBarVisibility visibility) = 0; | |
| 37 virtual void SetDesktopBarThickness(DesktopBarAlignment alignment, | |
| 38 int thickness) = 0; | |
| 39 virtual void EnableFullScreenMode(bool enabled) = 0; | |
| 40 }; | |
| 41 | |
| 42 BasePanelBrowserTest(); | |
| 43 ~BasePanelBrowserTest() override; | |
| 44 | |
| 45 void SetUpCommandLine(base::CommandLine* command_line) override; | |
| 46 void SetUpOnMainThread() override; | |
| 47 | |
| 48 protected: | |
| 49 enum ActiveState { SHOW_AS_ACTIVE, SHOW_AS_INACTIVE }; | |
| 50 | |
| 51 struct CreatePanelParams { | |
| 52 std::string name; | |
| 53 gfx::Rect bounds; | |
| 54 ActiveState show_flag; | |
| 55 GURL url; | |
| 56 bool wait_for_fully_created; | |
| 57 ActiveState expected_active_state; | |
| 58 PanelManager::CreateMode create_mode; | |
| 59 Profile* profile; | |
| 60 | |
| 61 CreatePanelParams(const std::string& name, | |
| 62 const gfx::Rect& bounds, | |
| 63 ActiveState show_flag); | |
| 64 }; | |
| 65 | |
| 66 Panel* CreatePanelWithParams(const CreatePanelParams& params); | |
| 67 Panel* CreatePanelWithBounds(const std::string& panel_name, | |
| 68 const gfx::Rect& bounds); | |
| 69 Panel* CreatePanel(const std::string& panel_name); | |
| 70 | |
| 71 Panel* CreateDockedPanel(const std::string& name, const gfx::Rect& bounds); | |
| 72 Panel* CreateDetachedPanel(const std::string& name, const gfx::Rect& bounds); | |
| 73 Panel* CreateStackedPanel(const std::string& name, | |
| 74 const gfx::Rect& bounds, | |
| 75 StackedPanelCollection* stack); | |
| 76 | |
| 77 Panel* CreateInactivePanel(const std::string& name); | |
| 78 Panel* CreateInactiveDockedPanel(const std::string& name, | |
| 79 const gfx::Rect& bounds); | |
| 80 Panel* CreateInactiveDetachedPanel(const std::string& name, | |
| 81 const gfx::Rect& bounds); | |
| 82 | |
| 83 void ActivatePanel(Panel* panel); | |
| 84 void DeactivatePanel(Panel* panel); | |
| 85 | |
| 86 static NativePanelTesting* CreateNativePanelTesting(Panel* panel); | |
| 87 | |
| 88 void WaitForPanelActiveState(Panel* panel, ActiveState state); | |
| 89 void WaitForBoundsAnimationFinished(Panel* panel); | |
| 90 | |
| 91 scoped_refptr<extensions::Extension> CreateExtension( | |
| 92 const base::FilePath::StringType& path, | |
| 93 extensions::Manifest::Location location, | |
| 94 const base::DictionaryValue& extra_value); | |
| 95 | |
| 96 void MoveMouseAndWaitForExpansionStateChange(Panel* panel, | |
| 97 const gfx::Point& position); | |
| 98 static void MoveMouse(const gfx::Point& position); | |
| 99 void CloseWindowAndWait(Panel* panel); | |
| 100 static std::string MakePanelName(int index); | |
| 101 | |
| 102 // Checks if the WM supports activation. This may not be true sometimes on | |
| 103 // buildbots for example when the wm has crashed. | |
| 104 static bool WmSupportWindowActivation(); | |
| 105 | |
| 106 MockDisplaySettingsProvider* mock_display_settings_provider() const { | |
| 107 return mock_display_settings_provider_; | |
| 108 } | |
| 109 | |
| 110 // Some tests might not want to use the mock version. | |
| 111 void disable_display_settings_mock() { | |
| 112 mock_display_settings_enabled_ = false; | |
| 113 } | |
| 114 | |
| 115 static const base::FilePath::CharType* kTestDir; | |
| 116 | |
| 117 private: | |
| 118 // Passed to and owned by PanelManager. | |
| 119 MockDisplaySettingsProvider* mock_display_settings_provider_; | |
| 120 | |
| 121 bool mock_display_settings_enabled_; | |
| 122 }; | |
| 123 | |
| 124 #endif // CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_ | |
| OLD | NEW |