Chromium Code Reviews| 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" | |
|
msw
2017/03/24 22:46:17
nit: blank line after
sky
2017/03/24 23:22:29
git cl format does this, but didn't add the newlin
| |
| 5 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" | 6 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" |
| 6 #include "ash/common/system/tray/system_tray.h" | 7 #include "ash/common/system/tray/system_tray.h" |
| 7 #include "ash/common/wm/overview/window_selector_controller.h" | 8 #include "ash/common/wm/overview/window_selector_controller.h" |
| 8 #include "ash/common/wm_shell.h" | 9 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 12 #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" | 13 #include "chrome/browser/ui/simple_message_box.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 class TrySwitchingUserTest : public ash::test::AshTestBase { | 18 class TrySwitchingUserTest : public ash::test::AshTestBase { |
| 19 public: | 19 public: |
| 20 // The action type to perform / check for upon user switching. | 20 // The action type to perform / check for upon user switching. |
| 21 enum ActionType { | 21 enum ActionType { |
| 22 NO_DIALOG, // No dialog should be shown. | 22 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)); | 75 FROM_HERE, base::Bind(&CloseMessageBox, action)); |
| 76 TrySwitchingActiveUser(base::Bind(&TrySwitchingUserTest::SwitchCallback, | 76 TrySwitchingActiveUser(base::Bind(&TrySwitchingUserTest::SwitchCallback, |
| 77 base::Unretained(this))); | 77 base::Unretained(this))); |
| 78 base::RunLoop().RunUntilIdle(); | 78 base::RunLoop().RunUntilIdle(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Called when the user will get actually switched. | 81 // Called when the user will get actually switched. |
| 82 void SwitchCallback() { switch_callback_hit_count_++; } | 82 void SwitchCallback() { switch_callback_hit_count_++; } |
| 83 | 83 |
| 84 // Methods needed to test with overview mode. | 84 // Methods needed to test with overview mode. |
| 85 const WindowSelectorController* window_selector_controller() const { | 85 const WindowSelectorController* window_selector_controller() const { |
|
msw
2017/03/24 22:46:17
optional nit: inline these accessors (just two use
sky
2017/03/24 23:22:29
Done.
| |
| 86 return WmShell::Get()->window_selector_controller(); | 86 return Shell::Get()->window_selector_controller(); |
| 87 } | 87 } |
| 88 WindowSelectorController* window_selector_controller() { | 88 WindowSelectorController* window_selector_controller() { |
| 89 return const_cast<WindowSelectorController*>( | 89 return const_cast<WindowSelectorController*>( |
| 90 const_cast<const TrySwitchingUserTest*>(this) | 90 const_cast<const TrySwitchingUserTest*>(this) |
| 91 ->window_selector_controller()); | 91 ->window_selector_controller()); |
| 92 } | 92 } |
| 93 bool ToggleOverview() { | 93 bool ToggleOverview() { |
| 94 return window_selector_controller()->ToggleOverview(); | 94 return window_selector_controller()->ToggleOverview(); |
| 95 } | 95 } |
| 96 bool IsSelecting() const { | 96 bool IsSelecting() const { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 gfx::Rect bounds(0, 0, 100, 100); | 245 gfx::Rect bounds(0, 0, 100, 100); |
| 246 std::unique_ptr<aura::Window> w(CreateTestWindowInShellWithBounds(bounds)); | 246 std::unique_ptr<aura::Window> w(CreateTestWindowInShellWithBounds(bounds)); |
| 247 ASSERT_TRUE(ToggleOverview()); | 247 ASSERT_TRUE(ToggleOverview()); |
| 248 ASSERT_TRUE(IsSelecting()); | 248 ASSERT_TRUE(IsSelecting()); |
| 249 SwitchUser(TrySwitchingUserTest::NO_DIALOG); | 249 SwitchUser(TrySwitchingUserTest::NO_DIALOG); |
| 250 ASSERT_FALSE(IsSelecting()); | 250 ASSERT_FALSE(IsSelecting()); |
| 251 EXPECT_EQ(1, switch_callback_hit_count()); | 251 EXPECT_EQ(1, switch_callback_hit_count()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace ash | 254 } // namespace ash |
| OLD | NEW |