| OLD | NEW |
| 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 "chrome/browser/ui/ash/multi_user/user_switch_util.h" |
| 6 |
| 5 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" | 7 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" |
| 6 #include "ash/common/system/tray/system_tray.h" | 8 #include "ash/common/system/tray/system_tray.h" |
| 7 #include "ash/common/wm/overview/window_selector_controller.h" | 9 #include "ash/common/wm/overview/window_selector_controller.h" |
| 8 #include "ash/common/wm_shell.h" | 10 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 10 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "chrome/browser/ui/ash/multi_user/user_switch_util.h" | |
| 13 #include "chrome/browser/ui/simple_message_box.h" | 14 #include "chrome/browser/ui/simple_message_box.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 | 16 |
| 16 namespace ash { | 17 namespace ash { |
| 17 | 18 |
| 18 class TrySwitchingUserTest : public ash::test::AshTestBase { | 19 class TrySwitchingUserTest : public ash::test::AshTestBase { |
| 19 public: | 20 public: |
| 20 // The action type to perform / check for upon user switching. | 21 // The action type to perform / check for upon user switching. |
| 21 enum ActionType { | 22 enum ActionType { |
| 22 NO_DIALOG, // No dialog should be shown. | 23 NO_DIALOG, // No dialog should be shown. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 FROM_HERE, base::Bind(&CloseMessageBox, action)); | 76 FROM_HERE, base::Bind(&CloseMessageBox, action)); |
| 76 TrySwitchingActiveUser(base::Bind(&TrySwitchingUserTest::SwitchCallback, | 77 TrySwitchingActiveUser(base::Bind(&TrySwitchingUserTest::SwitchCallback, |
| 77 base::Unretained(this))); | 78 base::Unretained(this))); |
| 78 base::RunLoop().RunUntilIdle(); | 79 base::RunLoop().RunUntilIdle(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 // Called when the user will get actually switched. | 82 // Called when the user will get actually switched. |
| 82 void SwitchCallback() { switch_callback_hit_count_++; } | 83 void SwitchCallback() { switch_callback_hit_count_++; } |
| 83 | 84 |
| 84 // Methods needed to test with overview mode. | 85 // Methods needed to test with overview mode. |
| 85 const WindowSelectorController* window_selector_controller() const { | |
| 86 return WmShell::Get()->window_selector_controller(); | |
| 87 } | |
| 88 WindowSelectorController* window_selector_controller() { | |
| 89 return const_cast<WindowSelectorController*>( | |
| 90 const_cast<const TrySwitchingUserTest*>(this) | |
| 91 ->window_selector_controller()); | |
| 92 } | |
| 93 bool ToggleOverview() { | 86 bool ToggleOverview() { |
| 94 return window_selector_controller()->ToggleOverview(); | 87 return Shell::Get()->window_selector_controller()->ToggleOverview(); |
| 95 } | 88 } |
| 96 bool IsSelecting() const { | 89 bool IsSelecting() const { |
| 97 return window_selector_controller()->IsSelecting(); | 90 return Shell::Get()->window_selector_controller()->IsSelecting(); |
| 98 } | 91 } |
| 99 | 92 |
| 100 // Various counter accessors. | 93 // Various counter accessors. |
| 101 int stop_capture_callback_hit_count() const { | 94 int stop_capture_callback_hit_count() const { |
| 102 return stop_capture_callback_hit_count_; | 95 return stop_capture_callback_hit_count_; |
| 103 } | 96 } |
| 104 int stop_share_callback_hit_count() const { | 97 int stop_share_callback_hit_count() const { |
| 105 return stop_share_callback_hit_count_; | 98 return stop_share_callback_hit_count_; |
| 106 } | 99 } |
| 107 int switch_callback_hit_count() const { return switch_callback_hit_count_; } | 100 int switch_callback_hit_count() const { return switch_callback_hit_count_; } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 gfx::Rect bounds(0, 0, 100, 100); | 238 gfx::Rect bounds(0, 0, 100, 100); |
| 246 std::unique_ptr<aura::Window> w(CreateTestWindowInShellWithBounds(bounds)); | 239 std::unique_ptr<aura::Window> w(CreateTestWindowInShellWithBounds(bounds)); |
| 247 ASSERT_TRUE(ToggleOverview()); | 240 ASSERT_TRUE(ToggleOverview()); |
| 248 ASSERT_TRUE(IsSelecting()); | 241 ASSERT_TRUE(IsSelecting()); |
| 249 SwitchUser(TrySwitchingUserTest::NO_DIALOG); | 242 SwitchUser(TrySwitchingUserTest::NO_DIALOG); |
| 250 ASSERT_FALSE(IsSelecting()); | 243 ASSERT_FALSE(IsSelecting()); |
| 251 EXPECT_EQ(1, switch_callback_hit_count()); | 244 EXPECT_EQ(1, switch_callback_hit_count()); |
| 252 } | 245 } |
| 253 | 246 |
| 254 } // namespace ash | 247 } // namespace ash |
| OLD | NEW |