forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracing_notification_controller_unittest.cc
45 lines (35 loc) · 1.37 KB
/
tracing_notification_controller_unittest.cc
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
// Copyright 2018 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/system/tracing_notification_controller.h"
#include "ash/shell.h"
#include "ash/system/model/system_tray_model.h"
#include "ash/test/ash_test_base.h"
#include "ui/message_center/message_center.h"
namespace ash {
class TracingNotificationControllerTest : public AshTestBase {
public:
TracingNotificationControllerTest() = default;
~TracingNotificationControllerTest() override = default;
protected:
bool HasNotification() {
return message_center::MessageCenter::Get()->FindVisibleNotificationById(
TracingNotificationController::kNotificationId);
}
private:
DISALLOW_COPY_AND_ASSIGN(TracingNotificationControllerTest);
};
// Tests that the notification becomes visible when the tray model toggles
// it.
TEST_F(TracingNotificationControllerTest, Visibility) {
// The system starts with tracing off, so the notification isn't visible.
EXPECT_FALSE(HasNotification());
// Simulate turning on tracing.
SystemTrayModel* model = Shell::Get()->system_tray_model();
model->SetPerformanceTracingIconVisible(true);
EXPECT_TRUE(HasNotification());
// Simulate turning off tracing.
model->SetPerformanceTracingIconVisible(false);
EXPECT_FALSE(HasNotification());
}
} // namespace ash