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/test/test_shelf_delegate.h" | 11 #include "ash/common/test/test_shelf_delegate.h" |
12 #include "ash/common/test/test_system_tray_delegate.h" | 12 #include "ash/common/test/test_system_tray_delegate.h" |
13 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
14 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 15 #include "ash/shell.h" |
15 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
16 #include "ash/test/user_metrics_recorder_test_api.h" | 17 #include "ash/test/user_metrics_recorder_test_api.h" |
17 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 namespace { | 22 namespace { |
22 | 23 |
23 const char kAsh_NumberOfVisibleWindowsInPrimaryDisplay[] = | 24 const char kAsh_NumberOfVisibleWindowsInPrimaryDisplay[] = |
24 "Ash.NumberOfVisibleWindowsInPrimaryDisplay"; | 25 "Ash.NumberOfVisibleWindowsInPrimaryDisplay"; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 TEST_F(UserMetricsRecorderTest, ValuesRecordedByRecordShelfItemCounts) { | 190 TEST_F(UserMetricsRecorderTest, ValuesRecordedByRecordShelfItemCounts) { |
190 // TODO: investigate failure in mash, http://crbug.com/695629. | 191 // TODO: investigate failure in mash, http://crbug.com/695629. |
191 if (WmShell::Get()->IsRunningInMash()) | 192 if (WmShell::Get()->IsRunningInMash()) |
192 return; | 193 return; |
193 | 194 |
194 test::TestShelfDelegate* test_shelf_delegate = | 195 test::TestShelfDelegate* test_shelf_delegate = |
195 test::TestShelfDelegate::instance(); | 196 test::TestShelfDelegate::instance(); |
196 SetUserInActiveDesktopEnvironment(true); | 197 SetUserInActiveDesktopEnvironment(true); |
197 | 198 |
198 // Make sure the shelf contains the app list launcher button. | 199 // Make sure the shelf contains the app list launcher button. |
199 const ShelfItems& shelf_items = WmShell::Get()->shelf_model()->items(); | 200 const ShelfItems& shelf_items = Shell::Get()->shelf_model()->items(); |
200 ASSERT_EQ(1u, shelf_items.size()); | 201 ASSERT_EQ(1u, shelf_items.size()); |
201 ASSERT_EQ(TYPE_APP_LIST, shelf_items[0].type); | 202 ASSERT_EQ(TYPE_APP_LIST, shelf_items[0].type); |
202 | 203 |
203 aura::Window* pinned_window_with_app_id_1 = CreateTestWindow(); | 204 aura::Window* pinned_window_with_app_id_1 = CreateTestWindow(); |
204 test_shelf_delegate->AddShelfItem(WmWindow::Get(pinned_window_with_app_id_1), | 205 test_shelf_delegate->AddShelfItem(WmWindow::Get(pinned_window_with_app_id_1), |
205 "app_id_1"); | 206 "app_id_1"); |
206 test_shelf_delegate->PinAppWithID("app_id_1"); | 207 test_shelf_delegate->PinAppWithID("app_id_1"); |
207 | 208 |
208 aura::Window* pinned_window_with_app_id_2 = CreateTestWindow(); | 209 aura::Window* pinned_window_with_app_id_2 = CreateTestWindow(); |
209 test_shelf_delegate->AddShelfItem(WmWindow::Get(pinned_window_with_app_id_2), | 210 test_shelf_delegate->AddShelfItem(WmWindow::Get(pinned_window_with_app_id_2), |
(...skipping 10 matching lines...) Expand all Loading... |
220 aura::Window* unpinned_window_5 = CreateTestWindow(); | 221 aura::Window* unpinned_window_5 = CreateTestWindow(); |
221 test_shelf_delegate->AddShelfItem(WmWindow::Get(unpinned_window_5)); | 222 test_shelf_delegate->AddShelfItem(WmWindow::Get(unpinned_window_5)); |
222 | 223 |
223 user_metrics_recorder_test_api()->RecordPeriodicMetrics(); | 224 user_metrics_recorder_test_api()->RecordPeriodicMetrics(); |
224 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfItems, 5, 1); | 225 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfItems, 5, 1); |
225 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfPinnedItems, 2, 1); | 226 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfPinnedItems, 2, 1); |
226 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfUnpinnedItems, 3, 1); | 227 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfUnpinnedItems, 3, 1); |
227 } | 228 } |
228 | 229 |
229 } // namespace ash | 230 } // namespace ash |
OLD | NEW |