Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / panels / base_panel_browser_test.h
blobbd5a10d4a979e70b69538f29419653f84264ac90
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.
5 #ifndef CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_
6 #define CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_
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/rect.h"
18 class NativePanelTesting;
19 class StackedPanelCollection;
21 class BasePanelBrowserTest : public InProcessBrowserTest {
22 public:
23 class MockDisplaySettingsProvider : public DisplaySettingsProvider {
24 public:
25 MockDisplaySettingsProvider() { }
26 virtual ~MockDisplaySettingsProvider() { }
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;
42 BasePanelBrowserTest();
43 virtual ~BasePanelBrowserTest();
45 // Linux bots use icewm which activate windows in ways that break
46 // certain panel tests. Skip those tests when running on the bots.
47 // We do not disable the tests to make it easy for developers to run
48 // them locally. [Icewm always activates a window when shown.]
49 bool SkipTestIfIceWM();
51 // Gnome running compiz refuses to activate a window that was initially
52 // created as inactive, causing certain panel tests to fail. These tests
53 // pass fine on the bots, but fail for developers as Gnome running compiz
54 // is the typical linux dev machine configuration. We do not disable the
55 // tests to ensure we still have coverage on the bots.
56 bool SkipTestIfCompizWM();
58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
59 virtual void SetUpOnMainThread() OVERRIDE;
61 protected:
62 enum ActiveState { SHOW_AS_ACTIVE, SHOW_AS_INACTIVE };
64 struct CreatePanelParams {
65 std::string name;
66 gfx::Rect bounds;
67 ActiveState show_flag;
68 GURL url;
69 bool wait_for_fully_created;
70 ActiveState expected_active_state;
71 PanelManager::CreateMode create_mode;
72 Profile* profile;
74 CreatePanelParams(const std::string& name,
75 const gfx::Rect& bounds,
76 ActiveState show_flag);
79 Panel* CreatePanelWithParams(const CreatePanelParams& params);
80 Panel* CreatePanelWithBounds(const std::string& panel_name,
81 const gfx::Rect& bounds);
82 Panel* CreatePanel(const std::string& panel_name);
84 Panel* CreateDockedPanel(const std::string& name, const gfx::Rect& bounds);
85 Panel* CreateDetachedPanel(const std::string& name, const gfx::Rect& bounds);
86 Panel* CreateStackedPanel(const std::string& name,
87 const gfx::Rect& bounds,
88 StackedPanelCollection* stack);
90 Panel* CreateInactivePanel(const std::string& name);
91 Panel* CreateInactiveDockedPanel(const std::string& name,
92 const gfx::Rect& bounds);
93 Panel* CreateInactiveDetachedPanel(const std::string& name,
94 const gfx::Rect& bounds);
96 void ActivatePanel(Panel* panel);
97 void DeactivatePanel(Panel* panel);
99 static NativePanelTesting* CreateNativePanelTesting(Panel* panel);
101 void WaitForPanelActiveState(Panel* panel, ActiveState state);
102 void WaitForWindowSizeAvailable(Panel* panel);
103 void WaitForBoundsAnimationFinished(Panel* panel);
105 scoped_refptr<extensions::Extension> CreateExtension(
106 const base::FilePath::StringType& path,
107 extensions::Manifest::Location location,
108 const base::DictionaryValue& extra_value);
110 void MoveMouseAndWaitForExpansionStateChange(Panel* panel,
111 const gfx::Point& position);
112 static void MoveMouse(const gfx::Point& position);
113 void CloseWindowAndWait(Panel* panel);
114 static std::string MakePanelName(int index);
116 // Checks if the WM supports activation. This may not be true sometimes on
117 // buildbots for example when the wm has crashed.
118 static bool WmSupportWindowActivation();
120 MockDisplaySettingsProvider* mock_display_settings_provider() const {
121 return mock_display_settings_provider_;
124 // Some tests might not want to use the mock version.
125 void disable_display_settings_mock() {
126 mock_display_settings_enabled_ = false;
129 static const base::FilePath::CharType* kTestDir;
131 private:
132 // Passed to and owned by PanelManager.
133 MockDisplaySettingsProvider* mock_display_settings_provider_;
135 bool mock_display_settings_enabled_;
138 #endif // CHROME_BROWSER_UI_PANELS_BASE_PANEL_BROWSER_TEST_H_