| 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 "ash/common/system/chromeos/screen_security/screen_tray_item.h" | 5 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" |
| 6 #include "ash/common/system/tray/system_tray.h" | 6 #include "ash/common/system/tray/system_tray.h" |
| 7 #include "ash/common/wm/overview/window_selector_controller.h" |
| 8 #include "ash/common/wm_shell.h" |
| 7 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 8 #include "chrome/browser/ui/ash/multi_user/user_switch_util.h" | 10 #include "chrome/browser/ui/ash/multi_user/user_switch_util.h" |
| 11 #include "ui/aura/window.h" |
| 9 | 12 |
| 10 namespace ash { | 13 namespace ash { |
| 11 | 14 |
| 12 class TrySwitchingUserTest : public ash::test::AshTestBase { | 15 class TrySwitchingUserTest : public ash::test::AshTestBase { |
| 13 public: | 16 public: |
| 14 // The action type to perform / check for upon user switching. | 17 // The action type to perform / check for upon user switching. |
| 15 enum ActionType { | 18 enum ActionType { |
| 16 NO_DIALOG, // No dialog should be shown. | 19 NO_DIALOG, // No dialog should be shown. |
| 17 ACCEPT_DIALOG, // A dialog should be shown and we should accept it. | 20 ACCEPT_DIALOG, // A dialog should be shown and we should accept it. |
| 18 DECLINE_DIALOG, // A dialog should be shown and we do not accept it. | 21 DECLINE_DIALOG, // A dialog should be shown and we do not accept it. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return; | 79 return; |
| 77 case DECLINE_DIALOG: | 80 case DECLINE_DIALOG: |
| 78 EXPECT_TRUE(TestAndTerminateDesktopCastingWarningForTest(false)); | 81 EXPECT_TRUE(TestAndTerminateDesktopCastingWarningForTest(false)); |
| 79 return; | 82 return; |
| 80 } | 83 } |
| 81 } | 84 } |
| 82 | 85 |
| 83 // Called when the user will get actually switched. | 86 // Called when the user will get actually switched. |
| 84 void SwitchCallback() { switch_callback_hit_count_++; } | 87 void SwitchCallback() { switch_callback_hit_count_++; } |
| 85 | 88 |
| 89 // Methods needed to test with overview mode. |
| 90 const WindowSelectorController* window_selector_controller() const { |
| 91 return WmShell::Get()->window_selector_controller(); |
| 92 } |
| 93 WindowSelectorController* window_selector_controller() { |
| 94 return const_cast<WindowSelectorController*>( |
| 95 const_cast<const TrySwitchingUserTest*>(this) |
| 96 ->window_selector_controller()); |
| 97 } |
| 98 void ToggleOverview() { window_selector_controller()->ToggleOverview(); } |
| 99 bool IsSelecting() const { |
| 100 return window_selector_controller()->IsSelecting(); |
| 101 } |
| 102 |
| 86 // Various counter accessors. | 103 // Various counter accessors. |
| 87 int stop_capture_callback_hit_count() const { | 104 int stop_capture_callback_hit_count() const { |
| 88 return stop_capture_callback_hit_count_; | 105 return stop_capture_callback_hit_count_; |
| 89 } | 106 } |
| 90 int stop_share_callback_hit_count() const { | 107 int stop_share_callback_hit_count() const { |
| 91 return stop_share_callback_hit_count_; | 108 return stop_share_callback_hit_count_; |
| 92 } | 109 } |
| 93 int switch_callback_hit_count() const { return switch_callback_hit_count_; } | 110 int switch_callback_hit_count() const { return switch_callback_hit_count_; } |
| 94 | 111 |
| 95 private: | 112 private: |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 EXPECT_EQ(1, stop_capture_callback_hit_count()); | 221 EXPECT_EQ(1, stop_capture_callback_hit_count()); |
| 205 EXPECT_EQ(1, stop_share_callback_hit_count()); | 222 EXPECT_EQ(1, stop_share_callback_hit_count()); |
| 206 // Another stop should have no effect. | 223 // Another stop should have no effect. |
| 207 StopShareSession(); | 224 StopShareSession(); |
| 208 StopCaptureSession(); | 225 StopCaptureSession(); |
| 209 EXPECT_EQ(1, switch_callback_hit_count()); | 226 EXPECT_EQ(1, switch_callback_hit_count()); |
| 210 EXPECT_EQ(1, stop_capture_callback_hit_count()); | 227 EXPECT_EQ(1, stop_capture_callback_hit_count()); |
| 211 EXPECT_EQ(1, stop_share_callback_hit_count()); | 228 EXPECT_EQ(1, stop_share_callback_hit_count()); |
| 212 } | 229 } |
| 213 | 230 |
| 231 // Test that overview mode is dismissed before switching user profile. |
| 232 TEST_F(TrySwitchingUserTest, OverviewModeDismissed) { |
| 233 EXPECT_EQ(0, switch_callback_hit_count()); |
| 234 gfx::Rect bounds(0, 0, 100, 100); |
| 235 std::unique_ptr<aura::Window> w(CreateTestWindowInShellWithBounds(bounds)); |
| 236 ToggleOverview(); |
| 237 ASSERT_TRUE(IsSelecting()); |
| 238 SwitchUser(TrySwitchingUserTest::NO_DIALOG); |
| 239 ASSERT_FALSE(IsSelecting()); |
| 240 EXPECT_EQ(1, switch_callback_hit_count()); |
| 241 } |
| 242 |
| 214 } // namespace ash | 243 } // namespace ash |
| OLD | NEW |