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

Side by Side Diff: ash/system/supervised/tray_supervised_user_unittest.cc

Issue 2931643002: chromeos: Introduce ash::SystemTrayTestApi (Closed)
Patch Set: review comments Created 3 years, 6 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/session/tray_session_length_limit_unittest.cc ('k') | ash/system/tray/system_tray.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/supervised/tray_supervised_user.h" 5 #include "ash/system/supervised/tray_supervised_user.h"
6 6
7 #include "ash/login_status.h" 7 #include "ash/login_status.h"
8 #include "ash/session/session_controller.h" 8 #include "ash/session/session_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/tray/label_tray_view.h" 10 #include "ash/system/tray/label_tray_view.h"
11 #include "ash/system/tray/system_tray.h" 11 #include "ash/system/tray/system_tray.h"
12 #include "ash/system/tray/system_tray_test_api.h"
12 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
13 #include "ash/test/test_session_controller_client.h" 14 #include "ash/test/test_session_controller_client.h"
14 #include "ash/test/test_system_tray_delegate.h" 15 #include "ash/test/test_system_tray_delegate.h"
15 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "ui/message_center/message_center.h" 18 #include "ui/message_center/message_center.h"
18 #include "ui/message_center/notification.h" 19 #include "ui/message_center/notification.h"
19 #include "ui/message_center/notification_list.h" 20 #include "ui/message_center/notification_list.h"
20 #include "ui/message_center/notification_types.h" 21 #include "ui/message_center/notification_types.h"
21 #include "ui/views/view.h" 22 #include "ui/views/view.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ASSERT_TRUE(notification); 93 ASSERT_TRUE(notification);
93 EXPECT_EQ( 94 EXPECT_EQ(
94 "Usage and history of this user can be reviewed by the manager " 95 "Usage and history of this user can be reviewed by the manager "
95 "(parent2@test.com) on chrome.com.", 96 "(parent2@test.com) on chrome.com.",
96 UTF16ToUTF8(notification->message())); 97 UTF16ToUTF8(notification->message()));
97 } 98 }
98 99
99 // Verifies an item is created for a supervised user. 100 // Verifies an item is created for a supervised user.
100 TEST_F(TraySupervisedUserTest, CreateDefaultView) { 101 TEST_F(TraySupervisedUserTest, CreateDefaultView) {
101 TraySupervisedUser* tray = 102 TraySupervisedUser* tray =
102 GetPrimarySystemTray()->GetTraySupervisedUserForTesting(); 103 SystemTrayTestApi(GetPrimarySystemTray()).tray_supervised_user();
103 SessionController* session = Shell::Get()->session_controller(); 104 SessionController* session = Shell::Get()->session_controller();
104 ASSERT_FALSE(session->IsActiveUserSessionStarted()); 105 ASSERT_FALSE(session->IsActiveUserSessionStarted());
105 106
106 // Before login there is no supervised user item. 107 // Before login there is no supervised user item.
107 const LoginStatus unused = LoginStatus::NOT_LOGGED_IN; 108 const LoginStatus unused = LoginStatus::NOT_LOGGED_IN;
108 EXPECT_FALSE(tray->CreateDefaultView(unused)); 109 EXPECT_FALSE(tray->CreateDefaultView(unused));
109 110
110 // Simulate a supervised user logging in. 111 // Simulate a supervised user logging in.
111 test::TestSessionControllerClient* client = GetSessionControllerClient(); 112 test::TestSessionControllerClient* client = GetSessionControllerClient();
112 client->Reset(); 113 client->Reset();
113 client->AddUserSession("child@test.com", user_manager::USER_TYPE_SUPERVISED); 114 client->AddUserSession("child@test.com", user_manager::USER_TYPE_SUPERVISED);
114 client->SetSessionState(session_manager::SessionState::ACTIVE); 115 client->SetSessionState(session_manager::SessionState::ACTIVE);
115 mojom::UserSessionPtr user_session = session->GetUserSession(0)->Clone(); 116 mojom::UserSessionPtr user_session = session->GetUserSession(0)->Clone();
116 user_session->custodian_email = "parent@test.com"; 117 user_session->custodian_email = "parent@test.com";
117 session->UpdateUserSession(std::move(user_session)); 118 session->UpdateUserSession(std::move(user_session));
118 119
119 // Now there is a supervised user item. 120 // Now there is a supervised user item.
120 std::unique_ptr<views::View> view = 121 std::unique_ptr<views::View> view =
121 base::WrapUnique(tray->CreateDefaultView(unused)); 122 base::WrapUnique(tray->CreateDefaultView(unused));
122 ASSERT_TRUE(view); 123 ASSERT_TRUE(view);
123 EXPECT_EQ( 124 EXPECT_EQ(
124 "Usage and history of this user can be reviewed by the manager " 125 "Usage and history of this user can be reviewed by the manager "
125 "(parent@test.com) on chrome.com.", 126 "(parent@test.com) on chrome.com.",
126 UTF16ToUTF8(static_cast<LabelTrayView*>(view.get())->message())); 127 UTF16ToUTF8(static_cast<LabelTrayView*>(view.get())->message()));
127 } 128 }
128 129
129 } // namespace ash 130 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/session/tray_session_length_limit_unittest.cc ('k') | ash/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698