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

Side by Side Diff: ash/test/test_session_controller_client.cc

Issue 2911493002: cros: Pull user info from session_controller_client.mojom into separate mojom. (Closed)
Patch Set: Fix ordering in typemaps Created 3 years, 7 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/system/user/user_view.cc ('k') | chrome/browser/ui/ash/session_controller_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/test/test_session_controller_client.h" 5 #include "ash/test/test_session_controller_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/login_status.h" 10 #include "ash/login_status.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Updates session state after adding user sessions. 94 // Updates session state after adding user sessions.
95 SetSessionState(session_manager::SessionState::ACTIVE); 95 SetSessionState(session_manager::SessionState::ACTIVE);
96 } 96 }
97 97
98 void TestSessionControllerClient::AddUserSession( 98 void TestSessionControllerClient::AddUserSession(
99 const std::string& display_email, 99 const std::string& display_email,
100 user_manager::UserType user_type, 100 user_manager::UserType user_type,
101 bool enable_settings) { 101 bool enable_settings) {
102 mojom::UserSessionPtr session = mojom::UserSession::New(); 102 mojom::UserSessionPtr session = mojom::UserSession::New();
103 session->session_id = ++fake_session_id_; 103 session->session_id = ++fake_session_id_;
104 session->type = user_type; 104 session->user_info = mojom::UserInfo::New();
105 session->account_id = 105 session->user_info->type = user_type;
106 session->user_info->account_id =
106 AccountId::FromUserEmail(GetUserIdFromEmail(display_email)); 107 AccountId::FromUserEmail(GetUserIdFromEmail(display_email));
107 session->display_name = "Über tray Über tray Über tray Über tray"; 108 session->user_info->display_name = "Über tray Über tray Über tray Über tray";
108 session->display_email = display_email; 109 session->user_info->display_email = display_email;
109 session->should_enable_settings = enable_settings; 110 session->should_enable_settings = enable_settings;
110 session->should_show_notification_tray = true; 111 session->should_show_notification_tray = true;
111 controller_->UpdateUserSession(std::move(session)); 112 controller_->UpdateUserSession(std::move(session));
112 } 113 }
113 114
114 void TestSessionControllerClient::UnlockScreen() { 115 void TestSessionControllerClient::UnlockScreen() {
115 SetSessionState(session_manager::SessionState::ACTIVE); 116 SetSessionState(session_manager::SessionState::ACTIVE);
116 } 117 }
117 118
118 void TestSessionControllerClient::RequestLockScreen() { 119 void TestSessionControllerClient::RequestLockScreen() {
119 SetSessionState(session_manager::SessionState::LOCKED); 120 SetSessionState(session_manager::SessionState::LOCKED);
120 } 121 }
121 122
122 void TestSessionControllerClient::SwitchActiveUser( 123 void TestSessionControllerClient::SwitchActiveUser(
123 const AccountId& account_id) { 124 const AccountId& account_id) {
124 std::vector<uint32_t> session_order; 125 std::vector<uint32_t> session_order;
125 session_order.reserve(controller_->GetUserSessions().size()); 126 session_order.reserve(controller_->GetUserSessions().size());
126 127
127 for (const auto& user_session : controller_->GetUserSessions()) { 128 for (const auto& user_session : controller_->GetUserSessions()) {
128 if (user_session->account_id == account_id) { 129 if (user_session->user_info->account_id == account_id) {
129 session_order.insert(session_order.begin(), user_session->session_id); 130 session_order.insert(session_order.begin(), user_session->session_id);
130 } else { 131 } else {
131 session_order.push_back(user_session->session_id); 132 session_order.push_back(user_session->session_id);
132 } 133 }
133 } 134 }
134 135
135 controller_->SetUserSessionOrder(session_order); 136 controller_->SetUserSessionOrder(session_order);
136 } 137 }
137 138
138 void TestSessionControllerClient::CycleActiveUser( 139 void TestSessionControllerClient::CycleActiveUser(
(...skipping 27 matching lines...) Expand all
166 // Maps session id to AccountId and call SwitchActiveUser. 167 // Maps session id to AccountId and call SwitchActiveUser.
167 auto it = std::find_if(sessions.begin(), sessions.end(), 168 auto it = std::find_if(sessions.begin(), sessions.end(),
168 [session_id](const mojom::UserSessionPtr& session) { 169 [session_id](const mojom::UserSessionPtr& session) {
169 return session && session->session_id == session_id; 170 return session && session->session_id == session_id;
170 }); 171 });
171 if (it == sessions.end()) { 172 if (it == sessions.end()) {
172 NOTREACHED(); 173 NOTREACHED();
173 return; 174 return;
174 } 175 }
175 176
176 SwitchActiveUser((*it)->account_id); 177 SwitchActiveUser((*it)->user_info->account_id);
177 } 178 }
178 179
179 } // namespace test 180 } // namespace test
180 } // namespace ash 181 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/user_view.cc ('k') | chrome/browser/ui/ash/session_controller_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698