OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/shell.h" | |
6 #include "ash/system/chromeos/drive/tray_drive_notice.h" | |
7 #include "ash/system/tray/system_tray.h" | |
8 #include "ash/system/tray/system_tray_notifier.h" | |
9 #include "ash/system/tray/tray_item_view.h" | |
10 #include "ash/test/ash_test_base.h" | |
11 | |
12 namespace ash { | |
13 namespace internal { | |
14 | |
15 class DriveNoticeTest : public ash::test::AshTestBase { | |
16 public: | |
17 DriveNoticeTest() {} | |
18 | |
19 virtual void SetUp() OVERRIDE { | |
20 test::AshTestBase::SetUp(); | |
21 TrayItemView::DisableAnimationsForTest(); | |
22 | |
23 // Ownership of |notice_tray_item_| passed to system tray. | |
24 notice_tray_item_ = new TrayDriveNotice(GetSystemTray()); | |
25 notice_tray_item_->SetTimeVisibleForTest(0); | |
26 GetSystemTray()->AddTrayItem(notice_tray_item_); | |
27 } | |
28 | |
29 TrayDriveNotice* notice_tray_item() { return notice_tray_item_; } | |
30 | |
31 SystemTray* GetSystemTray() { | |
32 return Shell::GetInstance()->GetPrimarySystemTray(); | |
33 } | |
34 | |
35 void NotifyOfflineEnabled() { | |
36 Shell::GetInstance()->system_tray_notifier()->NotifyDriveOfflineEnabled(); | |
37 } | |
38 | |
39 private: | |
40 // |notice_tray_item_| is owned by system tray. | |
41 TrayDriveNotice* notice_tray_item_; | |
42 }; | |
43 | |
44 TEST_F(DriveNoticeTest, NotifyEnabled) { | |
45 // Tray item views should not be visible initially. | |
46 EXPECT_FALSE(notice_tray_item()->GetTrayView()->visible()); | |
47 EXPECT_FALSE(notice_tray_item()->default_view()); | |
48 EXPECT_FALSE(notice_tray_item()->detailed_view()); | |
49 | |
50 // Tray item view should appear after notifying offline enabled. | |
51 NotifyOfflineEnabled(); | |
52 EXPECT_TRUE(notice_tray_item()->GetTrayView()->visible()); | |
53 | |
54 // Open system bubble and check default view is visible. | |
55 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | |
56 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); | |
57 EXPECT_TRUE(notice_tray_item()->default_view()); | |
58 | |
59 // Open detailed view and check detailed view is visible. | |
60 GetSystemTray()->ShowDetailedView( | |
61 notice_tray_item(), 0, false, BUBBLE_USE_EXISTING); | |
62 EXPECT_TRUE(notice_tray_item()->detailed_view()); | |
63 | |
64 GetSystemTray()->CloseSystemBubble(); | |
65 } | |
66 | |
67 TEST_F(DriveNoticeTest, AutomaticallyHidden) { | |
68 // The tray item should automatically be hidden after a period of time. | |
69 EXPECT_FALSE(notice_tray_item()->GetTrayView()->visible()); | |
70 NotifyOfflineEnabled(); | |
71 EXPECT_TRUE(notice_tray_item()->GetTrayView()->visible()); | |
72 | |
73 RunAllPendingInMessageLoop(); | |
74 EXPECT_FALSE(notice_tray_item()->GetTrayView()->visible()); | |
75 | |
76 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | |
77 EXPECT_FALSE(notice_tray_item()->default_view()); | |
78 } | |
79 | |
80 } // internal | |
81 } // ash | |
OLD | NEW |