| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/shell_delegate.h" | 8 #include "ash/common/shell_delegate.h" |
| 9 #include "ash/common/system/tray/system_tray.h" | 9 #include "ash/common/system/tray/system_tray.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // We then add also the separator. | 98 // We then add also the separator. |
| 99 tray_user_separator_ = new TrayUserSeparator(tray_); | 99 tray_user_separator_ = new TrayUserSeparator(tray_); |
| 100 tray_->AddTrayItem(base::WrapUnique(tray_user_separator_)); | 100 tray_->AddTrayItem(base::WrapUnique(tray_user_separator_)); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void TrayUserTest::ShowTrayMenu(ui::test::EventGenerator* generator) { | 104 void TrayUserTest::ShowTrayMenu(ui::test::EventGenerator* generator) { |
| 105 gfx::Point center = tray()->GetBoundsInScreen().CenterPoint(); | 105 gfx::Point center = tray()->GetBoundsInScreen().CenterPoint(); |
| 106 | 106 |
| 107 generator->MoveMouseTo(center.x(), center.y()); | 107 generator->MoveMouseTo(center.x(), center.y()); |
| 108 EXPECT_FALSE(tray()->IsAnyBubbleVisible()); | 108 EXPECT_FALSE(tray()->IsSystemBubbleVisible()); |
| 109 generator->ClickLeftButton(); | 109 generator->ClickLeftButton(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void TrayUserTest::MoveOverUserItem(ui::test::EventGenerator* generator, | 112 void TrayUserTest::MoveOverUserItem(ui::test::EventGenerator* generator, |
| 113 int index) { | 113 int index) { |
| 114 gfx::Point center = | 114 gfx::Point center = |
| 115 tray_user(index)->GetUserPanelBoundsInScreenForTest().CenterPoint(); | 115 tray_user(index)->GetUserPanelBoundsInScreenForTest().CenterPoint(); |
| 116 | 116 |
| 117 generator->MoveMouseTo(center.x(), center.y()); | 117 generator->MoveMouseTo(center.x(), center.y()); |
| 118 } | 118 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Make sure that in single user mode the user panel cannot be activated and no | 139 // Make sure that in single user mode the user panel cannot be activated and no |
| 140 // separators are being created. | 140 // separators are being created. |
| 141 TEST_F(TrayUserTest, SingleUserModeDoesNotAllowAddingUser) { | 141 TEST_F(TrayUserTest, SingleUserModeDoesNotAllowAddingUser) { |
| 142 InitializeParameters(1, false); | 142 InitializeParameters(1, false); |
| 143 | 143 |
| 144 // Move the mouse over the status area and click to open the status menu. | 144 // Move the mouse over the status area and click to open the status menu. |
| 145 ui::test::EventGenerator& generator = GetEventGenerator(); | 145 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 146 | 146 |
| 147 EXPECT_FALSE(tray()->IsAnyBubbleVisible()); | 147 EXPECT_FALSE(tray()->IsSystemBubbleVisible()); |
| 148 | 148 |
| 149 for (int i = 0; i < delegate()->GetMaximumNumberOfLoggedInUsers(); i++) | 149 for (int i = 0; i < delegate()->GetMaximumNumberOfLoggedInUsers(); i++) |
| 150 EXPECT_EQ(TrayUser::HIDDEN, tray_user(i)->GetStateForTest()); | 150 EXPECT_EQ(TrayUser::HIDDEN, tray_user(i)->GetStateForTest()); |
| 151 if (!UseMd()) | 151 if (!UseMd()) |
| 152 EXPECT_FALSE(tray_user_separator()->separator_shown()); | 152 EXPECT_FALSE(tray_user_separator()->separator_shown()); |
| 153 | 153 |
| 154 ShowTrayMenu(&generator); | 154 ShowTrayMenu(&generator); |
| 155 | 155 |
| 156 EXPECT_TRUE(tray()->HasSystemBubble()); | 156 EXPECT_TRUE(tray()->HasSystemBubble()); |
| 157 EXPECT_TRUE(tray()->IsAnyBubbleVisible()); | 157 EXPECT_TRUE(tray()->IsSystemBubbleVisible()); |
| 158 | 158 |
| 159 for (int i = 0; i < delegate()->GetMaximumNumberOfLoggedInUsers(); i++) | 159 for (int i = 0; i < delegate()->GetMaximumNumberOfLoggedInUsers(); i++) |
| 160 EXPECT_EQ(i == 0 ? TrayUser::SHOWN : TrayUser::HIDDEN, | 160 EXPECT_EQ(i == 0 ? TrayUser::SHOWN : TrayUser::HIDDEN, |
| 161 tray_user(i)->GetStateForTest()); | 161 tray_user(i)->GetStateForTest()); |
| 162 if (!UseMd()) | 162 if (!UseMd()) |
| 163 EXPECT_FALSE(tray_user_separator()->separator_shown()); | 163 EXPECT_FALSE(tray_user_separator()->separator_shown()); |
| 164 tray()->CloseSystemBubble(); | 164 tray()->CloseSystemBubble(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 TEST_F(TrayUserTest, AccessibleLabelContainsSingleUserInfo) { | 167 TEST_F(TrayUserTest, AccessibleLabelContainsSingleUserInfo) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 ui::test::EventGenerator& generator = GetEventGenerator(); | 205 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 206 generator.set_async(false); | 206 generator.set_async(false); |
| 207 | 207 |
| 208 int max_users = delegate()->GetMaximumNumberOfLoggedInUsers(); | 208 int max_users = delegate()->GetMaximumNumberOfLoggedInUsers(); |
| 209 // Checking now for each amount of users that the correct is done. | 209 // Checking now for each amount of users that the correct is done. |
| 210 for (int j = 1; j < max_users; j++) { | 210 for (int j = 1; j < max_users; j++) { |
| 211 // Set the number of logged in users. | 211 // Set the number of logged in users. |
| 212 delegate()->set_logged_in_users(j); | 212 delegate()->set_logged_in_users(j); |
| 213 | 213 |
| 214 // Verify that nothing is shown. | 214 // Verify that nothing is shown. |
| 215 EXPECT_FALSE(tray()->IsAnyBubbleVisible()); | 215 EXPECT_FALSE(tray()->IsSystemBubbleVisible()); |
| 216 for (int i = 0; i < max_users; i++) | 216 for (int i = 0; i < max_users; i++) |
| 217 EXPECT_FALSE(tray_user(i)->GetStateForTest()); | 217 EXPECT_FALSE(tray_user(i)->GetStateForTest()); |
| 218 if (!UseMd()) | 218 if (!UseMd()) |
| 219 EXPECT_FALSE(tray_user_separator()->separator_shown()); | 219 EXPECT_FALSE(tray_user_separator()->separator_shown()); |
| 220 // After clicking on the tray the menu should get shown and for each logged | 220 // After clicking on the tray the menu should get shown and for each logged |
| 221 // in user we should get a visible item. In addition, the separator should | 221 // in user we should get a visible item. In addition, the separator should |
| 222 // show up when we reach more than one user. | 222 // show up when we reach more than one user. |
| 223 ShowTrayMenu(&generator); | 223 ShowTrayMenu(&generator); |
| 224 | 224 |
| 225 EXPECT_TRUE(tray()->HasSystemBubble()); | 225 EXPECT_TRUE(tray()->HasSystemBubble()); |
| 226 EXPECT_TRUE(tray()->IsAnyBubbleVisible()); | 226 EXPECT_TRUE(tray()->IsSystemBubbleVisible()); |
| 227 for (int i = 0; i < max_users; i++) { | 227 for (int i = 0; i < max_users; i++) { |
| 228 EXPECT_EQ(i < j ? TrayUser::SHOWN : TrayUser::HIDDEN, | 228 EXPECT_EQ(i < j ? TrayUser::SHOWN : TrayUser::HIDDEN, |
| 229 tray_user(i)->GetStateForTest()); | 229 tray_user(i)->GetStateForTest()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Check the visibility of the separator. | 232 // Check the visibility of the separator. |
| 233 if (!UseMd()) | 233 if (!UseMd()) |
| 234 EXPECT_EQ(j > 1 ? true : false, tray_user_separator()->separator_shown()); | 234 EXPECT_EQ(j > 1 ? true : false, tray_user_separator()->separator_shown()); |
| 235 | 235 |
| 236 // Move the mouse over the user item and it should hover. | 236 // Move the mouse over the user item and it should hover. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 247 EXPECT_EQ(j == max_users ? TrayUser::ACTIVE_BUT_DISABLED : TrayUser::ACTIVE, | 247 EXPECT_EQ(j == max_users ? TrayUser::ACTIVE_BUT_DISABLED : TrayUser::ACTIVE, |
| 248 tray_user(0)->GetStateForTest()); | 248 tray_user(0)->GetStateForTest()); |
| 249 | 249 |
| 250 // Click the button again to see that the menu goes away. | 250 // Click the button again to see that the menu goes away. |
| 251 ClickUserItem(&generator, 0); | 251 ClickUserItem(&generator, 0); |
| 252 MoveOverUserItem(&generator, 0); | 252 MoveOverUserItem(&generator, 0); |
| 253 EXPECT_EQ(TrayUser::HOVERED, tray_user(0)->GetStateForTest()); | 253 EXPECT_EQ(TrayUser::HOVERED, tray_user(0)->GetStateForTest()); |
| 254 | 254 |
| 255 // Close and check that everything is deleted. | 255 // Close and check that everything is deleted. |
| 256 tray()->CloseSystemBubble(); | 256 tray()->CloseSystemBubble(); |
| 257 EXPECT_FALSE(tray()->IsAnyBubbleVisible()); | 257 EXPECT_FALSE(tray()->IsSystemBubbleVisible()); |
| 258 for (int i = 0; i < delegate()->GetMaximumNumberOfLoggedInUsers(); i++) | 258 for (int i = 0; i < delegate()->GetMaximumNumberOfLoggedInUsers(); i++) |
| 259 EXPECT_EQ(TrayUser::HIDDEN, tray_user(i)->GetStateForTest()); | 259 EXPECT_EQ(TrayUser::HIDDEN, tray_user(i)->GetStateForTest()); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 // Make sure that user changing gets properly executed. | 263 // Make sure that user changing gets properly executed. |
| 264 TEST_F(TrayUserTest, MultiUserModeButtonClicks) { | 264 TEST_F(TrayUserTest, MultiUserModeButtonClicks) { |
| 265 // Have two users. | 265 // Have two users. |
| 266 InitializeParameters(2, true); | 266 InitializeParameters(2, true); |
| 267 ui::test::EventGenerator& generator = GetEventGenerator(); | 267 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 268 ShowTrayMenu(&generator); | 268 ShowTrayMenu(&generator); |
| 269 | 269 |
| 270 // Switch to a new user - which has a capitalized name. | 270 // Switch to a new user - which has a capitalized name. |
| 271 ClickUserItem(&generator, 1); | 271 ClickUserItem(&generator, 1); |
| 272 const user_manager::UserInfo* active_user = delegate()->GetActiveUserInfo(); | 272 const user_manager::UserInfo* active_user = delegate()->GetActiveUserInfo(); |
| 273 const user_manager::UserInfo* second_user = delegate()->GetUserInfo(1); | 273 const user_manager::UserInfo* second_user = delegate()->GetUserInfo(1); |
| 274 EXPECT_EQ(active_user->GetAccountId(), second_user->GetAccountId()); | 274 EXPECT_EQ(active_user->GetAccountId(), second_user->GetAccountId()); |
| 275 // Since the name is capitalized, the email should be different than the | 275 // Since the name is capitalized, the email should be different than the |
| 276 // user_id. | 276 // user_id. |
| 277 EXPECT_NE(active_user->GetAccountId().GetUserEmail(), | 277 EXPECT_NE(active_user->GetAccountId().GetUserEmail(), |
| 278 second_user->GetDisplayEmail()); | 278 second_user->GetDisplayEmail()); |
| 279 tray()->CloseSystemBubble(); | 279 tray()->CloseSystemBubble(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace ash | 282 } // namespace ash |
| OLD | NEW |