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

Side by Side Diff: ash/system/user/tray_user_unittest.cc

Issue 184113005: Removal of drag window to user tray icon functionality (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
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/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_delegate.h" 11 #include "ash/shell_delegate.h"
12 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
13 #include "ash/system/user/tray_user.h" 13 #include "ash/system/user/tray_user.h"
14 #include "ash/system/user/tray_user_separator.h" 14 #include "ash/system/user/tray_user_separator.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "ash/test/test_session_state_delegate.h" 16 #include "ash/test/test_session_state_delegate.h"
17 #include "ash/test/test_shell_delegate.h" 17 #include "ash/test/test_shell_delegate.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "ui/aura/test/event_generator.h" 19 #include "ui/aura/test/event_generator.h"
20 #include "ui/gfx/animation/animation_container_element.h" 20 #include "ui/gfx/animation/animation_container_element.h"
21 #include "ui/views/view.h" 21 #include "ui/views/view.h"
22 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
23 23
24 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
25 #include "ash/system/tray/system_tray_notifier.h" 25 #include "ash/system/tray/system_tray_notifier.h"
oshima 2014/02/28 23:29:33 you probably don't need this anymore?
Mr4D (OOO till 08-26) 2014/03/01 17:21:34 Done.
26 #endif 26 #endif
27 27
28 namespace ash { 28 namespace ash {
29 namespace internal { 29 namespace internal {
30 30
31 class TrayUserTest : public ash::test::AshTestBase { 31 class TrayUserTest : public ash::test::AshTestBase {
32 public: 32 public:
33 TrayUserTest(); 33 TrayUserTest();
34 34
35 // testing::Test: 35 // testing::Test:
(...skipping 28 matching lines...) Expand all
64 // Note that the ownership of these items is on the shelf. 64 // Note that the ownership of these items is on the shelf.
65 std::vector<ash::internal::TrayUser*> tray_user_; 65 std::vector<ash::internal::TrayUser*> tray_user_;
66 66
67 // The separator between the tray users and the rest of the menu. 67 // The separator between the tray users and the rest of the menu.
68 // Note: The item will get owned by the shelf. 68 // Note: The item will get owned by the shelf.
69 TrayUserSeparator* tray_user_separator_; 69 TrayUserSeparator* tray_user_separator_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(TrayUserTest); 71 DISALLOW_COPY_AND_ASSIGN(TrayUserTest);
72 }; 72 };
73 73
74 #if defined(OS_CHROMEOS)
75 // The tray user test which tests functionality where multiple tray items are
76 // visible in the system tray.
77 class MultiTrayUserTest : public TrayUserTest {
78 public:
79 MultiTrayUserTest() {}
80
81 virtual void SetUp() OVERRIDE {
82 CommandLine* command_line = CommandLine::ForCurrentProcess();
83 command_line->AppendSwitch(ash::switches::kAshEnableMultiUserTray);
84 TrayUserTest::SetUp();
85 }
86
87 private:
88 DISALLOW_COPY_AND_ASSIGN(MultiTrayUserTest);
89 };
90 #endif
91
92 TrayUserTest::TrayUserTest() 74 TrayUserTest::TrayUserTest()
93 : shelf_(NULL), 75 : shelf_(NULL),
94 tray_(NULL), 76 tray_(NULL),
95 delegate_(NULL), 77 delegate_(NULL),
96 tray_user_separator_(NULL) { 78 tray_user_separator_(NULL) {
97 } 79 }
98 80
99 void TrayUserTest::SetUp() { 81 void TrayUserTest::SetUp() {
100 ash::test::AshTestBase::SetUp(); 82 ash::test::AshTestBase::SetUp();
101 shelf_ = Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 83 shelf_ = Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 241
260 // Switch to a new user - which has a capitalized name. 242 // Switch to a new user - which has a capitalized name.
261 ClickUserItem(&generator, 1); 243 ClickUserItem(&generator, 1);
262 EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserID(1)); 244 EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserID(1));
263 // Since the name is capitalized, the email should be different then the 245 // Since the name is capitalized, the email should be different then the
264 // user_id. 246 // user_id.
265 EXPECT_NE(delegate()->get_activated_user(), delegate()->GetUserEmail(1)); 247 EXPECT_NE(delegate()->get_activated_user(), delegate()->GetUserEmail(1));
266 tray()->CloseSystemBubble(); 248 tray()->CloseSystemBubble();
267 } 249 }
268 250
269 // Make sure that we show items for all users in the tray accordingly.
270 TEST_F(MultiTrayUserTest, CheckTrayUserItems) {
271 InitializeParameters(1, true);
272
273 int max_users = delegate()->GetMaximumNumberOfLoggedInUsers();
274 // Checking now for each amount of users that the proper items are visible in
275 // the tray. The proper item is hereby:
276 // 2 -> User #1
277 // 1 -> User #2
278 // 0 -> User #3
279 // Note: Tray items are required to populate system tray items as well as the
280 // system tray menu. The system tray menu changes it's appearance with the
281 // addition of more users, but the system tray does not create new items after
282 // it got created.
283 for (int present_users = 1; present_users <= max_users; ++present_users) {
284 // We simulate the user addition by telling the delegate the new number of
285 // users, then change all user tray items and finally tell the tray to
286 // re-layout itself.
287 delegate()->set_logged_in_users(present_users);
288 Shell::GetInstance()->system_tray_notifier()->NotifyUserAddedToSession();
289 tray()->Layout();
290
291 // Check that the tray items are being shown in the reverse order.
292 for (int i = 0; i < max_users; i++) {
293 gfx::Rect rect =
294 tray()->GetTrayItemViewForTest(tray_user(i))->GetBoundsInScreen();
295 if (max_users - 1 - i < present_users)
296 EXPECT_FALSE(rect.IsEmpty());
297 else
298 EXPECT_TRUE(rect.IsEmpty());
299 }
300 }
301
302 // Click on the last item to see that the user changes.
303 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
304 generator.set_async(false);
305
306 // Switch to a new user - again, note that we have to click on the reverse
307 // item in the list. Since the first clickable item is 1, we get user #2.
308 gfx::Point point =
309 tray()->GetTrayItemViewForTest(tray_user(1))->
310 GetBoundsInScreen().CenterPoint();
311
312 generator.MoveMouseTo(point.x(), point.y());
313 generator.ClickLeftButton();
314 EXPECT_EQ(delegate()->get_activated_user(), delegate()->GetUserID(1));
315 }
316
317 #endif 251 #endif
318 252
319 } // namespace internal 253 } // namespace internal
320 } // namespace ash 254 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698