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

Side by Side Diff: ash/common/system/chromeos/screen_security/screen_tray_item_unittest.cc

Issue 2422453002: mutash: Convert ScreenShareTest/ScreenCaptureTest to AshTest (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « ash/common/system/chromeos/network/tray_vpn.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 6
7 #include "ash/common/system/chromeos/screen_security/screen_capture_tray_item.h" 7 #include "ash/common/system/chromeos/screen_security/screen_capture_tray_item.h"
8 #include "ash/common/system/chromeos/screen_security/screen_share_tray_item.h" 8 #include "ash/common/system/chromeos/screen_security/screen_share_tray_item.h"
9 #include "ash/common/system/tray/system_tray_notifier.h" 9 #include "ash/common/system/tray/system_tray_notifier.h"
10 #include "ash/common/system/tray/tray_item_view.h" 10 #include "ash/common/system/tray/tray_item_view.h"
11 #include "ash/common/test/ash_test.h"
11 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
12 #include "ash/test/ash_test_base.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "ui/events/event.h" 15 #include "ui/events/event.h"
16 #include "ui/events/event_utils.h" 16 #include "ui/events/event_utils.h"
17 #include "ui/gfx/geometry/point.h" 17 #include "ui/gfx/geometry/point.h"
18 #include "ui/message_center/message_center.h" 18 #include "ui/message_center/message_center.h"
19 #include "ui/views/view.h" 19 #include "ui/views/view.h"
20 20
21 namespace ash { 21 namespace ash {
22 22
23 // Test with unicode strings. 23 // Test with unicode strings.
24 const char kTestScreenCaptureAppName[] = 24 const char kTestScreenCaptureAppName[] =
25 "\xE0\xB2\xA0\x5F\xE0\xB2\xA0 (Screen Capture Test)"; 25 "\xE0\xB2\xA0\x5F\xE0\xB2\xA0 (Screen Capture Test)";
26 const char kTestScreenShareHelperName[] = 26 const char kTestScreenShareHelperName[] =
27 "\xE5\xAE\x8B\xE8\x85\xBE (Screen Share Test)"; 27 "\xE5\xAE\x8B\xE8\x85\xBE (Screen Share Test)";
28 28
29 void ClickViewCenter(views::View* view) { 29 void ClickViewCenter(views::View* view) {
30 gfx::Point click_location_in_local = 30 gfx::Point click_location_in_local =
31 gfx::Point(view->width() / 2, view->height() / 2); 31 gfx::Point(view->width() / 2, view->height() / 2);
32 view->OnMousePressed(ui::MouseEvent( 32 view->OnMousePressed(ui::MouseEvent(
33 ui::ET_MOUSE_PRESSED, click_location_in_local, click_location_in_local, 33 ui::ET_MOUSE_PRESSED, click_location_in_local, click_location_in_local,
34 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); 34 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
35 } 35 }
36 36
37 class ScreenTrayItemTest : public ash::test::AshTestBase { 37 class ScreenTrayItemTest : public AshTest {
38 public: 38 public:
39 ScreenTrayItemTest() : tray_item_(NULL), stop_callback_hit_count_(0) {} 39 ScreenTrayItemTest() : tray_item_(NULL), stop_callback_hit_count_(0) {}
40 ~ScreenTrayItemTest() override {} 40 ~ScreenTrayItemTest() override {}
41 41
42 ScreenTrayItem* tray_item() { return tray_item_; } 42 ScreenTrayItem* tray_item() { return tray_item_; }
43 void set_tray_item(ScreenTrayItem* tray_item) { tray_item_ = tray_item; } 43 void set_tray_item(ScreenTrayItem* tray_item) { tray_item_ = tray_item; }
44 44
45 int stop_callback_hit_count() const { return stop_callback_hit_count_; } 45 int stop_callback_hit_count() const { return stop_callback_hit_count_; }
46 46
47 void SetUp() override { 47 void SetUp() override {
48 test::AshTestBase::SetUp(); 48 AshTest::SetUp();
49 TrayItemView::DisableAnimationsForTest(); 49 TrayItemView::DisableAnimationsForTest();
50 } 50 }
51 51
52 void StartSession() { 52 void StartSession() {
53 tray_item_->Start( 53 tray_item_->Start(
54 base::Bind(&ScreenTrayItemTest::StopCallback, base::Unretained(this))); 54 base::Bind(&ScreenTrayItemTest::StopCallback, base::Unretained(this)));
55 } 55 }
56 56
57 void StopSession() { tray_item_->Stop(); } 57 void StopSession() { tray_item_->Stop(); }
58 58
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 EXPECT_TRUE(tray_item->is_started()); 110 EXPECT_TRUE(tray_item->is_started());
111 111
112 test->StopSession(); 112 test->StopSession();
113 EXPECT_FALSE(tray_item->is_started()); 113 EXPECT_FALSE(tray_item->is_started());
114 EXPECT_EQ(1, test->stop_callback_hit_count()); 114 EXPECT_EQ(1, test->stop_callback_hit_count());
115 } 115 }
116 116
117 TEST_F(ScreenCaptureTest, StartAndStop) { 117 TEST_F(ScreenCaptureTest, StartAndStop) {
118 TestStartAndStop(this); 118 TestStartAndStop(this);
119 } 119 }
120
120 TEST_F(ScreenShareTest, StartAndStop) { 121 TEST_F(ScreenShareTest, StartAndStop) {
121 TestStartAndStop(this); 122 TestStartAndStop(this);
122 } 123 }
123 124
124 void TestNotificationStartAndStop(ScreenTrayItemTest* test, 125 void TestNotificationStartAndStop(ScreenTrayItemTest* test,
125 const base::Closure& start_function, 126 const base::Closure& start_function,
126 const base::Closure& stop_function) { 127 const base::Closure& stop_function) {
127 ScreenTrayItem* tray_item = test->tray_item(); 128 ScreenTrayItem* tray_item = test->tray_item();
128 EXPECT_FALSE(tray_item->is_started()); 129 EXPECT_FALSE(tray_item->is_started());
129 130
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 message_center::MessageCenter* message_center = 173 message_center::MessageCenter* message_center =
173 message_center::MessageCenter::Get(); 174 message_center::MessageCenter::Get();
174 EXPECT_TRUE(message_center->FindVisibleNotificationById( 175 EXPECT_TRUE(message_center->FindVisibleNotificationById(
175 tray_item->GetNotificationId())); 176 tray_item->GetNotificationId()));
176 test->StopSession(); 177 test->StopSession();
177 } 178 }
178 179
179 TEST_F(ScreenCaptureTest, NotificationView) { 180 TEST_F(ScreenCaptureTest, NotificationView) {
180 TestNotificationView(this); 181 TestNotificationView(this);
181 } 182 }
183
182 TEST_F(ScreenShareTest, NotificationView) { 184 TEST_F(ScreenShareTest, NotificationView) {
183 TestNotificationView(this); 185 TestNotificationView(this);
184 } 186 }
185 187
186 void TestSystemTrayInteraction(ScreenTrayItemTest* test) { 188 void TestSystemTrayInteraction(ScreenTrayItemTest* test) {
187 ScreenTrayItem* tray_item = test->tray_item(); 189 ScreenTrayItem* tray_item = test->tray_item();
188 EXPECT_FALSE(tray_item->tray_view()->visible()); 190 EXPECT_FALSE(tray_item->tray_view()->visible());
189 191
190 const std::vector<SystemTrayItem*>& tray_items = 192 const std::vector<SystemTrayItem*>& tray_items =
191 test::AshTestBase::GetPrimarySystemTray()->GetTrayItems(); 193 AshTest::GetPrimarySystemTray()->GetTrayItems();
192 EXPECT_NE(std::find(tray_items.begin(), tray_items.end(), tray_item), 194 EXPECT_NE(std::find(tray_items.begin(), tray_items.end(), tray_item),
193 tray_items.end()); 195 tray_items.end());
194 196
195 test->StartSession(); 197 test->StartSession();
196 EXPECT_TRUE(tray_item->tray_view()->visible()); 198 EXPECT_TRUE(tray_item->tray_view()->visible());
197 199
198 // The default view should be created in a new bubble. 200 // The default view should be created in a new bubble.
199 test::AshTestBase::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); 201 AshTest::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
200 EXPECT_TRUE(tray_item->default_view()); 202 EXPECT_TRUE(tray_item->default_view());
201 test::AshTestBase::GetPrimarySystemTray()->CloseSystemBubble(); 203 AshTest::GetPrimarySystemTray()->CloseSystemBubble();
202 EXPECT_FALSE(tray_item->default_view()); 204 EXPECT_FALSE(tray_item->default_view());
203 205
204 test->StopSession(); 206 test->StopSession();
205 EXPECT_FALSE(tray_item->tray_view()->visible()); 207 EXPECT_FALSE(tray_item->tray_view()->visible());
206 208
207 // The default view should not be visible because session is stopped. 209 // The default view should not be visible because session is stopped.
208 test::AshTestBase::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); 210 AshTest::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
209 EXPECT_FALSE(tray_item->default_view()->visible()); 211 EXPECT_FALSE(tray_item->default_view()->visible());
210 } 212 }
211 213
212 TEST_F(ScreenCaptureTest, SystemTrayInteraction) { 214 TEST_F(ScreenCaptureTest, SystemTrayInteraction) {
213 TestSystemTrayInteraction(this); 215 TestSystemTrayInteraction(this);
214 } 216 }
215 217
216 TEST_F(ScreenShareTest, SystemTrayInteraction) { 218 TEST_F(ScreenShareTest, SystemTrayInteraction) {
217 TestSystemTrayInteraction(this); 219 TestSystemTrayInteraction(this);
218 } 220 }
219 221
220 } // namespace ash 222 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/tray_vpn.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698