Remove existing Skia suppressions
[chromium-blink-merge.git] / ash / metrics / task_switch_metrics_recorder_unittest.cc
blob5c2ef7b01c1bb3acabef83fc3a3c3be84d2d43f4
1 // Copyright 2015 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.
5 #include "ash/metrics/task_switch_metrics_recorder.h"
7 #include "base/test/histogram_tester.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace ash {
11 namespace {
13 // Test fixture for the TaskSwitchMetricsRecorder class.
14 class TaskSwitchMetricsRecorderTest : public testing::Test {
15 public:
16 TaskSwitchMetricsRecorderTest();
17 ~TaskSwitchMetricsRecorderTest() override;
19 // Wrapper to the test targets OnTaskSwitch(TaskSwitchSource) method.
20 void OnTaskSwitch(
21 TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source);
23 // testing::Test:
24 void SetUp() override;
25 void TearDown() override;
27 protected:
28 // Used to verify recorded data.
29 scoped_ptr<base::HistogramTester> histogram_tester_;
31 // The test target.
32 scoped_ptr<TaskSwitchMetricsRecorder> task_switch_metrics_recorder_;
34 private:
35 DISALLOW_COPY_AND_ASSIGN(TaskSwitchMetricsRecorderTest);
38 TaskSwitchMetricsRecorderTest::TaskSwitchMetricsRecorderTest() {
41 TaskSwitchMetricsRecorderTest::~TaskSwitchMetricsRecorderTest() {
44 void TaskSwitchMetricsRecorderTest::OnTaskSwitch(
45 TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) {
46 task_switch_metrics_recorder_->OnTaskSwitch(task_switch_source);
49 void TaskSwitchMetricsRecorderTest::SetUp() {
50 testing::Test::SetUp();
52 histogram_tester_.reset(new base::HistogramTester());
53 task_switch_metrics_recorder_.reset(new TaskSwitchMetricsRecorder());
56 void TaskSwitchMetricsRecorderTest::TearDown() {
57 testing::Test::TearDown();
59 histogram_tester_.reset();
60 task_switch_metrics_recorder_.reset();
63 } // namespace
65 // Verifies that task switches from a non kAny source also add data to the
66 // Ash.TimeBetweenTaskSwitches histogram.
67 TEST_F(TaskSwitchMetricsRecorderTest,
68 VerifyTaskSwitchesRecordInAllTaskSwitchHistogram) {
69 const std::string kHistogramName = "Ash.TimeBetweenTaskSwitches";
71 OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
72 OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
73 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
76 // Verifies that the TaskSwitchMetricsRecorder::kDesktop source adds data to the
77 // Ash.Desktop.TimeBetweenNavigateToTaskSwitches histogram.
78 TEST_F(TaskSwitchMetricsRecorderTest, VerifyTaskSwitchesForDesktopAreRecorded) {
79 const std::string kHistogramName =
80 "Ash.Desktop.TimeBetweenNavigateToTaskSwitches";
82 OnTaskSwitch(TaskSwitchMetricsRecorder::kDesktop);
83 OnTaskSwitch(TaskSwitchMetricsRecorder::kDesktop);
84 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
86 OnTaskSwitch(TaskSwitchMetricsRecorder::kDesktop);
87 histogram_tester_->ExpectTotalCount(kHistogramName, 2);
90 // Verifies that the TaskSwitchMetricsRecorder::kWindowCycleController source
91 // adds data to the Ash.WindowCycleController.TimeBetweenTaskSwitches histogram.
92 TEST_F(TaskSwitchMetricsRecorderTest,
93 VerifyTaskSwitchesForWindowCycleControllerAreRecorded) {
94 const std::string kHistogramName =
95 "Ash.WindowCycleController.TimeBetweenTaskSwitches";
97 OnTaskSwitch(TaskSwitchMetricsRecorder::kWindowCycleController);
98 OnTaskSwitch(TaskSwitchMetricsRecorder::kWindowCycleController);
99 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
101 OnTaskSwitch(TaskSwitchMetricsRecorder::kWindowCycleController);
102 histogram_tester_->ExpectTotalCount(kHistogramName, 2);
105 // Verifies that the TaskSwitchMetricsRecorder::kShelf source adds data to the
106 // Ash.Shelf.TimeBetweenNavigateToTaskSwitches histogram.
107 TEST_F(TaskSwitchMetricsRecorderTest,
108 VerifyTaskSwitchesFromTheShelfAreRecorded) {
109 const std::string kHistogramName =
110 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches";
112 OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
113 OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
114 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
116 OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
117 histogram_tester_->ExpectTotalCount(kHistogramName, 2);
120 // Verifies that the TaskSwitchMetricsRecorder::kTabStrip source adds data to
121 // the Ash.Tab.TimeBetweenSwitchToExistingTabUserActions histogram.
122 TEST_F(TaskSwitchMetricsRecorderTest,
123 VerifyTaskSwitchesFromTheTabStripAreRecorded) {
124 const std::string kHistogramName =
125 "Ash.Tab.TimeBetweenSwitchToExistingTabUserActions";
127 OnTaskSwitch(TaskSwitchMetricsRecorder::kTabStrip);
128 OnTaskSwitch(TaskSwitchMetricsRecorder::kTabStrip);
129 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
131 OnTaskSwitch(TaskSwitchMetricsRecorder::kTabStrip);
132 histogram_tester_->ExpectTotalCount(kHistogramName, 2);
135 // Verifies that the TaskSwitchMetricsRecorder::kOverviewMode source adds data
136 // to the Ash.WindowSelector.TimeBetweenActiveWindowChanges histogram.
137 TEST_F(TaskSwitchMetricsRecorderTest,
138 VerifyTaskSwitchesFromOverviewModeAreRecorded) {
139 const std::string kHistogramName =
140 "Ash.WindowSelector.TimeBetweenActiveWindowChanges";
142 OnTaskSwitch(TaskSwitchMetricsRecorder::kOverviewMode);
143 OnTaskSwitch(TaskSwitchMetricsRecorder::kOverviewMode);
144 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
146 OnTaskSwitch(TaskSwitchMetricsRecorder::kOverviewMode);
147 histogram_tester_->ExpectTotalCount(kHistogramName, 2);
150 // Verifies that the TaskSwitchMetricsRecorder::kAppList source adds data to the
151 // Ash.AppList.TimeBetweenTaskSwitches histogram.
152 TEST_F(TaskSwitchMetricsRecorderTest,
153 VerifyTaskSwitchesFromApplistAreRecorded) {
154 const std::string kHistogramName = "Ash.AppList.TimeBetweenTaskSwitches";
156 OnTaskSwitch(TaskSwitchMetricsRecorder::kAppList);
157 OnTaskSwitch(TaskSwitchMetricsRecorder::kAppList);
158 histogram_tester_->ExpectTotalCount(kHistogramName, 1);
160 OnTaskSwitch(TaskSwitchMetricsRecorder::kAppList);
161 histogram_tester_->ExpectTotalCount(kHistogramName, 2);
164 } // namespace ash