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 // Returns true if running in mash. | |
60 static bool IsMash(); | |
James Cook
2016/10/04 23:16:04
We have WmShell::Get()->IsRunningInMash() now. How
sky
2016/10/06 17:57:06
I forgot about that one. Done.
| |
61 | |
57 bool SupportsMultipleDisplays() const; | 62 bool SupportsMultipleDisplays() const; |
58 | 63 |
59 // Update the display configuration as given in |display_spec|. | 64 // Update the display configuration as given in |display_spec|. |
60 // See test::DisplayManagerTestApi::UpdateDisplay for more details. | 65 // See test::DisplayManagerTestApi::UpdateDisplay for more details. |
61 void UpdateDisplay(const std::string& display_spec); | 66 void UpdateDisplay(const std::string& display_spec); |
62 | 67 |
63 // Creates a top level visible window in the appropriate container. If | 68 // Creates a top level visible window in the appropriate container. If |
64 // |bounds_in_screen| is empty the window is added to the primary root window, | 69 // |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|. | 70 // 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. | 71 // |shell_window_id| is the shell window id to give to the new window. |
67 std::unique_ptr<WindowOwner> CreateTestWindow( | 72 std::unique_ptr<WindowOwner> CreateTestWindow( |
68 const gfx::Rect& bounds_in_screen = gfx::Rect(), | 73 const gfx::Rect& bounds_in_screen = gfx::Rect(), |
69 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL, | 74 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL, |
70 int shell_window_id = kShellWindowId_Invalid); | 75 int shell_window_id = kShellWindowId_Invalid); |
71 | 76 |
77 // Creates a visible top-level window. For aura a top-level window is a Window | |
James Cook
2016/10/04 23:16:04
From the description it's a little hard to tell ho
sky
2016/10/06 17:57:06
I added a reference to aura::Window::GetToplevelWi
| |
78 // that has a delegate. | |
79 std::unique_ptr<WindowOwner> CreateToplevelTestWindow( | |
80 const gfx::Rect& bounds_in_screen = gfx::Rect(), | |
81 int shell_window_id = kShellWindowId_Invalid); | |
82 | |
72 // Creates a visible window parented to |parent| with the specified bounds and | 83 // Creates a visible window parented to |parent| with the specified bounds and |
73 // id. | 84 // id. |
74 std::unique_ptr<WindowOwner> CreateChildWindow( | 85 std::unique_ptr<WindowOwner> CreateChildWindow( |
75 WmWindow* parent, | 86 WmWindow* parent, |
76 const gfx::Rect& bounds = gfx::Rect(), | 87 const gfx::Rect& bounds = gfx::Rect(), |
77 int shell_window_id = kShellWindowId_Invalid); | 88 int shell_window_id = kShellWindowId_Invalid); |
78 | 89 |
79 // Returns the Display for the secondary display. It's assumed there are two | 90 // Returns the Display for the secondary display. It's assumed there are two |
80 // displays. | 91 // displays. |
81 display::Display GetSecondaryDisplay(); | 92 display::Display GetSecondaryDisplay(); |
82 | 93 |
83 // Sets the placement of the secondary display. Returns true if the secondary | 94 // 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 | 95 // display can be moved, false otherwise. The false return value is temporary |
85 // until mus fully supports this. | 96 // until mus fully supports this. |
86 bool SetSecondaryDisplayPlacement( | 97 bool SetSecondaryDisplayPlacement( |
87 display::DisplayPlacement::Position position, | 98 display::DisplayPlacement::Position position, |
88 int offset); | 99 int offset); |
89 | 100 |
101 // Configures |init_params| so that the widget will be created on the same | |
102 // display as |window|. | |
103 void ConfigureWidgetInitParamsForDisplay( | |
104 WmWindow* window, | |
105 views::Widget::InitParams* init_params); | |
106 | |
107 // Returns the WmShelf for the primary display. | |
108 WmShelf* GetPrimaryShelf(); | |
James Cook
2016/10/04 23:16:04
static and (optionally) move up
I think there are
sky
2016/10/06 17:57:06
Done.
| |
109 | |
110 // Adds |window| to the appropriate container in the primary root window. | |
111 void ParentWindowInPrimaryRootWindow(WmWindow* window); | |
112 | |
113 // Adds |window| as as a transient child of |parent|. | |
114 void AddTransientChild(WmWindow* parent, WmWindow* window); | |
115 | |
116 void SetCanLockScreen(bool can_lock_screen); | |
James Cook
2016/10/04 23:16:04
Function comment? "Lock" means signout-related-loc
sky
2016/10/06 17:57:06
Done.
| |
117 | |
118 void RunAllPendingInMessageLoop(); | |
119 | |
90 protected: | 120 protected: |
91 // testing::Test: | 121 // testing::Test: |
92 void SetUp() override; | 122 void SetUp() override; |
93 void TearDown() override; | 123 void TearDown() override; |
94 | 124 |
95 private: | 125 private: |
96 std::unique_ptr<AshTestImpl> test_impl_; | 126 std::unique_ptr<AshTestImpl> test_impl_; |
97 | 127 |
98 DISALLOW_COPY_AND_ASSIGN(AshTest); | 128 DISALLOW_COPY_AND_ASSIGN(AshTest); |
99 }; | 129 }; |
100 | 130 |
101 } // namespace ash | 131 } // namespace ash |
102 | 132 |
103 #endif // ASH_COMMON_TEST_ASH_TEST_H_ | 133 #endif // ASH_COMMON_TEST_ASH_TEST_H_ |
OLD | NEW |