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> |
| 8 |
7 #include "ash/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
8 #include "ash/shelf/shelf_util.h" | 10 #include "ash/shelf/shelf_util.h" |
9 #include "ash/shell.h" | 11 #include "ash/shell.h" |
10 #include "ash/system/user/login_status.h" | 12 #include "ash/system/user/login_status.h" |
11 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/test_shelf_delegate.h" | 14 #include "ash/test/test_shelf_delegate.h" |
13 #include "ash/test/test_system_tray_delegate.h" | 15 #include "ash/test/test_system_tray_delegate.h" |
14 #include "ash/test/user_metrics_recorder_test_api.h" | 16 #include "ash/test/user_metrics_recorder_test_api.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
18 | 19 |
19 namespace ash { | 20 namespace ash { |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kAsh_NumberOfVisibleWindowsInPrimaryDisplay[] = | 23 const char kAsh_NumberOfVisibleWindowsInPrimaryDisplay[] = |
23 "Ash.NumberOfVisibleWindowsInPrimaryDisplay"; | 24 "Ash.NumberOfVisibleWindowsInPrimaryDisplay"; |
24 | 25 |
25 const char kAsh_ActiveWindowShowTypeOverTime[] = | 26 const char kAsh_ActiveWindowShowTypeOverTime[] = |
(...skipping 29 matching lines...) Expand all Loading... |
55 aura::Window* CreateTestWindow(); | 56 aura::Window* CreateTestWindow(); |
56 | 57 |
57 test::UserMetricsRecorderTestAPI* user_metrics_recorder_test_api() { | 58 test::UserMetricsRecorderTestAPI* user_metrics_recorder_test_api() { |
58 return user_metrics_recorder_test_api_.get(); | 59 return user_metrics_recorder_test_api_.get(); |
59 } | 60 } |
60 | 61 |
61 base::HistogramTester& histograms() { return histograms_; } | 62 base::HistogramTester& histograms() { return histograms_; } |
62 | 63 |
63 private: | 64 private: |
64 // Test API to access private members of the test target. | 65 // Test API to access private members of the test target. |
65 scoped_ptr<test::UserMetricsRecorderTestAPI> user_metrics_recorder_test_api_; | 66 std::unique_ptr<test::UserMetricsRecorderTestAPI> |
| 67 user_metrics_recorder_test_api_; |
66 | 68 |
67 // Histogram value verifier. | 69 // Histogram value verifier. |
68 base::HistogramTester histograms_; | 70 base::HistogramTester histograms_; |
69 | 71 |
70 // The active SystemTrayDelegate. Not owned. | 72 // The active SystemTrayDelegate. Not owned. |
71 test::TestSystemTrayDelegate* test_system_tray_delegate_; | 73 test::TestSystemTrayDelegate* test_system_tray_delegate_; |
72 | 74 |
73 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorderTest); | 75 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorderTest); |
74 }; | 76 }; |
75 | 77 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 aura::Window* unpinned_window_5 = CreateTestWindow(); | 215 aura::Window* unpinned_window_5 = CreateTestWindow(); |
214 test_shelf_delegate->AddShelfItem(unpinned_window_5); | 216 test_shelf_delegate->AddShelfItem(unpinned_window_5); |
215 | 217 |
216 user_metrics_recorder_test_api()->RecordPeriodicMetrics(); | 218 user_metrics_recorder_test_api()->RecordPeriodicMetrics(); |
217 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfItems, 5, 1); | 219 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfItems, 5, 1); |
218 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfPinnedItems, 2, 1); | 220 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfPinnedItems, 2, 1); |
219 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfUnpinnedItems, 3, 1); | 221 histograms().ExpectBucketCount(kAsh_Shelf_NumberOfUnpinnedItems, 3, 1); |
220 } | 222 } |
221 | 223 |
222 } // namespace ash | 224 } // namespace ash |
OLD | NEW |