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 "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 WindowSelectorController* window_selector_controller() { | |
| 91 return WmShell::Get()->window_selector_controller(); | |
| 92 } | |
| 93 void ToggleOverview() { window_selector_controller()->ToggleOverview(); } | |
| 94 bool IsSelecting() { return window_selector_controller()->IsSelecting(); } | |
|
oshima
2016/08/25 21:29:39
nit: const?
varkha
2016/08/26 03:28:53
Done.
| |
| 95 | |
| 86 // Various counter accessors. | 96 // Various counter accessors. |
| 87 int stop_capture_callback_hit_count() const { | 97 int stop_capture_callback_hit_count() const { |
| 88 return stop_capture_callback_hit_count_; | 98 return stop_capture_callback_hit_count_; |
| 89 } | 99 } |
| 90 int stop_share_callback_hit_count() const { | 100 int stop_share_callback_hit_count() const { |
| 91 return stop_share_callback_hit_count_; | 101 return stop_share_callback_hit_count_; |
| 92 } | 102 } |
| 93 int switch_callback_hit_count() const { return switch_callback_hit_count_; } | 103 int switch_callback_hit_count() const { return switch_callback_hit_count_; } |
| 94 | 104 |
| 95 private: | 105 private: |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 EXPECT_EQ(1, stop_capture_callback_hit_count()); | 214 EXPECT_EQ(1, stop_capture_callback_hit_count()); |
| 205 EXPECT_EQ(1, stop_share_callback_hit_count()); | 215 EXPECT_EQ(1, stop_share_callback_hit_count()); |
| 206 // Another stop should have no effect. | 216 // Another stop should have no effect. |
| 207 StopShareSession(); | 217 StopShareSession(); |
| 208 StopCaptureSession(); | 218 StopCaptureSession(); |
| 209 EXPECT_EQ(1, switch_callback_hit_count()); | 219 EXPECT_EQ(1, switch_callback_hit_count()); |
| 210 EXPECT_EQ(1, stop_capture_callback_hit_count()); | 220 EXPECT_EQ(1, stop_capture_callback_hit_count()); |
| 211 EXPECT_EQ(1, stop_share_callback_hit_count()); | 221 EXPECT_EQ(1, stop_share_callback_hit_count()); |
| 212 } | 222 } |
| 213 | 223 |
| 224 // Test that overview mode is dismissed before switching user profile. | |
| 225 TEST_F(TrySwitchingUserTest, OverviewModeDismissed) { | |
| 226 EXPECT_EQ(0, switch_callback_hit_count()); | |
| 227 gfx::Rect bounds(0, 0, 100, 100); | |
| 228 std::unique_ptr<aura::Window> w(CreateTestWindowInShellWithBounds(bounds)); | |
| 229 ToggleOverview(); | |
| 230 ASSERT_TRUE(IsSelecting()); | |
| 231 SwitchUser(TrySwitchingUserTest::NO_DIALOG); | |
| 232 ASSERT_FALSE(IsSelecting()); | |
| 233 EXPECT_EQ(1, switch_callback_hit_count()); | |
| 234 } | |
| 235 | |
| 214 } // namespace ash | 236 } // namespace ash |
| OLD | NEW |