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

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

Issue 2852493002: chromeos: Converts more tests to AshTestBase (Closed)
Patch Set: Created 3 years, 7 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/system/date/date_view_unittest.cc ('k') | ash/wm/mru_window_tracker_unittest.cc » ('j') | 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/system/screen_security/screen_tray_item.h" 5 #include "ash/system/screen_security/screen_tray_item.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/screen_security/screen_capture_tray_item.h" 8 #include "ash/system/screen_security/screen_capture_tray_item.h"
9 #include "ash/system/screen_security/screen_share_tray_item.h" 9 #include "ash/system/screen_security/screen_share_tray_item.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_notifier.h" 11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/system/tray/tray_item_view.h" 12 #include "ash/system/tray/tray_item_view.h"
13 #include "ash/test/ash_test.h" 13 #include "ash/test/ash_test_base.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "ui/events/event.h" 17 #include "ui/events/event.h"
18 #include "ui/events/event_utils.h" 18 #include "ui/events/event_utils.h"
19 #include "ui/gfx/geometry/point.h" 19 #include "ui/gfx/geometry/point.h"
20 #include "ui/message_center/message_center.h" 20 #include "ui/message_center/message_center.h"
21 #include "ui/views/view.h" 21 #include "ui/views/view.h"
22 22
23 namespace ash { 23 namespace ash {
24 24
25 // Test with unicode strings. 25 // Test with unicode strings.
26 const char kTestScreenCaptureAppName[] = 26 const char kTestScreenCaptureAppName[] =
27 "\xE0\xB2\xA0\x5F\xE0\xB2\xA0 (Screen Capture Test)"; 27 "\xE0\xB2\xA0\x5F\xE0\xB2\xA0 (Screen Capture Test)";
28 const char kTestScreenShareHelperName[] = 28 const char kTestScreenShareHelperName[] =
29 "\xE5\xAE\x8B\xE8\x85\xBE (Screen Share Test)"; 29 "\xE5\xAE\x8B\xE8\x85\xBE (Screen Share Test)";
30 30
31 void ClickViewCenter(views::View* view) { 31 void ClickViewCenter(views::View* view) {
32 gfx::Point click_location_in_local = 32 gfx::Point click_location_in_local =
33 gfx::Point(view->width() / 2, view->height() / 2); 33 gfx::Point(view->width() / 2, view->height() / 2);
34 view->OnMousePressed(ui::MouseEvent( 34 view->OnMousePressed(ui::MouseEvent(
35 ui::ET_MOUSE_PRESSED, click_location_in_local, click_location_in_local, 35 ui::ET_MOUSE_PRESSED, click_location_in_local, click_location_in_local,
36 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); 36 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
37 } 37 }
38 38
39 class ScreenTrayItemTest : public AshTest { 39 class ScreenTrayItemTest : public test::AshTestBase {
40 public: 40 public:
41 ScreenTrayItemTest() : tray_item_(NULL), stop_callback_hit_count_(0) {} 41 ScreenTrayItemTest() : tray_item_(NULL), stop_callback_hit_count_(0) {}
42 ~ScreenTrayItemTest() override {} 42 ~ScreenTrayItemTest() override {}
43 43
44 ScreenTrayItem* tray_item() { return tray_item_; } 44 ScreenTrayItem* tray_item() { return tray_item_; }
45 void set_tray_item(ScreenTrayItem* tray_item) { tray_item_ = tray_item; } 45 void set_tray_item(ScreenTrayItem* tray_item) { tray_item_ = tray_item; }
46 46
47 int stop_callback_hit_count() const { return stop_callback_hit_count_; } 47 int stop_callback_hit_count() const { return stop_callback_hit_count_; }
48 48
49 void SetUp() override { 49 void SetUp() override {
50 AshTest::SetUp(); 50 AshTestBase::SetUp();
51 TrayItemView::DisableAnimationsForTest(); 51 TrayItemView::DisableAnimationsForTest();
52 } 52 }
53 53
54 void StartSession() { 54 void StartSession() {
55 tray_item_->Start( 55 tray_item_->Start(
56 base::Bind(&ScreenTrayItemTest::StopCallback, base::Unretained(this))); 56 base::Bind(&ScreenTrayItemTest::StopCallback, base::Unretained(this)));
57 } 57 }
58 58
59 void StopSession() { tray_item_->Stop(); } 59 void StopSession() { tray_item_->Stop(); }
60 60
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 TEST_F(ScreenShareTest, NotificationView) { 186 TEST_F(ScreenShareTest, NotificationView) {
187 TestNotificationView(this); 187 TestNotificationView(this);
188 } 188 }
189 189
190 void TestSystemTrayInteraction(ScreenTrayItemTest* test) { 190 void TestSystemTrayInteraction(ScreenTrayItemTest* test) {
191 ScreenTrayItem* tray_item = test->tray_item(); 191 ScreenTrayItem* tray_item = test->tray_item();
192 EXPECT_FALSE(tray_item->tray_view()->visible()); 192 EXPECT_FALSE(tray_item->tray_view()->visible());
193 193
194 std::vector<SystemTrayItem*> tray_items = 194 std::vector<SystemTrayItem*> tray_items =
195 AshTest::GetPrimarySystemTray()->GetTrayItems(); 195 test::AshTestBase::GetPrimarySystemTray()->GetTrayItems();
196 EXPECT_NE(std::find(tray_items.begin(), tray_items.end(), tray_item), 196 EXPECT_NE(std::find(tray_items.begin(), tray_items.end(), tray_item),
197 tray_items.end()); 197 tray_items.end());
198 198
199 test->StartSession(); 199 test->StartSession();
200 EXPECT_TRUE(tray_item->tray_view()->visible()); 200 EXPECT_TRUE(tray_item->tray_view()->visible());
201 201
202 // The default view should be created in a new bubble. 202 // The default view should be created in a new bubble.
203 AshTest::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); 203 test::AshTestBase::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
204 EXPECT_TRUE(tray_item->default_view()); 204 EXPECT_TRUE(tray_item->default_view());
205 AshTest::GetPrimarySystemTray()->CloseSystemBubble(); 205 test::AshTestBase::GetPrimarySystemTray()->CloseSystemBubble();
206 EXPECT_FALSE(tray_item->default_view()); 206 EXPECT_FALSE(tray_item->default_view());
207 207
208 test->StopSession(); 208 test->StopSession();
209 EXPECT_FALSE(tray_item->tray_view()->visible()); 209 EXPECT_FALSE(tray_item->tray_view()->visible());
210 210
211 // The default view should not be visible because session is stopped. 211 // The default view should not be visible because session is stopped.
212 AshTest::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); 212 test::AshTestBase::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
213 EXPECT_FALSE(tray_item->default_view()->visible()); 213 EXPECT_FALSE(tray_item->default_view()->visible());
214 } 214 }
215 215
216 TEST_F(ScreenCaptureTest, SystemTrayInteraction) { 216 TEST_F(ScreenCaptureTest, SystemTrayInteraction) {
217 TestSystemTrayInteraction(this); 217 TestSystemTrayInteraction(this);
218 } 218 }
219 219
220 TEST_F(ScreenShareTest, SystemTrayInteraction) { 220 TEST_F(ScreenShareTest, SystemTrayInteraction) {
221 TestSystemTrayInteraction(this); 221 TestSystemTrayInteraction(this);
222 } 222 }
223 223
224 } // namespace ash 224 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/date/date_view_unittest.cc ('k') | ash/wm/mru_window_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698