blob: 3bbaa735007e3e5b65e2c553eaae24b749709fd1 [file] [log] [blame]
Tetsui Ohkubo56307e32018-05-18 07:36:261// Copyright 2018 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/system/tracing_notification_controller.h"
6
7#include "ash/public/cpp/ash_features.h"
8#include "ash/shell.h"
Tetsui Ohkubo36794462018-06-29 07:26:029#include "ash/system/model/system_tray_model.h"
Tetsui Ohkubo56307e32018-05-18 07:36:2610#include "ash/test/ash_test_base.h"
11#include "base/test/scoped_feature_list.h"
12#include "ui/message_center/message_center.h"
13
14namespace ash {
15
16class TracingNotificationControllerTest : public AshTestBase {
17 public:
18 TracingNotificationControllerTest() = default;
19 ~TracingNotificationControllerTest() override = default;
20
21 void SetUp() override {
22 scoped_feature_list_.InitAndEnableFeature(features::kSystemTrayUnified);
23 AshTestBase::SetUp();
24 }
25
26 protected:
27 bool HasNotification() {
28 return message_center::MessageCenter::Get()->FindVisibleNotificationById(
29 TracingNotificationController::kNotificationId);
30 }
31
32 private:
33 base::test::ScopedFeatureList scoped_feature_list_;
34
35 DISALLOW_COPY_AND_ASSIGN(TracingNotificationControllerTest);
36};
37
Tetsui Ohkubo36794462018-06-29 07:26:0238// Tests that the notification becomes visible when the tray model toggles
Tetsui Ohkubo56307e32018-05-18 07:36:2639// it.
40TEST_F(TracingNotificationControllerTest, Visibility) {
41 // The system starts with tracing off, so the notification isn't visible.
42 EXPECT_FALSE(HasNotification());
43
44 // Simulate turning on tracing.
Tetsui Ohkubo36794462018-06-29 07:26:0245 SystemTrayModel* model = Shell::Get()->system_tray_model();
46 model->SetPerformanceTracingIconVisible(true);
Tetsui Ohkubo56307e32018-05-18 07:36:2647 EXPECT_TRUE(HasNotification());
48
49 // Simulate turning off tracing.
Tetsui Ohkubo36794462018-06-29 07:26:0250 model->SetPerformanceTracingIconVisible(false);
Tetsui Ohkubo56307e32018-05-18 07:36:2651 EXPECT_FALSE(HasNotification());
52}
53
54} // namespace ash