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 #pragma once |
| 8 |
| 9 #include "base/values.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "chrome/browser/ui/panels/display_settings_provider.h" |
| 12 #include "chrome/browser/ui/panels/panel.h" |
| 13 #include "chrome/browser/ui/panels/panel_strip.h" |
| 14 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "ui/gfx/rect.h" |
| 17 |
| 18 class BasePanelBrowserTest : public InProcessBrowserTest { |
| 19 public: |
| 20 class MockDisplaySettingsProvider : public DisplaySettingsProvider { |
| 21 public: |
| 22 MockDisplaySettingsProvider() { } |
| 23 virtual ~MockDisplaySettingsProvider() { } |
| 24 |
| 25 virtual void SetPrimaryScreenArea(const gfx::Rect& primary_screen_area) = 0; |
| 26 virtual void SetWorkArea(const gfx::Rect& work_area) = 0; |
| 27 virtual void EnableAutoHidingDesktopBar(DesktopBarAlignment alignment, |
| 28 bool enabled, |
| 29 int thickness) = 0; |
| 30 virtual void SetDesktopBarVisibility(DesktopBarAlignment alignment, |
| 31 DesktopBarVisibility visibility) = 0; |
| 32 virtual void SetDesktopBarThickness(DesktopBarAlignment alignment, |
| 33 int thickness) = 0; |
| 34 }; |
| 35 |
| 36 BasePanelBrowserTest(); |
| 37 virtual ~BasePanelBrowserTest(); |
| 38 |
| 39 // Linux bots use icewm which activate windows in ways that break |
| 40 // certain panel tests. Skip those tests when running on the bots. |
| 41 // We do not disable the tests to make it easy for developers to run |
| 42 // them locally. |
| 43 bool SkipTestIfIceWM(); |
| 44 |
| 45 // Gnome running compiz refuses to activate a window that was initially |
| 46 // created as inactive, causing certain panel tests to fail. These tests |
| 47 // pass fine on the bots, but fail for developers as Gnome running compiz |
| 48 // is the typical linux dev machine configuration. We do not disable the |
| 49 // tests to ensure we still have coverage on the bots. |
| 50 bool SkipTestIfCompizWM(); |
| 51 |
| 52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 53 virtual void SetUpOnMainThread() OVERRIDE; |
| 54 |
| 55 protected: |
| 56 enum ActiveState { SHOW_AS_ACTIVE, SHOW_AS_INACTIVE }; |
| 57 |
| 58 struct CreatePanelParams { |
| 59 std::string name; |
| 60 gfx::Rect bounds; |
| 61 ActiveState show_flag; |
| 62 GURL url; |
| 63 bool wait_for_fully_created; |
| 64 ActiveState expected_active_state; |
| 65 |
| 66 CreatePanelParams(const std::string& name, |
| 67 const gfx::Rect& bounds, |
| 68 ActiveState show_flag) |
| 69 : name(name), |
| 70 bounds(bounds), |
| 71 show_flag(show_flag), |
| 72 wait_for_fully_created(true), |
| 73 expected_active_state(show_flag) { |
| 74 } |
| 75 }; |
| 76 |
| 77 Panel* CreatePanelWithParams(const CreatePanelParams& params); |
| 78 Panel* CreatePanelWithBounds(const std::string& panel_name, |
| 79 const gfx::Rect& bounds); |
| 80 Panel* CreatePanel(const std::string& panel_name); |
| 81 |
| 82 Panel* CreateDockedPanel(const std::string& name, const gfx::Rect& bounds); |
| 83 Panel* CreateDetachedPanel(const std::string& name, const gfx::Rect& bounds); |
| 84 |
| 85 void WaitForPanelActiveState(Panel* panel, ActiveState state); |
| 86 void WaitForWindowSizeAvailable(Panel* panel); |
| 87 void WaitForBoundsAnimationFinished(Panel* panel); |
| 88 void WaitForExpansionStateChanged(Panel* panel, |
| 89 Panel::ExpansionState expansion_state); |
| 90 |
| 91 void CreateTestTabContents(Browser* browser); |
| 92 |
| 93 scoped_refptr<extensions::Extension> CreateExtension( |
| 94 const FilePath::StringType& path, |
| 95 extensions::Extension::Location location, |
| 96 const DictionaryValue& extra_value); |
| 97 |
| 98 void MoveMouseAndWaitForExpansionStateChange(Panel* panel, |
| 99 const gfx::Point& position); |
| 100 static void MoveMouse(const gfx::Point& position); |
| 101 void CloseWindowAndWait(Panel* panel); |
| 102 static std::string MakePanelName(int index); |
| 103 |
| 104 // |primary_screen_area| must contain |work_area|. If empty rect is passed |
| 105 // to |work_area|, it will be set to same as |primary_screen_area|. |
| 106 void SetTestingAreas(const gfx::Rect& primary_screen_area, |
| 107 const gfx::Rect& work_area); |
| 108 |
| 109 MockDisplaySettingsProvider* mock_display_settings_provider() const { |
| 110 return mock_display_settings_provider_; |
| 111 } |
| 112 |
| 113 // Some tests might not want to use the mock version. |
| 114 void disable_display_settings_mock() { |
| 115 mock_display_settings_enabled_ = false; |
| 116 } |
| 117 |
| 118 static const FilePath::CharType* kTestDir; |
| 119 |
| 120 private: |
| 121 // Passed to and owned by PanelManager. |
| 122 MockDisplaySettingsProvider* mock_display_settings_provider_; |
| 123 |
| 124 bool mock_display_settings_enabled_; |
| 125 }; |
| 126 |
| 127 #endif // CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_ |
OLD | NEW |