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