Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: ash/test/ash_test.h

Issue 2847283002: chromeos: convert remaining AshTest usage to AshTestBase (Closed)
Patch Set: comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/test/BUILD.gn ('k') | ash/test/ash_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_TEST_ASH_TEST_H_
6 #define ASH_TEST_ASH_TEST_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "ash/public/cpp/shell_window_ids.h"
12 #include "base/macros.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/display/display_layout.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/widget/widget.h"
17 #include "ui/wm/public/window_types.h"
18
19 namespace display {
20 class Display;
21 }
22
23 namespace views {
24 class WidgetDelegate;
25 }
26
27 namespace ash {
28
29 class AshTestImpl;
30 class SystemTray;
31 class WmShelf;
32 class WmWindow;
33
34 namespace test {
35 class TestSystemTrayDelegate;
36 }
37
38 // Wraps a WmWindow calling WmWindow::Destroy() from the destructor. WmWindow is
39 // owned by the corresponding window implementation. The only way to delete
40 // WmWindow is to call WmWindow::Destroy(), which deletes the corresponding
41 // window, then the WmWindow. This class calls WmWindow::Destroy() from its
42 // destructor.
43 class WindowOwner {
44 public:
45 explicit WindowOwner(WmWindow* window);
46 ~WindowOwner();
47
48 WmWindow* window() { return window_; }
49
50 private:
51 WmWindow* window_;
52
53 DISALLOW_COPY_AND_ASSIGN(WindowOwner);
54 };
55
56 // Base class for ash tests. This class calls through to AshTestImpl for the
57 // real implementation. This class exists so that tests can be written to
58 // run in both mus and aura.
59 //
60 // TODO: this class is deprecated and should be removed.
61 // http://crbug.com/707057.
62 class AshTest : public testing::Test {
63 public:
64 AshTest();
65 ~AshTest() override;
66
67 // Returns the WmShelf for the primary display.
68 static WmShelf* GetPrimaryShelf();
69
70 // Returns the system tray on the primary display.
71 static SystemTray* GetPrimarySystemTray();
72
73 static test::TestSystemTrayDelegate* GetSystemTrayDelegate();
74
75 // Update the display configuration as given in |display_spec|.
76 // See test::DisplayManagerTestApi::UpdateDisplay for more details.
77 void UpdateDisplay(const std::string& display_spec);
78
79 // Creates a visible window in the appropriate container. If
80 // |bounds_in_screen| is empty the window is added to the primary root
81 // window, otherwise the window is added to the display matching
82 // |bounds_in_screen|. |shell_window_id| is the shell window id to give to
83 // the new window.
84 std::unique_ptr<WindowOwner> CreateTestWindow(
85 const gfx::Rect& bounds_in_screen = gfx::Rect(),
86 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL,
87 int shell_window_id = kShellWindowId_Invalid);
88
89 // Creates a visible top-level window. For aura a top-level window is a Window
90 // that has a delegate, see aura::Window::GetToplevelWindow() for more
91 // details.
92 std::unique_ptr<WindowOwner> CreateToplevelTestWindow(
93 const gfx::Rect& bounds_in_screen = gfx::Rect(),
94 int shell_window_id = kShellWindowId_Invalid);
95
96 // Creates a visible window parented to |parent| with the specified bounds and
97 // id.
98 std::unique_ptr<WindowOwner> CreateChildWindow(
99 WmWindow* parent,
100 const gfx::Rect& bounds = gfx::Rect(),
101 int shell_window_id = kShellWindowId_Invalid);
102
103 // Creates and shows a widget. See ash/public/cpp/shell_window_ids.h for
104 // values for |container_id|.
105 static std::unique_ptr<views::Widget> CreateTestWidget(
106 const gfx::Rect& bounds,
107 views::WidgetDelegate* delegate = nullptr,
108 int container_id = kShellWindowId_DefaultContainer);
109
110 // Returns the Display for the secondary display. It's assumed there are two
111 // displays.
112 display::Display GetSecondaryDisplay();
113
114 // Sets the placement of the secondary display. Returns true if the secondary
115 // display can be moved, false otherwise. The false return value is temporary
116 // until mus fully supports this.
117 bool SetSecondaryDisplayPlacement(
118 display::DisplayPlacement::Position position,
119 int offset);
120
121 // Configures |init_params| so that the widget will be created on the same
122 // display as |window|.
123 void ConfigureWidgetInitParamsForDisplay(
124 WmWindow* window,
125 views::Widget::InitParams* init_params);
126
127 // Adds |window| to the appropriate container in the primary root window.
128 void ParentWindowInPrimaryRootWindow(WmWindow* window);
129
130 // Adds |window| as as a transient child of |parent|.
131 void AddTransientChild(WmWindow* parent, WmWindow* window);
132
133 void RunAllPendingInMessageLoop();
134
135 protected:
136 // testing::Test:
137 void SetUp() override;
138 void TearDown() override;
139
140 private:
141 std::unique_ptr<AshTestImpl> test_impl_;
142
143 DISALLOW_COPY_AND_ASSIGN(AshTest);
144 };
145
146 } // namespace ash
147
148 #endif // ASH_TEST_ASH_TEST_H_
OLDNEW
« no previous file with comments | « ash/test/BUILD.gn ('k') | ash/test/ash_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698