| 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/shelf/shelf_button_pressed_metric_tracker.h" | 5 #include "ash/shelf/shelf_button_pressed_metric_tracker.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // A simple light weight test double dummy for a views::Button. | 26 // A simple light weight test double dummy for a views::Button. |
| 27 class DummyButton : public views::Button { | 27 class DummyButton : public views::Button { |
| 28 public: | 28 public: |
| 29 DummyButton(); | 29 DummyButton(); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(DummyButton); | 32 DISALLOW_COPY_AND_ASSIGN(DummyButton); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 DummyButton::DummyButton() : views::Button(nullptr) { | 35 DummyButton::DummyButton() : views::Button(nullptr) {} |
| 36 } | |
| 37 | 36 |
| 38 // A simple light weight test double dummy for a ui::Event. | 37 // A simple light weight test double dummy for a ui::Event. |
| 39 class DummyEvent : public ui::Event { | 38 class DummyEvent : public ui::Event { |
| 40 public: | 39 public: |
| 41 DummyEvent(); | 40 DummyEvent(); |
| 42 ~DummyEvent() override; | 41 ~DummyEvent() override; |
| 43 int unique_id() const { return unique_id_; } | 42 int unique_id() const { return unique_id_; } |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 static int next_unique_id_; | 45 static int next_unique_id_; |
| 47 int unique_id_; | 46 int unique_id_; |
| 48 | 47 |
| 49 DISALLOW_COPY_AND_ASSIGN(DummyEvent); | 48 DISALLOW_COPY_AND_ASSIGN(DummyEvent); |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 int DummyEvent::next_unique_id_ = 0; | 51 int DummyEvent::next_unique_id_ = 0; |
| 53 | 52 |
| 54 DummyEvent::DummyEvent() | 53 DummyEvent::DummyEvent() |
| 55 : Event(ui::ET_GESTURE_TAP, base::TimeTicks(), 0), | 54 : Event(ui::ET_GESTURE_TAP, base::TimeTicks(), 0), |
| 56 unique_id_(next_unique_id_++) {} | 55 unique_id_(next_unique_id_++) {} |
| 57 | 56 |
| 58 DummyEvent::~DummyEvent() { | 57 DummyEvent::~DummyEvent() {} |
| 59 } | |
| 60 | 58 |
| 61 // Test fixture for the ShelfButtonPressedMetricTracker class. Relies on | 59 // Test fixture for the ShelfButtonPressedMetricTracker class. Relies on |
| 62 // AshTestBase to initilize the UserMetricsRecorder and it's dependencies. | 60 // AshTestBase to initilize the UserMetricsRecorder and it's dependencies. |
| 63 class ShelfButtonPressedMetricTrackerTest : public AshTestBase { | 61 class ShelfButtonPressedMetricTrackerTest : public AshTestBase { |
| 64 public: | 62 public: |
| 65 static const char* | 63 static const char* |
| 66 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; | 64 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; |
| 67 | 65 |
| 68 ShelfButtonPressedMetricTrackerTest(); | 66 ShelfButtonPressedMetricTrackerTest(); |
| 69 ~ShelfButtonPressedMetricTrackerTest() override; | 67 ~ShelfButtonPressedMetricTrackerTest() override; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 94 | 92 |
| 95 private: | 93 private: |
| 96 DISALLOW_COPY_AND_ASSIGN(ShelfButtonPressedMetricTrackerTest); | 94 DISALLOW_COPY_AND_ASSIGN(ShelfButtonPressedMetricTrackerTest); |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 const char* ShelfButtonPressedMetricTrackerTest:: | 97 const char* ShelfButtonPressedMetricTrackerTest:: |
| 100 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName = | 98 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName = |
| 101 ShelfButtonPressedMetricTracker:: | 99 ShelfButtonPressedMetricTracker:: |
| 102 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; | 100 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; |
| 103 | 101 |
| 104 ShelfButtonPressedMetricTrackerTest::ShelfButtonPressedMetricTrackerTest() { | 102 ShelfButtonPressedMetricTrackerTest::ShelfButtonPressedMetricTrackerTest() {} |
| 105 } | |
| 106 | 103 |
| 107 ShelfButtonPressedMetricTrackerTest::~ShelfButtonPressedMetricTrackerTest() { | 104 ShelfButtonPressedMetricTrackerTest::~ShelfButtonPressedMetricTrackerTest() {} |
| 108 } | |
| 109 | 105 |
| 110 void ShelfButtonPressedMetricTrackerTest::SetUp() { | 106 void ShelfButtonPressedMetricTrackerTest::SetUp() { |
| 111 AshTestBase::SetUp(); | 107 AshTestBase::SetUp(); |
| 112 | 108 |
| 113 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 109 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 114 ShelfViewTestAPI shelf_view_test_api(ShelfTestAPI(shelf).shelf_view()); | 110 ShelfViewTestAPI shelf_view_test_api(ShelfTestAPI(shelf).shelf_view()); |
| 115 | 111 |
| 116 metric_tracker_ = shelf_view_test_api.shelf_button_pressed_metric_tracker(); | 112 metric_tracker_ = shelf_view_test_api.shelf_button_pressed_metric_tracker(); |
| 117 | 113 |
| 118 ShelfButtonPressedMetricTrackerTestAPI test_api(metric_tracker_); | 114 ShelfButtonPressedMetricTrackerTestAPI test_api(metric_tracker_); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 288 |
| 293 histogram_tester.ExpectTotalCount( | 289 histogram_tester.ExpectTotalCount( |
| 294 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1); | 290 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1); |
| 295 histogram_tester.ExpectBucketCount( | 291 histogram_tester.ExpectBucketCount( |
| 296 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, | 292 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, |
| 297 kTimeDeltaInMilliseconds, 1); | 293 kTimeDeltaInMilliseconds, 1); |
| 298 } | 294 } |
| 299 | 295 |
| 300 } // namespace test | 296 } // namespace test |
| 301 } // namespace ash | 297 } // namespace ash |
| OLD | NEW |