Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: ash/system/chromeos/multi_user/user_switch_util_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shell.h" 5 #include "ash/shell.h"
6 #include "ash/system/chromeos/multi_user/user_switch_util.h" 6 #include "ash/system/chromeos/multi_user/user_switch_util.h"
7 #include "ash/system/chromeos/screen_security/screen_tray_item.h" 7 #include "ash/system/chromeos/screen_security/screen_tray_item.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 10
11 namespace ash { 11 namespace ash {
12 12
13 class TrySwitchingUserTest : public ash::test::AshTestBase { 13 class TrySwitchingUserTest : public ash::test::AshTestBase {
14 public: 14 public:
15 // The action type to perform / check for upon user switching. 15 // The action type to perform / check for upon user switching.
16 enum ActionType { 16 enum ActionType {
17 NO_DIALOG, // No dialog should be shown. 17 NO_DIALOG, // No dialog should be shown.
18 ACCEPT_DIALOG, // A dialog should be shown and we should accept it. 18 ACCEPT_DIALOG, // A dialog should be shown and we should accept it.
19 DECLINE_DIALOG, // A dialog should be shown and we do not accept it. 19 DECLINE_DIALOG, // A dialog should be shown and we do not accept it.
20 }; 20 };
21 TrySwitchingUserTest() 21 TrySwitchingUserTest()
22 : capture_item_(NULL), 22 : capture_item_(NULL),
23 share_item_(NULL), 23 share_item_(NULL),
24 stop_capture_callback_hit_count_(0), 24 stop_capture_callback_hit_count_(0),
25 stop_share_callback_hit_count_(0), 25 stop_share_callback_hit_count_(0),
26 switch_callback_hit_count_(0) {} 26 switch_callback_hit_count_(0) {}
27 ~TrySwitchingUserTest() override {} 27 ~TrySwitchingUserTest() override {}
28 28
29 void SetUp() override { 29 void SetUp() override {
30 test::AshTestBase::SetUp(); 30 test::AshTestBase::SetUp();
31 TrayItemView::DisableAnimationsForTest(); 31 TrayItemView::DisableAnimationsForTest();
32 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray(); 32 SystemTray* system_tray = Shell::GetInstance()->GetPrimarySystemTray();
33 share_item_ = system_tray->GetScreenShareItem(); 33 share_item_ = system_tray->GetScreenShareItem();
34 capture_item_ = system_tray->GetScreenCaptureItem(); 34 capture_item_ = system_tray->GetScreenCaptureItem();
35 EXPECT_TRUE(share_item_); 35 EXPECT_TRUE(share_item_);
36 EXPECT_TRUE(capture_item_); 36 EXPECT_TRUE(capture_item_);
37 } 37 }
38 38
39 // Accessing the capture session functionality. 39 // Accessing the capture session functionality.
40 // Simulates a screen capture session start. 40 // Simulates a screen capture session start.
41 void StartCaptureSession() { 41 void StartCaptureSession() {
42 capture_item_->Start( 42 capture_item_->Start(base::Bind(&TrySwitchingUserTest::StopCaptureCallback,
43 base::Bind(&TrySwitchingUserTest::StopCaptureCallback, 43 base::Unretained(this)));
44 base::Unretained(this)));
45 } 44 }
46 45
47 // The callback which gets called when the screen capture gets stopped. 46 // The callback which gets called when the screen capture gets stopped.
48 void StopCaptureSession() { 47 void StopCaptureSession() { capture_item_->Stop(); }
49 capture_item_->Stop();
50 }
51 48
52 // Simulates a screen capture session stop. 49 // Simulates a screen capture session stop.
53 void StopCaptureCallback() { 50 void StopCaptureCallback() { stop_capture_callback_hit_count_++; }
54 stop_capture_callback_hit_count_++;
55 }
56 51
57 // Accessing the share session functionality. 52 // Accessing the share session functionality.
58 // Simulate a Screen share session start. 53 // Simulate a Screen share session start.
59 void StartShareSession() { 54 void StartShareSession() {
60 share_item_->Start( 55 share_item_->Start(base::Bind(&TrySwitchingUserTest::StopShareCallback,
61 base::Bind(&TrySwitchingUserTest::StopShareCallback, 56 base::Unretained(this)));
62 base::Unretained(this)));
63 } 57 }
64 58
65 // Simulates a screen share session stop. 59 // Simulates a screen share session stop.
66 void StopShareSession() { 60 void StopShareSession() { share_item_->Stop(); }
67 share_item_->Stop();
68 }
69 61
70 // The callback which gets called when the screen share gets stopped. 62 // The callback which gets called when the screen share gets stopped.
71 void StopShareCallback() { 63 void StopShareCallback() { stop_share_callback_hit_count_++; }
72 stop_share_callback_hit_count_++;
73 }
74 64
75 // Issuing a switch user call which might or might not create a dialog. 65 // Issuing a switch user call which might or might not create a dialog.
76 // The passed |action| type parameter defines the outcome (which will be 66 // The passed |action| type parameter defines the outcome (which will be
77 // checked) and the action the user will choose. 67 // checked) and the action the user will choose.
78 void SwitchUser(ActionType action) { 68 void SwitchUser(ActionType action) {
79 TrySwitchingActiveUser( 69 TrySwitchingActiveUser(base::Bind(&TrySwitchingUserTest::SwitchCallback,
80 base::Bind(&TrySwitchingUserTest::SwitchCallback, 70 base::Unretained(this)));
81 base::Unretained(this))); 71 switch (action) {
82 switch(action) {
83 case NO_DIALOG: 72 case NO_DIALOG:
84 EXPECT_TRUE(!TestAndTerminateDesktopCastingWarningForTest(true)); 73 EXPECT_TRUE(!TestAndTerminateDesktopCastingWarningForTest(true));
85 return; 74 return;
86 case ACCEPT_DIALOG: 75 case ACCEPT_DIALOG:
87 EXPECT_TRUE(TestAndTerminateDesktopCastingWarningForTest(true)); 76 EXPECT_TRUE(TestAndTerminateDesktopCastingWarningForTest(true));
88 return; 77 return;
89 case DECLINE_DIALOG: 78 case DECLINE_DIALOG:
90 EXPECT_TRUE(TestAndTerminateDesktopCastingWarningForTest(false)); 79 EXPECT_TRUE(TestAndTerminateDesktopCastingWarningForTest(false));
91 return; 80 return;
92 } 81 }
93 } 82 }
94 83
95 // Called when the user will get actually switched. 84 // Called when the user will get actually switched.
96 void SwitchCallback() { 85 void SwitchCallback() { switch_callback_hit_count_++; }
97 switch_callback_hit_count_++;
98 }
99 86
100 // Various counter accessors. 87 // Various counter accessors.
101 int stop_capture_callback_hit_count() const { 88 int stop_capture_callback_hit_count() const {
102 return stop_capture_callback_hit_count_; 89 return stop_capture_callback_hit_count_;
103 } 90 }
104 int stop_share_callback_hit_count() const { 91 int stop_share_callback_hit_count() const {
105 return stop_share_callback_hit_count_; 92 return stop_share_callback_hit_count_;
106 } 93 }
107 int switch_callback_hit_count() const { return switch_callback_hit_count_; } 94 int switch_callback_hit_count() const { return switch_callback_hit_count_; }
108 95
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 EXPECT_EQ(1, stop_share_callback_hit_count()); 206 EXPECT_EQ(1, stop_share_callback_hit_count());
220 // Another stop should have no effect. 207 // Another stop should have no effect.
221 StopShareSession(); 208 StopShareSession();
222 StopCaptureSession(); 209 StopCaptureSession();
223 EXPECT_EQ(1, switch_callback_hit_count()); 210 EXPECT_EQ(1, switch_callback_hit_count());
224 EXPECT_EQ(1, stop_capture_callback_hit_count()); 211 EXPECT_EQ(1, stop_capture_callback_hit_count());
225 EXPECT_EQ(1, stop_share_callback_hit_count()); 212 EXPECT_EQ(1, stop_share_callback_hit_count());
226 } 213 }
227 214
228 } // namespace ash 215 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/multi_user/user_switch_util.cc ('k') | ash/system/chromeos/network/network_detailed_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698