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

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

Issue 2374893002: Adds AshTest (Closed)
Patch Set: real feedback 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/BUILD.gn ('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
(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/common/shell_window_ids.h"
12 #include "base/macros.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/display/manager/display_layout.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/wm/public/window_types.h"
17
18 namespace display {
19 class Display;
20 }
21
22 namespace ash {
23
24 class AshTestImpl;
25 class WmWindow;
26
27 // Wraps a WmWindow calling WmWindow::Destroy() from the destructor. WmWindow is
28 // owned by the corresponding window implementation. The only way to delete
29 // WmWindow is to call WmWindow::Destroy(), which deletes the corresponding
30 // window, then the WmWindow. This class calls WmWindow::Destroy() from its
31 // destructor.
James Cook 2016/09/28 18:13:52 Nice comment.
32 class WindowOwner {
33 public:
34 explicit WindowOwner(WmWindow* window);
35 ~WindowOwner();
36
37 WmWindow* window() { return window_; }
38
39 private:
40 WmWindow* window_;
41
42 DISALLOW_COPY_AND_ASSIGN(WindowOwner);
43 };
44
45 // Base class for ash tests. This class calls through to AshTestImpl for the
46 // real implementation. This class exists so that tests can be written to
47 // ash/common and run in both mus and aura.
48 //
49 // 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
51 // backend is not provided as a separate link target.
52 class AshTest : public testing::Test {
53 public:
54 AshTest();
55 ~AshTest() override;
56
57 bool SupportsMultipleDisplays() const;
58
59 // Update the display configuration as given in |display_spec|.
60 // See test::DisplayManagerTestApi::UpdateDisplay for more details.
61 void UpdateDisplay(const std::string& display_spec);
62
63 // 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,
65 // 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.
67 std::unique_ptr<WindowOwner> CreateTestWindow(
68 const gfx::Rect& bounds_in_screen = gfx::Rect(),
69 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL,
70 int shell_window_id = kShellWindowId_Invalid);
71
72 // Returns the Display for the secondary display. It's assumed there is two
73 // displays.
74 display::Display GetSecondaryDisplay();
75
76 // Sets the placement of the secondary display. Returns true if the secondary
77 // display can be moved, false otherwise. The false return value is temporary
78 // until mus fully supports this.
79 bool SetSecondaryDisplayPlacement(
80 display::DisplayPlacement::Position position,
81 int offset);
82
83 protected:
84 // testing::Test:
85 void SetUp() override;
86 void TearDown() override;
87
88 private:
89 std::unique_ptr<AshTestImpl> test_impl_;
90
91 DISALLOW_COPY_AND_ASSIGN(AshTest);
92 };
93
94 } // namespace ash
95
96 #endif // ASH_COMMON_TEST_ASH_TEST_H_
OLDNEW
« no previous file with comments | « ash/BUILD.gn ('k') | ash/common/test/ash_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698