OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/metrics/user_metrics_recorder.h" | 5 #include "ash/metrics/user_metrics_recorder.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/common/login_status.h" | 9 #include "ash/common/login_status.h" |
10 #include "ash/common/shelf/shelf_model.h" | 10 #include "ash/common/shelf/shelf_model.h" |
| 11 #include "ash/common/wm_shell.h" |
11 #include "ash/shelf/shelf_util.h" | 12 #include "ash/shelf/shelf_util.h" |
12 #include "ash/shell.h" | |
13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
14 #include "ash/test/test_shelf_delegate.h" | 14 #include "ash/test/test_shelf_delegate.h" |
15 #include "ash/test/test_system_tray_delegate.h" | 15 #include "ash/test/test_system_tray_delegate.h" |
16 #include "ash/test/user_metrics_recorder_test_api.h" | 16 #include "ash/test/user_metrics_recorder_test_api.h" |
17 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 namespace { | 21 namespace { |
22 | 22 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 185 } |
186 | 186 |
187 // Verify the shelf item counts recorded by the | 187 // Verify the shelf item counts recorded by the |
188 // UserMetricsRecorder::RecordPeriodicMetrics() method. | 188 // UserMetricsRecorder::RecordPeriodicMetrics() method. |
189 TEST_F(UserMetricsRecorderTest, ValuesRecordedByRecordShelfItemCounts) { | 189 TEST_F(UserMetricsRecorderTest, ValuesRecordedByRecordShelfItemCounts) { |
190 test::TestShelfDelegate* test_shelf_delegate = | 190 test::TestShelfDelegate* test_shelf_delegate = |
191 test::TestShelfDelegate::instance(); | 191 test::TestShelfDelegate::instance(); |
192 SetUserInActiveDesktopEnvironment(true); | 192 SetUserInActiveDesktopEnvironment(true); |
193 | 193 |
194 // Make sure the shelf contains the app list launcher button. | 194 // Make sure the shelf contains the app list launcher button. |
195 const ShelfItems& shelf_items = Shell::GetInstance()->shelf_model()->items(); | 195 const ShelfItems& shelf_items = WmShell::Get()->shelf_model()->items(); |
196 ASSERT_EQ(1u, shelf_items.size()); | 196 ASSERT_EQ(1u, shelf_items.size()); |
197 ASSERT_EQ(TYPE_APP_LIST, shelf_items[0].type); | 197 ASSERT_EQ(TYPE_APP_LIST, shelf_items[0].type); |
198 | 198 |
199 aura::Window* pinned_window_with_app_id_1 = CreateTestWindow(); | 199 aura::Window* pinned_window_with_app_id_1 = CreateTestWindow(); |
200 test_shelf_delegate->AddShelfItem(pinned_window_with_app_id_1, "app_id_1"); | 200 test_shelf_delegate->AddShelfItem(pinned_window_with_app_id_1, "app_id_1"); |
201 test_shelf_delegate->PinAppWithID("app_id_1"); | 201 test_shelf_delegate->PinAppWithID("app_id_1"); |
202 | 202 |
203 aura::Window* pinned_window_with_app_id_2 = CreateTestWindow(); | 203 aura::Window* pinned_window_with_app_id_2 = CreateTestWindow(); |
204 test_shelf_delegate->AddShelfItem(pinned_window_with_app_id_2, "app_id_2"); | 204 test_shelf_delegate->AddShelfItem(pinned_window_with_app_id_2, "app_id_2"); |
205 test_shelf_delegate->PinAppWithID("app_id_2"); | 205 test_shelf_delegate->PinAppWithID("app_id_2"); |
206 | 206 |
207 aura::Window* unpinned_window_with_app_id_3 = CreateTestWindow(); | 207 aura::Window* unpinned_window_with_app_id_3 = CreateTestWindow(); |
208 test_shelf_delegate->AddShelfItem(unpinned_window_with_app_id_3, "app_id_3"); | 208 test_shelf_delegate->AddShelfItem(unpinned_window_with_app_id_3, "app_id_3"); |
209 | 209 |
210 aura::Window* unpinned_window_4 = CreateTestWindow(); | 210 aura::Window* unpinned_window_4 = CreateTestWindow(); |
211 test_shelf_delegate->AddShelfItem(unpinned_window_4); | 211 test_shelf_delegate->AddShelfItem(unpinned_window_4); |
212 | 212 |
213 aura::Window* unpinned_window_5 = CreateTestWindow(); | 213 aura::Window* unpinned_window_5 = CreateTestWindow(); |
214 test_shelf_delegate->AddShelfItem(unpinned_window_5); | 214 test_shelf_delegate->AddShelfItem(unpinned_window_5); |
215 | 215 |
216 user_metrics_recorder_test_api()->RecordPeriodicMetrics(); | 216 user_metrics_recorder_test_api()->RecordPeriodicMetrics(); |
217 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfItems, 5, 1); | 217 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfItems, 5, 1); |
218 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfPinnedItems, 2, 1); | 218 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfPinnedItems, 2, 1); |
219 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfUnpinnedItems, 3, 1); | 219 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfUnpinnedItems, 3, 1); |
220 } | 220 } |
221 | 221 |
222 } // namespace ash | 222 } // namespace ash |
OLD | NEW |