OLD | NEW |
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 #include "ash/mus/test/ash_test_impl_mus.h" | 5 #include "ash/mus/test/ash_test_impl_mus.h" |
6 | 6 |
7 #include "ash/common/session/session_controller.h" | |
8 #include "ash/common/test/ash_test.h" | 7 #include "ash/common/test/ash_test.h" |
9 #include "ash/common/wm_shell.h" | |
10 #include "ash/mus/bridge/wm_window_mus.h" | 8 #include "ash/mus/bridge/wm_window_mus.h" |
11 #include "ash/public/cpp/session_types.h" | |
12 #include "ash/public/interfaces/session_controller.mojom.h" | |
13 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
14 #include "services/ui/public/cpp/property_type_converters.h" | 10 #include "services/ui/public/cpp/property_type_converters.h" |
15 #include "services/ui/public/interfaces/window_manager.mojom.h" | 11 #include "services/ui/public/interfaces/window_manager.mojom.h" |
16 #include "ui/wm/core/window_util.h" | 12 #include "ui/wm/core/window_util.h" |
17 | 13 |
18 namespace ash { | 14 namespace ash { |
19 namespace mus { | 15 namespace mus { |
20 namespace { | 16 namespace { |
21 | 17 |
22 // WmTestBase is abstract as TestBody() is pure virtual (the various TEST | 18 // WmTestBase is abstract as TestBody() is pure virtual (the various TEST |
(...skipping 14 matching lines...) Expand all Loading... |
37 | 33 |
38 } // namespace | 34 } // namespace |
39 | 35 |
40 AshTestImplMus::AshTestImplMus() | 36 AshTestImplMus::AshTestImplMus() |
41 : wm_test_base_(base::MakeUnique<WmTestBaseImpl>()) {} | 37 : wm_test_base_(base::MakeUnique<WmTestBaseImpl>()) {} |
42 | 38 |
43 AshTestImplMus::~AshTestImplMus() {} | 39 AshTestImplMus::~AshTestImplMus() {} |
44 | 40 |
45 void AshTestImplMus::SetUp() { | 41 void AshTestImplMus::SetUp() { |
46 wm_test_base_->SetUp(); | 42 wm_test_base_->SetUp(); |
47 | |
48 // Most tests assume the user is logged in (and hence the shelf is created). | |
49 SimulateUserLogin(); | |
50 } | 43 } |
51 | 44 |
52 void AshTestImplMus::TearDown() { | 45 void AshTestImplMus::TearDown() { |
53 wm_test_base_->TearDown(); | 46 wm_test_base_->TearDown(); |
54 } | 47 } |
55 | 48 |
56 bool AshTestImplMus::SupportsMultipleDisplays() const { | 49 bool AshTestImplMus::SupportsMultipleDisplays() const { |
57 return wm_test_base_->SupportsMultipleDisplays(); | 50 return wm_test_base_->SupportsMultipleDisplays(); |
58 } | 51 } |
59 | 52 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 mojo::ConvertTo<std::vector<uint8_t>>( | 93 mojo::ConvertTo<std::vector<uint8_t>>( |
101 window->GetDisplayNearestWindow().id()); | 94 window->GetDisplayNearestWindow().id()); |
102 } | 95 } |
103 | 96 |
104 void AshTestImplMus::AddTransientChild(WmWindow* parent, WmWindow* window) { | 97 void AshTestImplMus::AddTransientChild(WmWindow* parent, WmWindow* window) { |
105 // TODO(sky): remove this as both classes can share same implementation now. | 98 // TODO(sky): remove this as both classes can share same implementation now. |
106 ::wm::AddTransientChild(WmWindowAura::GetAuraWindow(parent), | 99 ::wm::AddTransientChild(WmWindowAura::GetAuraWindow(parent), |
107 WmWindowAura::GetAuraWindow(window)); | 100 WmWindowAura::GetAuraWindow(window)); |
108 } | 101 } |
109 | 102 |
110 void AshTestImplMus::SimulateUserLogin() { | |
111 SessionController* session_controller = WmShell::Get()->session_controller(); | |
112 | |
113 // Simulate the first user logging in. | |
114 mojom::UserSessionPtr session = mojom::UserSession::New(); | |
115 session->session_id = 1; | |
116 session->type = user_manager::USER_TYPE_REGULAR; | |
117 const std::string email("ash.user@example.com"); | |
118 session->serialized_account_id = AccountId::FromUserEmail(email).Serialize(); | |
119 session->display_name = "Ash User"; | |
120 session->display_email = email; | |
121 session_controller->UpdateUserSession(std::move(session)); | |
122 | |
123 // Simulate the user session becoming active. | |
124 mojom::SessionInfoPtr info = mojom::SessionInfo::New(); | |
125 info->max_users = 10; | |
126 info->can_lock_screen = true; | |
127 info->should_lock_screen_automatically = false; | |
128 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; | |
129 info->state = session_manager::SessionState::ACTIVE; | |
130 session_controller->SetSessionInfo(std::move(info)); | |
131 } | |
132 | |
133 } // namespace mus | 103 } // namespace mus |
134 | 104 |
135 // static | 105 // static |
136 std::unique_ptr<AshTestImpl> AshTestImpl::Create() { | 106 std::unique_ptr<AshTestImpl> AshTestImpl::Create() { |
137 return base::MakeUnique<mus::AshTestImplMus>(); | 107 return base::MakeUnique<mus::AshTestImplMus>(); |
138 } | 108 } |
139 | 109 |
140 } // namespace ash | 110 } // namespace ash |
OLD | NEW |