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

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

Issue 2391153002: Converts most of WorkspaceLayoutManager tests to use common code (Closed)
Patch Set: merge Created 4 years, 2 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/aura/wm_window_aura.cc ('k') | ash/common/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
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
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 the WmShelf for the primary display.
60 static WmShelf* GetPrimaryShelf();
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 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
65 // otherwise the window is added to the display matching |bounds_in_screen|. 70 // window, otherwise the window is added to the display matching
66 // |shell_window_id| is the shell window id to give to the new window. 71 // |bounds_in_screen|. |shell_window_id| is the shell window id to give to
72 // the new window.
67 std::unique_ptr<WindowOwner> CreateTestWindow( 73 std::unique_ptr<WindowOwner> CreateTestWindow(
68 const gfx::Rect& bounds_in_screen = gfx::Rect(), 74 const gfx::Rect& bounds_in_screen = gfx::Rect(),
69 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL, 75 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL,
70 int shell_window_id = kShellWindowId_Invalid); 76 int shell_window_id = kShellWindowId_Invalid);
71 77
78 // Creates a visible top-level window. For aura a top-level window is a Window
79 // that has a delegate, see aura::Window::GetToplevelWindow() for more
80 // details.
81 std::unique_ptr<WindowOwner> CreateToplevelTestWindow(
82 const gfx::Rect& bounds_in_screen = gfx::Rect(),
83 int shell_window_id = kShellWindowId_Invalid);
84
72 // Creates a visible window parented to |parent| with the specified bounds and 85 // Creates a visible window parented to |parent| with the specified bounds and
73 // id. 86 // id.
74 std::unique_ptr<WindowOwner> CreateChildWindow( 87 std::unique_ptr<WindowOwner> CreateChildWindow(
75 WmWindow* parent, 88 WmWindow* parent,
76 const gfx::Rect& bounds = gfx::Rect(), 89 const gfx::Rect& bounds = gfx::Rect(),
77 int shell_window_id = kShellWindowId_Invalid); 90 int shell_window_id = kShellWindowId_Invalid);
78 91
79 // Returns the Display for the secondary display. It's assumed there are two 92 // Returns the Display for the secondary display. It's assumed there are two
80 // displays. 93 // displays.
81 display::Display GetSecondaryDisplay(); 94 display::Display GetSecondaryDisplay();
82 95
83 // Sets the placement of the secondary display. Returns true if the secondary 96 // 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 97 // display can be moved, false otherwise. The false return value is temporary
85 // until mus fully supports this. 98 // until mus fully supports this.
86 bool SetSecondaryDisplayPlacement( 99 bool SetSecondaryDisplayPlacement(
87 display::DisplayPlacement::Position position, 100 display::DisplayPlacement::Position position,
88 int offset); 101 int offset);
89 102
103 // Configures |init_params| so that the widget will be created on the same
104 // display as |window|.
105 void ConfigureWidgetInitParamsForDisplay(
106 WmWindow* window,
107 views::Widget::InitParams* init_params);
108
109 // Adds |window| to the appropriate container in the primary root window.
110 void ParentWindowInPrimaryRootWindow(WmWindow* window);
111
112 // Adds |window| as as a transient child of |parent|.
113 void AddTransientChild(WmWindow* parent, WmWindow* window);
114
115 void RunAllPendingInMessageLoop();
116
90 protected: 117 protected:
91 // testing::Test: 118 // testing::Test:
92 void SetUp() override; 119 void SetUp() override;
93 void TearDown() override; 120 void TearDown() override;
94 121
95 private: 122 private:
96 std::unique_ptr<AshTestImpl> test_impl_; 123 std::unique_ptr<AshTestImpl> test_impl_;
97 124
98 DISALLOW_COPY_AND_ASSIGN(AshTest); 125 DISALLOW_COPY_AND_ASSIGN(AshTest);
99 }; 126 };
100 127
101 } // namespace ash 128 } // namespace ash
102 129
103 #endif // ASH_COMMON_TEST_ASH_TEST_H_ 130 #endif // ASH_COMMON_TEST_ASH_TEST_H_
OLDNEW
« no previous file with comments | « ash/aura/wm_window_aura.cc ('k') | ash/common/test/ash_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698