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 #include "ash/mus/test/ash_test_impl_mus.h" | |
6 | |
7 #include "ash/test/ash_test.h" | |
8 #include "ash/wm_window.h" | |
9 #include "base/command_line.h" | |
10 #include "base/memory/ptr_util.h" | |
11 #include "services/ui/public/cpp/property_type_converters.h" | |
12 #include "services/ui/public/interfaces/window_manager.mojom.h" | |
13 #include "ui/aura/window.h" | |
14 #include "ui/display/display_switches.h" | |
15 #include "ui/wm/core/window_util.h" | |
16 | |
17 namespace ash { | |
18 namespace mus { | |
19 namespace { | |
20 | |
21 // WmTestBase is abstract as TestBody() is pure virtual (the various TEST | |
22 // macros have the implementation). In order to create WmTestBase we have to | |
23 // subclass with an empty implementation of TestBody(). That's ok as the class | |
24 // isn't used as a normal test here. | |
25 class WmTestBaseImpl : public WmTestBase { | |
26 public: | |
27 WmTestBaseImpl() {} | |
28 ~WmTestBaseImpl() override {} | |
29 | |
30 // WmTestBase: | |
31 void TestBody() override {} | |
32 | |
33 private: | |
34 DISALLOW_COPY_AND_ASSIGN(WmTestBaseImpl); | |
35 }; | |
36 | |
37 } // namespace | |
38 | |
39 AshTestImplMus::AshTestImplMus() | |
40 : wm_test_base_(base::MakeUnique<WmTestBaseImpl>()) {} | |
41 | |
42 AshTestImplMus::~AshTestImplMus() {} | |
43 | |
44 void AshTestImplMus::SetUp() { | |
45 // This matches what AshTestBase does. | |
46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
47 if (!command_line->HasSwitch(::switches::kHostWindowBounds)) { | |
48 command_line->AppendSwitchASCII(::switches::kHostWindowBounds, | |
49 "1+1-800x600"); | |
50 } | |
51 | |
52 wm_test_base_->SetUp(); | |
53 } | |
54 | |
55 void AshTestImplMus::TearDown() { | |
56 wm_test_base_->TearDown(); | |
57 } | |
58 | |
59 void AshTestImplMus::UpdateDisplay(const std::string& display_spec) { | |
60 wm_test_base_->UpdateDisplay(display_spec); | |
61 } | |
62 | |
63 std::unique_ptr<WindowOwner> AshTestImplMus::CreateTestWindow( | |
64 const gfx::Rect& bounds_in_screen, | |
65 ui::wm::WindowType type, | |
66 int shell_window_id) { | |
67 aura::Window* window = | |
68 wm_test_base_->CreateTestWindow(bounds_in_screen, type); | |
69 window->set_id(shell_window_id); | |
70 return base::MakeUnique<WindowOwner>(WmWindow::Get(window)); | |
71 } | |
72 | |
73 std::unique_ptr<WindowOwner> AshTestImplMus::CreateToplevelTestWindow( | |
74 const gfx::Rect& bounds_in_screen, | |
75 int shell_window_id) { | |
76 // For mus CreateTestWindow() creates top level windows (assuming | |
77 // WINDOW_TYPE_NORMAL). | |
78 return CreateTestWindow(bounds_in_screen, ui::wm::WINDOW_TYPE_NORMAL, | |
79 shell_window_id); | |
80 } | |
81 | |
82 display::Display AshTestImplMus::GetSecondaryDisplay() { | |
83 return wm_test_base_->GetSecondaryDisplay(); | |
84 } | |
85 | |
86 bool AshTestImplMus::SetSecondaryDisplayPlacement( | |
87 display::DisplayPlacement::Position position, | |
88 int offset) { | |
89 NOTIMPLEMENTED(); | |
90 return false; | |
91 } | |
92 | |
93 void AshTestImplMus::ConfigureWidgetInitParamsForDisplay( | |
94 WmWindow* window, | |
95 views::Widget::InitParams* init_params) { | |
96 init_params->context = WmWindow::GetAuraWindow(window); | |
97 init_params | |
98 ->mus_properties[ui::mojom::WindowManager::kDisplayId_InitProperty] = | |
99 mojo::ConvertTo<std::vector<uint8_t>>( | |
100 window->GetDisplayNearestWindow().id()); | |
101 } | |
102 | |
103 void AshTestImplMus::AddTransientChild(WmWindow* parent, WmWindow* window) { | |
104 // TODO(sky): remove this as both classes can share same implementation now. | |
105 ::wm::AddTransientChild(WmWindow::GetAuraWindow(parent), | |
106 WmWindow::GetAuraWindow(window)); | |
107 } | |
108 | |
109 } // namespace mus | |
110 } // namespace ash | |
OLD | NEW |