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

Side by Side Diff: ash/system/chromeos/session/tray_session_length_limit_unittest.cc

Issue 895863002: Fixes tray_session_length_limit_unittest timeout on valgrind. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | 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 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/system/chromeos/session/tray_session_length_limit.h" 5 #include "ash/system/chromeos/session/tray_session_length_limit.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 12 matching lines...) Expand all
23 ~TraySessionLengthLimitTest() override {} 23 ~TraySessionLengthLimitTest() override {}
24 24
25 void SetUp() override { 25 void SetUp() override {
26 AshTestBase::SetUp(); 26 AshTestBase::SetUp();
27 SystemTray* system_tray = 27 SystemTray* system_tray =
28 Shell::GetPrimaryRootWindowController()->GetSystemTray(); 28 Shell::GetPrimaryRootWindowController()->GetSystemTray();
29 tray_session_length_limit_ = new TraySessionLengthLimit(system_tray); 29 tray_session_length_limit_ = new TraySessionLengthLimit(system_tray);
30 system_tray->AddTrayItem(tray_session_length_limit_); 30 system_tray->AddTrayItem(tray_session_length_limit_);
31 } 31 }
32 32
33 void TearDown() override { AshTestBase::TearDown(); } 33 void TearDown() override {
34 ClearSessionLengthLimit();
35 AshTestBase::TearDown();
36 }
34 37
35 protected: 38 protected:
36 void UpdateSessionLengthLimitInMin(int mins) { 39 void UpdateSessionLengthLimitInMin(int mins) {
37 GetSystemTrayDelegate()->SetSessionLengthLimitForTest( 40 GetSystemTrayDelegate()->SetSessionLengthLimitForTest(
38 base::TimeDelta::FromMinutes(mins)); 41 base::TimeDelta::FromMinutes(mins));
39 tray_session_length_limit_->OnSessionLengthLimitChanged(); 42 tray_session_length_limit_->OnSessionLengthLimitChanged();
40 } 43 }
41 44
42 message_center::Notification* GetNotification() { 45 message_center::Notification* GetNotification() {
43 const message_center::NotificationList::Notifications& notifications = 46 const message_center::NotificationList::Notifications& notifications =
44 message_center::MessageCenter::Get()->GetVisibleNotifications(); 47 message_center::MessageCenter::Get()->GetVisibleNotifications();
45 for (message_center::NotificationList::Notifications::const_iterator iter = 48 for (message_center::NotificationList::Notifications::const_iterator iter =
46 notifications.begin(); iter != notifications.end(); ++iter) { 49 notifications.begin(); iter != notifications.end(); ++iter) {
47 if ((*iter)->id() == TraySessionLengthLimit::kNotificationId) 50 if ((*iter)->id() == TraySessionLengthLimit::kNotificationId)
48 return *iter; 51 return *iter;
49 } 52 }
50 return NULL; 53 return nullptr;
51 } 54 }
52 55
53 void ClearSessionLengthLimit() { 56 void ClearSessionLengthLimit() {
54 GetSystemTrayDelegate()->ClearSessionLengthLimit(); 57 GetSystemTrayDelegate()->ClearSessionLengthLimit();
55 tray_session_length_limit_->OnSessionLengthLimitChanged(); 58 tray_session_length_limit_->OnSessionLengthLimitChanged();
56 } 59 }
57 60
58 void RemoveNotification() { 61 void RemoveNotification() {
59 message_center::MessageCenter::Get()->RemoveNotification( 62 message_center::MessageCenter::Get()->RemoveNotification(
60 TraySessionLengthLimit::kNotificationId, false /* by_user */); 63 TraySessionLengthLimit::kNotificationId, false /* by_user */);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Should read again because an increase of the remaining time is noteworthy. 116 // Should read again because an increase of the remaining time is noteworthy.
114 EXPECT_TRUE(notification->rich_notification_data(). 117 EXPECT_TRUE(notification->rich_notification_data().
115 should_make_spoken_feedback_for_popup_updates); 118 should_make_spoken_feedback_for_popup_updates);
116 119
117 // Clears the limit: the notification should be gone. 120 // Clears the limit: the notification should be gone.
118 ClearSessionLengthLimit(); 121 ClearSessionLengthLimit();
119 EXPECT_FALSE(GetNotification()); 122 EXPECT_FALSE(GetNotification());
120 } 123 }
121 124
122 TEST_F(TraySessionLengthLimitTest, RemoveNotification) { 125 TEST_F(TraySessionLengthLimitTest, RemoveNotification) {
123 message_center::Notification* notification;
124
125 // Limit is 15 min. 126 // Limit is 15 min.
126 UpdateSessionLengthLimitInMin(15); 127 UpdateSessionLengthLimitInMin(15);
127 EXPECT_TRUE(GetNotification()); 128 EXPECT_TRUE(GetNotification());
128 129
129 // Removes the notification. 130 // Removes the notification.
130 RemoveNotification(); 131 RemoveNotification();
131 EXPECT_FALSE(GetNotification()); 132 EXPECT_FALSE(GetNotification());
132 133
133 // Limit is 10 min. The notification should not re-appear. 134 // Limit is 10 min. The notification should not re-appear.
134 UpdateSessionLengthLimitInMin(10); 135 UpdateSessionLengthLimitInMin(10);
135 EXPECT_FALSE(GetNotification()); 136 EXPECT_FALSE(GetNotification());
136 137
137 // Limit is 3 min. The notification should re-appear and should be re-read 138 // Limit is 3 min. The notification should re-appear and should be re-read
138 // because of state change. 139 // because of state change.
139 UpdateSessionLengthLimitInMin(3); 140 UpdateSessionLengthLimitInMin(3);
140 notification = GetNotification(); 141 message_center::Notification* notification = GetNotification();
141 EXPECT_TRUE(notification); 142 EXPECT_TRUE(notification);
142 EXPECT_TRUE(notification->rich_notification_data(). 143 EXPECT_TRUE(notification->rich_notification_data().
143 should_make_spoken_feedback_for_popup_updates); 144 should_make_spoken_feedback_for_popup_updates);
144 145
145 RemoveNotification(); 146 RemoveNotification();
146 147
147 // Session length limit is updated to longer state. Notification should 148 // Session length limit is updated to longer state. Notification should
148 // re-appear and be re-read. 149 // re-appear and be re-read.
149 UpdateSessionLengthLimitInMin(15); 150 UpdateSessionLengthLimitInMin(15);
150 notification = GetNotification(); 151 notification = GetNotification();
151 EXPECT_TRUE(notification); 152 EXPECT_TRUE(notification);
152 EXPECT_TRUE(notification->rich_notification_data(). 153 EXPECT_TRUE(notification->rich_notification_data().
153 should_make_spoken_feedback_for_popup_updates); 154 should_make_spoken_feedback_for_popup_updates);
154 } 155 }
155 156
156 } // namespace test 157 } // namespace test
157 } // namespace ash 158 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698