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/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/accessibility/ax_view_state.h" | 22 #include "ui/accessibility/ax_view_state.h" |
23 #include "ui/events/test/event_generator.h" | 23 #include "ui/events/test/event_generator.h" |
24 #include "ui/gfx/animation/animation_container_element.h" | 24 #include "ui/gfx/animation/animation_container_element.h" |
25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 | 27 |
28 namespace ash { | 28 namespace ash { |
29 | 29 |
30 class TrayUserTest : public ash::test::AshTestBase { | 30 class TrayUserTest : public ash::test::AshTestBase { |
31 public: | 31 public: |
32 TrayUserTest(); | 32 TrayUserTest() = default; |
33 | 33 |
34 // testing::Test: | 34 // testing::Test: |
35 void SetUp() override; | 35 void SetUp() override; |
36 | 36 |
37 // This has to be called prior to first use with the proper configuration. | 37 // This has to be called prior to first use with the proper configuration. |
38 void InitializeParameters(int users_logged_in, bool multiprofile); | 38 void InitializeParameters(int users_logged_in, bool multiprofile); |
39 | 39 |
40 // Show the system tray menu using the provided event generator. | 40 // Show the system tray menu using the provided event generator. |
41 void ShowTrayMenu(ui::test::EventGenerator* generator); | 41 void ShowTrayMenu(ui::test::EventGenerator* generator); |
42 | 42 |
43 // Move the mouse over the user item. | 43 // Move the mouse over the user item. |
44 void MoveOverUserItem(ui::test::EventGenerator* generator, int index); | 44 void MoveOverUserItem(ui::test::EventGenerator* generator, int index); |
45 | 45 |
46 // Click on the user item. Note that the tray menu needs to be shown. | 46 // Click on the user item. Note that the tray menu needs to be shown. |
47 void ClickUserItem(ui::test::EventGenerator* generator, int index); | 47 void ClickUserItem(ui::test::EventGenerator* generator, int index); |
48 | 48 |
49 // Accessors to various system components. | 49 // Accessors to various system components. |
50 ShelfLayoutManager* shelf() { return shelf_; } | |
51 SystemTray* tray() { return tray_; } | 50 SystemTray* tray() { return tray_; } |
52 ash::test::TestSessionStateDelegate* delegate() { return delegate_; } | 51 ash::test::TestSessionStateDelegate* delegate() { return delegate_; } |
53 ash::TrayUser* tray_user(int index) { return tray_user_[index]; } | 52 ash::TrayUser* tray_user(int index) { return tray_user_[index]; } |
54 ash::TrayUserSeparator* tray_user_separator() { return tray_user_separator_; } | 53 ash::TrayUserSeparator* tray_user_separator() { return tray_user_separator_; } |
55 | 54 |
56 private: | 55 private: |
57 ShelfLayoutManager* shelf_; | 56 SystemTray* tray_ = nullptr; |
58 SystemTray* tray_; | 57 ash::test::TestSessionStateDelegate* delegate_ = nullptr; |
59 ash::test::TestSessionStateDelegate* delegate_; | |
60 | 58 |
61 // Note that the ownership of these items is on the shelf. | 59 // Note that the ownership of these items is on the shelf. |
62 std::vector<ash::TrayUser*> tray_user_; | 60 std::vector<ash::TrayUser*> tray_user_; |
63 | 61 |
64 // The separator between the tray users and the rest of the menu. | 62 // The separator between the tray users and the rest of the menu. |
65 // Note: The item will get owned by the shelf. | 63 // Note: The item will get owned by the shelf. |
66 TrayUserSeparator* tray_user_separator_; | 64 TrayUserSeparator* tray_user_separator_ = nullptr; |
67 | 65 |
68 DISALLOW_COPY_AND_ASSIGN(TrayUserTest); | 66 DISALLOW_COPY_AND_ASSIGN(TrayUserTest); |
69 }; | 67 }; |
70 | 68 |
71 TrayUserTest::TrayUserTest() | |
72 : shelf_(NULL), | |
73 tray_(NULL), | |
74 delegate_(NULL), | |
75 tray_user_separator_(NULL) { | |
76 } | |
77 | |
78 void TrayUserTest::SetUp() { | 69 void TrayUserTest::SetUp() { |
79 ash::test::AshTestBase::SetUp(); | 70 ash::test::AshTestBase::SetUp(); |
80 shelf_ = Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | |
81 tray_ = Shell::GetPrimaryRootWindowController()->GetSystemTray(); | 71 tray_ = Shell::GetPrimaryRootWindowController()->GetSystemTray(); |
82 delegate_ = static_cast<ash::test::TestSessionStateDelegate*>( | 72 delegate_ = static_cast<ash::test::TestSessionStateDelegate*>( |
83 ash::Shell::GetInstance()->session_state_delegate()); | 73 ash::Shell::GetInstance()->session_state_delegate()); |
84 } | 74 } |
85 | 75 |
86 void TrayUserTest::InitializeParameters(int users_logged_in, | 76 void TrayUserTest::InitializeParameters(int users_logged_in, |
87 bool multiprofile) { | 77 bool multiprofile) { |
88 // Show the shelf. | 78 // Show the shelf. |
89 shelf()->LayoutShelf(); | 79 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
90 shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 80 shelf->shelf_layout_manager()->LayoutShelf(); |
| 81 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
91 | 82 |
92 // Set our default assumptions. Note that it is sufficient to set these | 83 // Set our default assumptions. Note that it is sufficient to set these |
93 // after everything was created. | 84 // after everything was created. |
94 delegate_->set_logged_in_users(users_logged_in); | 85 delegate_->set_logged_in_users(users_logged_in); |
95 ash::test::TestShellDelegate* shell_delegate = | 86 ash::test::TestShellDelegate* shell_delegate = |
96 static_cast<ash::test::TestShellDelegate*>( | 87 static_cast<ash::test::TestShellDelegate*>( |
97 ash::Shell::GetInstance()->delegate()); | 88 ash::Shell::GetInstance()->delegate()); |
98 shell_delegate->set_multi_profiles_enabled(multiprofile); | 89 shell_delegate->set_multi_profiles_enabled(multiprofile); |
99 | 90 |
100 // Instead of using the existing tray panels we create new ones which makes | 91 // Instead of using the existing tray panels we create new ones which makes |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Since the name is capitalized, the email should be different then the | 268 // Since the name is capitalized, the email should be different then the |
278 // user_id. | 269 // user_id. |
279 EXPECT_NE(active_user->GetAccountId().GetUserEmail(), | 270 EXPECT_NE(active_user->GetAccountId().GetUserEmail(), |
280 second_user->GetEmail()); | 271 second_user->GetEmail()); |
281 tray()->CloseSystemBubble(); | 272 tray()->CloseSystemBubble(); |
282 } | 273 } |
283 | 274 |
284 #endif | 275 #endif |
285 | 276 |
286 } // namespace ash | 277 } // namespace ash |
OLD | NEW |