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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
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_COMMON_TEST_ASH_TEST_H_
6 #define ASH_COMMON_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 // ash/common and run in both mus and aura.
59 //
60 // The implementation of AshTestImpl that is used depends upon gn targets. To
61 // use the aura backend depend on "//ash/test:ash_with_aura_test_support." The
62 // mus backend is not provided as a separate link target.
63 class AshTest : public testing::Test {
64 public:
65 AshTest();
66 ~AshTest() override;
67
68 // Returns the WmShelf for the primary display.
69 static WmShelf* GetPrimaryShelf();
70
71 // Returns the system tray on the primary display.
72 static SystemTray* GetPrimarySystemTray();
73
74 static test::TestSystemTrayDelegate* GetSystemTrayDelegate();
75
76 // Update the display configuration as given in |display_spec|.
77 // See test::DisplayManagerTestApi::UpdateDisplay for more details.
78 void UpdateDisplay(const std::string& display_spec);
79
80 // Creates a visible window in the appropriate container. If
81 // |bounds_in_screen| is empty the window is added to the primary root
82 // window, otherwise the window is added to the display matching
83 // |bounds_in_screen|. |shell_window_id| is the shell window id to give to
84 // the new window.
85 std::unique_ptr<WindowOwner> CreateTestWindow(
86 const gfx::Rect& bounds_in_screen = gfx::Rect(),
87 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL,
88 int shell_window_id = kShellWindowId_Invalid);
89
90 // Creates a visible top-level window. For aura a top-level window is a Window
91 // that has a delegate, see aura::Window::GetToplevelWindow() for more
92 // details.
93 std::unique_ptr<WindowOwner> CreateToplevelTestWindow(
94 const gfx::Rect& bounds_in_screen = gfx::Rect(),
95 int shell_window_id = kShellWindowId_Invalid);
96
97 // Creates a visible window parented to |parent| with the specified bounds and
98 // id.
99 std::unique_ptr<WindowOwner> CreateChildWindow(
100 WmWindow* parent,
101 const gfx::Rect& bounds = gfx::Rect(),
102 int shell_window_id = kShellWindowId_Invalid);
103
104 // Creates and shows a widget. See ash/public/cpp/shell_window_ids.h for
105 // values for |container_id|.
106 static std::unique_ptr<views::Widget> CreateTestWidget(
107 const gfx::Rect& bounds,
108 views::WidgetDelegate* delegate = nullptr,
109 int container_id = kShellWindowId_DefaultContainer);
110
111 // Returns the Display for the secondary display. It's assumed there are two
112 // displays.
113 display::Display GetSecondaryDisplay();
114
115 // Sets the placement of the secondary display. Returns true if the secondary
116 // display can be moved, false otherwise. The false return value is temporary
117 // until mus fully supports this.
118 bool SetSecondaryDisplayPlacement(
119 display::DisplayPlacement::Position position,
120 int offset);
121
122 // Configures |init_params| so that the widget will be created on the same
123 // display as |window|.
124 void ConfigureWidgetInitParamsForDisplay(
125 WmWindow* window,
126 views::Widget::InitParams* init_params);
127
128 // Adds |window| to the appropriate container in the primary root window.
129 void ParentWindowInPrimaryRootWindow(WmWindow* window);
130
131 // Adds |window| as as a transient child of |parent|.
132 void AddTransientChild(WmWindow* parent, WmWindow* window);
133
134 void RunAllPendingInMessageLoop();
135
136 protected:
137 // testing::Test:
138 void SetUp() override;
139 void TearDown() override;
140
141 private:
142 std::unique_ptr<AshTestImpl> test_impl_;
143
144 DISALLOW_COPY_AND_ASSIGN(AshTest);
145 };
146
147 } // namespace ash
148
149 #endif // ASH_COMMON_TEST_ASH_TEST_H_
OLDNEW
« no previous file with comments | « ash/common/system/web_notification/web_notification_tray.cc ('k') | ash/common/test/ash_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698