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" |
7 #include "ash/common/test/ash_test.h" | 8 #include "ash/common/test/ash_test.h" |
| 9 #include "ash/common/wm_shell.h" |
8 #include "ash/mus/bridge/wm_window_mus.h" | 10 #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" |
9 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
10 #include "services/ui/public/cpp/property_type_converters.h" | 14 #include "services/ui/public/cpp/property_type_converters.h" |
11 #include "services/ui/public/interfaces/window_manager.mojom.h" | 15 #include "services/ui/public/interfaces/window_manager.mojom.h" |
12 #include "ui/wm/core/window_util.h" | 16 #include "ui/wm/core/window_util.h" |
13 | 17 |
14 namespace ash { | 18 namespace ash { |
15 namespace mus { | 19 namespace mus { |
16 namespace { | 20 namespace { |
17 | 21 |
18 // WmTestBase is abstract as TestBody() is pure virtual (the various TEST | 22 // WmTestBase is abstract as TestBody() is pure virtual (the various TEST |
(...skipping 14 matching lines...) Expand all Loading... |
33 | 37 |
34 } // namespace | 38 } // namespace |
35 | 39 |
36 AshTestImplMus::AshTestImplMus() | 40 AshTestImplMus::AshTestImplMus() |
37 : wm_test_base_(base::MakeUnique<WmTestBaseImpl>()) {} | 41 : wm_test_base_(base::MakeUnique<WmTestBaseImpl>()) {} |
38 | 42 |
39 AshTestImplMus::~AshTestImplMus() {} | 43 AshTestImplMus::~AshTestImplMus() {} |
40 | 44 |
41 void AshTestImplMus::SetUp() { | 45 void AshTestImplMus::SetUp() { |
42 wm_test_base_->SetUp(); | 46 wm_test_base_->SetUp(); |
| 47 |
| 48 // Most tests assume the user is logged in (and hence the shelf is created). |
| 49 SimulateUserLogin(); |
43 } | 50 } |
44 | 51 |
45 void AshTestImplMus::TearDown() { | 52 void AshTestImplMus::TearDown() { |
46 wm_test_base_->TearDown(); | 53 wm_test_base_->TearDown(); |
47 } | 54 } |
48 | 55 |
49 bool AshTestImplMus::SupportsMultipleDisplays() const { | 56 bool AshTestImplMus::SupportsMultipleDisplays() const { |
50 return wm_test_base_->SupportsMultipleDisplays(); | 57 return wm_test_base_->SupportsMultipleDisplays(); |
51 } | 58 } |
52 | 59 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 mojo::ConvertTo<std::vector<uint8_t>>( | 100 mojo::ConvertTo<std::vector<uint8_t>>( |
94 window->GetDisplayNearestWindow().id()); | 101 window->GetDisplayNearestWindow().id()); |
95 } | 102 } |
96 | 103 |
97 void AshTestImplMus::AddTransientChild(WmWindow* parent, WmWindow* window) { | 104 void AshTestImplMus::AddTransientChild(WmWindow* parent, WmWindow* window) { |
98 // TODO(sky): remove this as both classes can share same implementation now. | 105 // TODO(sky): remove this as both classes can share same implementation now. |
99 ::wm::AddTransientChild(WmWindowAura::GetAuraWindow(parent), | 106 ::wm::AddTransientChild(WmWindowAura::GetAuraWindow(parent), |
100 WmWindowAura::GetAuraWindow(window)); | 107 WmWindowAura::GetAuraWindow(window)); |
101 } | 108 } |
102 | 109 |
| 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 |
103 } // namespace mus | 133 } // namespace mus |
104 | 134 |
105 // static | 135 // static |
106 std::unique_ptr<AshTestImpl> AshTestImpl::Create() { | 136 std::unique_ptr<AshTestImpl> AshTestImpl::Create() { |
107 return base::MakeUnique<mus::AshTestImplMus>(); | 137 return base::MakeUnique<mus::AshTestImplMus>(); |
108 } | 138 } |
109 | 139 |
110 } // namespace ash | 140 } // namespace ash |
OLD | NEW |