| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/pointer_metrics_recorder.h" | 5 #include "ash/metrics/pointer_metrics_recorder.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "ash/shared/app_types.h" | 8 #include "ash/shared/app_types.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "ash/wm_window.h" | |
| 13 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
| 13 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/window.h" |
| 14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 15 #include "ui/views/pointer_watcher.h" | 16 #include "ui/views/pointer_watcher.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 | 18 |
| 18 using views::PointerWatcher; | 19 using views::PointerWatcher; |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char kFormFactorHistogramName[] = "Event.DownEventCount.PerFormFactor"; | 24 const char kFormFactorHistogramName[] = "Event.DownEventCount.PerFormFactor"; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 152 |
| 152 // Verifies that down events dispatched to different destinations are recorded. | 153 // Verifies that down events dispatched to different destinations are recorded. |
| 153 TEST_F(PointerMetricsRecorderTest, DownEventPerDestination) { | 154 TEST_F(PointerMetricsRecorderTest, DownEventPerDestination) { |
| 154 std::unique_ptr<views::Widget> target = | 155 std::unique_ptr<views::Widget> target = |
| 155 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); | 156 CreateTestWidget(nullptr, kShellWindowId_DefaultContainer, gfx::Rect()); |
| 156 const ui::PointerEvent pointer_event( | 157 const ui::PointerEvent pointer_event( |
| 157 ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), 0, 0, | 158 ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), 0, 0, |
| 158 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0), | 159 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0), |
| 159 base::TimeTicks()); | 160 base::TimeTicks()); |
| 160 | 161 |
| 161 WmWindow* window = WmWindow::Get(target->GetNativeWindow()); | 162 aura::Window* window = target->GetNativeWindow(); |
| 162 CHECK(window); | 163 CHECK(window); |
| 163 | 164 |
| 164 window->SetAppType(static_cast<int>(AppType::OTHERS)); | 165 window->SetProperty(aura::client::kAppType, |
| 166 static_cast<int>(AppType::OTHERS)); |
| 165 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), | 167 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), |
| 166 target.get()); | 168 target.get()); |
| 167 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 0, 1); | 169 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 0, 1); |
| 168 | 170 |
| 169 window->SetAppType(static_cast<int>(AppType::BROWSER)); | 171 window->SetProperty(aura::client::kAppType, |
| 172 static_cast<int>(AppType::BROWSER)); |
| 170 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), | 173 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), |
| 171 target.get()); | 174 target.get()); |
| 172 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 1, 1); | 175 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 1, 1); |
| 173 | 176 |
| 174 window->SetAppType(static_cast<int>(AppType::CHROME_APP)); | 177 window->SetProperty(aura::client::kAppType, |
| 178 static_cast<int>(AppType::CHROME_APP)); |
| 175 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), | 179 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), |
| 176 target.get()); | 180 target.get()); |
| 177 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 2, 1); | 181 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 2, 1); |
| 178 | 182 |
| 179 window->SetAppType(static_cast<int>(AppType::ARC_APP)); | 183 window->SetProperty(aura::client::kAppType, |
| 184 static_cast<int>(AppType::ARC_APP)); |
| 180 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), | 185 pointer_metrics_recorder_->OnPointerEventObserved(pointer_event, gfx::Point(), |
| 181 target.get()); | 186 target.get()); |
| 182 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 3, 1); | 187 histogram_tester_->ExpectBucketCount(kDestinationHistogramName, 3, 1); |
| 183 } | 188 } |
| 184 | 189 |
| 185 } // namespace ash | 190 } // namespace ash |
| OLD | NEW |