Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ASH_COMMON_TEST_ASH_TEST_H_ | 5 #ifndef ASH_COMMON_TEST_ASH_TEST_H_ |
| 6 #define ASH_COMMON_TEST_ASH_TEST_H_ | 6 #define ASH_COMMON_TEST_ASH_TEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/display/manager/display_layout.h" | 14 #include "ui/display/manager/display_layout.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/views/widget/widget.h" | |
| 16 #include "ui/wm/public/window_types.h" | 17 #include "ui/wm/public/window_types.h" |
| 17 | 18 |
| 18 namespace display { | 19 namespace display { |
| 19 class Display; | 20 class Display; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace ash { | 23 namespace ash { |
| 23 | 24 |
| 24 class AshTestImpl; | 25 class AshTestImpl; |
| 26 class WmShelf; | |
| 25 class WmWindow; | 27 class WmWindow; |
| 26 | 28 |
| 27 // Wraps a WmWindow calling WmWindow::Destroy() from the destructor. WmWindow is | 29 // Wraps a WmWindow calling WmWindow::Destroy() from the destructor. WmWindow is |
| 28 // owned by the corresponding window implementation. The only way to delete | 30 // owned by the corresponding window implementation. The only way to delete |
| 29 // WmWindow is to call WmWindow::Destroy(), which deletes the corresponding | 31 // WmWindow is to call WmWindow::Destroy(), which deletes the corresponding |
| 30 // window, then the WmWindow. This class calls WmWindow::Destroy() from its | 32 // window, then the WmWindow. This class calls WmWindow::Destroy() from its |
| 31 // destructor. | 33 // destructor. |
| 32 class WindowOwner { | 34 class WindowOwner { |
| 33 public: | 35 public: |
| 34 explicit WindowOwner(WmWindow* window); | 36 explicit WindowOwner(WmWindow* window); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 47 // ash/common and run in both mus and aura. | 49 // ash/common and run in both mus and aura. |
| 48 // | 50 // |
| 49 // The implementation of AshTestImpl that is used depends upon gn targets. To | 51 // The implementation of AshTestImpl that is used depends upon gn targets. To |
| 50 // use the aura backend depend on "//ash:ash_with_aura_test_support." The mus | 52 // use the aura backend depend on "//ash:ash_with_aura_test_support." The mus |
| 51 // backend is not provided as a separate link target. | 53 // backend is not provided as a separate link target. |
| 52 class AshTest : public testing::Test { | 54 class AshTest : public testing::Test { |
| 53 public: | 55 public: |
| 54 AshTest(); | 56 AshTest(); |
| 55 ~AshTest() override; | 57 ~AshTest() override; |
| 56 | 58 |
| 59 // Cover functions for WmShell::Get()->IsRunningInMash(). | |
|
msw
2016/10/06 20:18:24
nit: "Cover functions"? maybe just "Calls WmShell:
sky
2016/10/06 21:05:58
Done.
| |
| 60 static bool IsRunningInMash(); | |
| 61 | |
| 62 // Returns the WmShelf for the primary display. | |
| 63 static WmShelf* GetPrimaryShelf(); | |
| 64 | |
| 57 bool SupportsMultipleDisplays() const; | 65 bool SupportsMultipleDisplays() const; |
| 58 | 66 |
| 59 // Update the display configuration as given in |display_spec|. | 67 // Update the display configuration as given in |display_spec|. |
| 60 // See test::DisplayManagerTestApi::UpdateDisplay for more details. | 68 // See test::DisplayManagerTestApi::UpdateDisplay for more details. |
| 61 void UpdateDisplay(const std::string& display_spec); | 69 void UpdateDisplay(const std::string& display_spec); |
| 62 | 70 |
| 63 // Creates a top level visible window in the appropriate container. If | 71 // Creates a top level visible window in the appropriate container. If |
|
msw
2016/10/06 20:18:24
I see that James already asked about this, but I n
sky
2016/10/06 21:05:58
I removed the mention to top-level here. I would r
| |
| 64 // |bounds_in_screen| is empty the window is added to the primary root window, | 72 // |bounds_in_screen| is empty the window is added to the primary root window, |
| 65 // otherwise the window is added to the display matching |bounds_in_screen|. | 73 // otherwise the window is added to the display matching |bounds_in_screen|. |
| 66 // |shell_window_id| is the shell window id to give to the new window. | 74 // |shell_window_id| is the shell window id to give to the new window. |
| 67 std::unique_ptr<WindowOwner> CreateTestWindow( | 75 std::unique_ptr<WindowOwner> CreateTestWindow( |
| 68 const gfx::Rect& bounds_in_screen = gfx::Rect(), | 76 const gfx::Rect& bounds_in_screen = gfx::Rect(), |
| 69 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL, | 77 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL, |
| 70 int shell_window_id = kShellWindowId_Invalid); | 78 int shell_window_id = kShellWindowId_Invalid); |
| 71 | 79 |
| 80 // Creates a visible top-level window. For aura a top-level window is a Window | |
| 81 // that has a delegate, see aura::Window::GetToplevelWindow() for more | |
| 82 // details. | |
| 83 std::unique_ptr<WindowOwner> CreateToplevelTestWindow( | |
| 84 const gfx::Rect& bounds_in_screen = gfx::Rect(), | |
| 85 int shell_window_id = kShellWindowId_Invalid); | |
| 86 | |
| 72 // Creates a visible window parented to |parent| with the specified bounds and | 87 // Creates a visible window parented to |parent| with the specified bounds and |
| 73 // id. | 88 // id. |
| 74 std::unique_ptr<WindowOwner> CreateChildWindow( | 89 std::unique_ptr<WindowOwner> CreateChildWindow( |
| 75 WmWindow* parent, | 90 WmWindow* parent, |
| 76 const gfx::Rect& bounds = gfx::Rect(), | 91 const gfx::Rect& bounds = gfx::Rect(), |
| 77 int shell_window_id = kShellWindowId_Invalid); | 92 int shell_window_id = kShellWindowId_Invalid); |
| 78 | 93 |
| 79 // Returns the Display for the secondary display. It's assumed there are two | 94 // Returns the Display for the secondary display. It's assumed there are two |
| 80 // displays. | 95 // displays. |
| 81 display::Display GetSecondaryDisplay(); | 96 display::Display GetSecondaryDisplay(); |
| 82 | 97 |
| 83 // Sets the placement of the secondary display. Returns true if the secondary | 98 // Sets the placement of the secondary display. Returns true if the secondary |
| 84 // display can be moved, false otherwise. The false return value is temporary | 99 // display can be moved, false otherwise. The false return value is temporary |
| 85 // until mus fully supports this. | 100 // until mus fully supports this. |
| 86 bool SetSecondaryDisplayPlacement( | 101 bool SetSecondaryDisplayPlacement( |
| 87 display::DisplayPlacement::Position position, | 102 display::DisplayPlacement::Position position, |
| 88 int offset); | 103 int offset); |
| 89 | 104 |
| 105 // Configures |init_params| so that the widget will be created on the same | |
| 106 // display as |window|. | |
| 107 void ConfigureWidgetInitParamsForDisplay( | |
| 108 WmWindow* window, | |
| 109 views::Widget::InitParams* init_params); | |
| 110 | |
| 111 // Adds |window| to the appropriate container in the primary root window. | |
| 112 void ParentWindowInPrimaryRootWindow(WmWindow* window); | |
| 113 | |
| 114 // Adds |window| as as a transient child of |parent|. | |
| 115 void AddTransientChild(WmWindow* parent, WmWindow* window); | |
| 116 | |
| 117 // Helper for calling TestSessionStateDelegate::SetCanLockScreen(). Controls | |
| 118 // the return value from SessionStateDelegate::CanLockScreen(). | |
| 119 void SetCanLockScreen(bool can_lock_screen); | |
|
msw
2016/10/06 20:18:24
This seems a little unnecessary as an AshTest func
sky
2016/10/06 21:05:58
Agreed. Done.
| |
| 120 | |
| 121 void RunAllPendingInMessageLoop(); | |
| 122 | |
| 90 protected: | 123 protected: |
| 91 // testing::Test: | 124 // testing::Test: |
| 92 void SetUp() override; | 125 void SetUp() override; |
| 93 void TearDown() override; | 126 void TearDown() override; |
| 94 | 127 |
| 95 private: | 128 private: |
| 96 std::unique_ptr<AshTestImpl> test_impl_; | 129 std::unique_ptr<AshTestImpl> test_impl_; |
| 97 | 130 |
| 98 DISALLOW_COPY_AND_ASSIGN(AshTest); | 131 DISALLOW_COPY_AND_ASSIGN(AshTest); |
| 99 }; | 132 }; |
| 100 | 133 |
| 101 } // namespace ash | 134 } // namespace ash |
| 102 | 135 |
| 103 #endif // ASH_COMMON_TEST_ASH_TEST_H_ | 136 #endif // ASH_COMMON_TEST_ASH_TEST_H_ |
| OLD | NEW |