Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/views/widget/widget.h" | |
| 17 #include "ui/wm/public/window_types.h" | |
| 18 | |
| 19 namespace display { | |
| 20 class Display; | |
| 21 } | |
| 22 | |
| 23 namespace ash { | |
| 24 | |
| 25 class AshTestImpl; | |
| 26 class WmWindow; | |
| 27 | |
| 28 // Wraps a WmWindow calling WmWindow::Destroy() from the destructor. | |
|
James Cook
2016/09/28 01:19:42
nit: Can you add another line or two here explaini
sky
2016/09/28 17:31:45
Done.
| |
| 29 class WindowOwner { | |
| 30 public: | |
| 31 explicit WindowOwner(WmWindow* window); | |
| 32 ~WindowOwner(); | |
| 33 | |
| 34 WmWindow* window() { return window_; } | |
| 35 | |
| 36 private: | |
| 37 WmWindow* window_; | |
| 38 | |
| 39 DISALLOW_COPY_AND_ASSIGN(WindowOwner); | |
| 40 }; | |
| 41 | |
| 42 // Base class for ash tests. This class calls through to AshTestImpl for the | |
| 43 // real implementation. This class exists so that tests can be written to | |
| 44 // ash/common and run in both mus and aura. | |
| 45 // | |
| 46 // The implementation of AshTestImpl that is used depends upon gn targets. To | |
| 47 // use the aura backend depend on "//ash:ash_with_aura_test_support." The mus | |
| 48 // backend is not provided as a separate link target. | |
|
James Cook
2016/09/28 01:19:42
For my knowledge: Is that because mash_unittests w
sky
2016/09/28 17:31:45
The only place that needs the mus implementation i
| |
| 49 class AshTest : public testing::Test { | |
| 50 public: | |
| 51 AshTest(); | |
| 52 ~AshTest() override; | |
| 53 | |
| 54 bool SupportsMultipleDisplays() const; | |
| 55 | |
| 56 // Update the display configuration as given in |display_spec|. | |
| 57 // See test::DisplayManagerTestApi::UpdateDisplay for more details. | |
| 58 void UpdateDisplay(const std::string& display_spec); | |
| 59 | |
| 60 // Creates a top level visible window in the appropriate container. If | |
| 61 // |bounds_is_screen| is empty the window is added to the primary root window, | |
|
James Cook
2016/09/28 01:19:42
nit: bounds_in_screen
sky
2016/09/28 17:31:45
Done.
| |
| 62 // otherwise the window is added to the display matching |bounds_in_screen|. | |
| 63 // |shell_window_id| is the shell window id to give to the new window. | |
| 64 std::unique_ptr<WindowOwner> CreateTestWindow( | |
| 65 const gfx::Rect& bounds_in_screen = gfx::Rect(), | |
| 66 ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL, | |
| 67 int shell_window_id = kShellWindowId_Invalid); | |
| 68 | |
| 69 // Returns the Display for the secondary display. It's assumed there is two | |
|
James Cook
2016/09/28 01:19:42
super nit: "there is" -> "there are"
sky
2016/09/28 17:31:45
Done.
| |
| 70 // displays. | |
| 71 display::Display GetSecondaryDisplay(); | |
| 72 | |
| 73 // Sets the placement of the secondary display. Returns true if the secondary | |
| 74 // display can be moved, false otherwise. The false return value is temporary | |
| 75 // until mus fully supports this. | |
| 76 bool SetSecondaryDisplayPlacement( | |
| 77 display::DisplayPlacement::Position position, | |
| 78 int offset); | |
| 79 | |
| 80 // Configures |init_params| so that the resulting Widget will appear on the | |
| 81 // display |window| is on. | |
| 82 void ConfigureWidgetInitParamsForDisplay( | |
|
James Cook
2016/09/28 01:19:42
It seems a little odd that this doesn't take a Dis
sky
2016/09/28 17:31:45
I'll need it shortly, but I can push it to the pat
| |
| 83 WmWindow* window, | |
| 84 views::Widget::InitParams* init_params); | |
| 85 | |
| 86 protected: | |
| 87 // testing::Test: | |
| 88 void SetUp() override; | |
| 89 void TearDown() override; | |
| 90 | |
| 91 private: | |
| 92 std::unique_ptr<AshTestImpl> test_impl_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(AshTest); | |
| 95 }; | |
| 96 | |
| 97 } // namespace ash | |
| 98 | |
| 99 #endif // ASH_COMMON_TEST_ASH_TEST_H_ | |
| OLD | NEW |