| 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 "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" | 5 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
| 10 | 11 |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/events/ozone/evdev/touch_evdev_types.h" | 16 #include "ui/events/ozone/evdev/touch_evdev_types.h" |
| 17 #include "ui/gfx/geometry/point_f.h" | 17 #include "ui/gfx/geometry/point_f.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 class TouchNoiseFinderTest : public testing::Test { | 21 class TouchNoiseFinderTest : public testing::Test { |
| 22 public: | 22 public: |
| 23 struct TouchEntry { | 23 struct TouchEntry { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 // testing::Test: | 76 // testing::Test: |
| 77 void SetUp() override { | 77 void SetUp() override { |
| 78 touch_noise_finder_.reset(new TouchNoiseFinder); | 78 touch_noise_finder_.reset(new TouchNoiseFinder); |
| 79 } | 79 } |
| 80 | 80 |
| 81 scoped_ptr<TouchNoiseFinder> touch_noise_finder_; | 81 std::unique_ptr<TouchNoiseFinder> touch_noise_finder_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(TouchNoiseFinderTest); | 83 DISALLOW_COPY_AND_ASSIGN(TouchNoiseFinderTest); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // Test that taps which are far apart in quick succession are considered noise. | 86 // Test that taps which are far apart in quick succession are considered noise. |
| 87 TEST_F(TouchNoiseFinderTest, FarApartTaps) { | 87 TEST_F(TouchNoiseFinderTest, FarApartTaps) { |
| 88 const TouchEntry kTestData[] = { | 88 const TouchEntry kTestData[] = { |
| 89 {10, 1, true, gfx::PointF(10, 10), false}, | 89 {10, 1, true, gfx::PointF(10, 10), false}, |
| 90 {20, 1, true, gfx::PointF(10, 11), false}, | 90 {20, 1, true, gfx::PointF(10, 11), false}, |
| 91 {30, 1, true, gfx::PointF(10, 12), false}, | 91 {30, 1, true, gfx::PointF(10, 12), false}, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 {1000, 1, true, gfx::PointF(10, 10), false}, | 148 {1000, 1, true, gfx::PointF(10, 10), false}, |
| 149 {2000, 1, true, gfx::PointF(10, 11), false}, | 149 {2000, 1, true, gfx::PointF(10, 11), false}, |
| 150 {3000, 1, true, gfx::PointF(10, 10), false}, | 150 {3000, 1, true, gfx::PointF(10, 10), false}, |
| 151 {4000, 1, true, gfx::PointF(10, 11), true}, | 151 {4000, 1, true, gfx::PointF(10, 11), true}, |
| 152 {5000, 1, true, gfx::PointF(10, 10), true}, | 152 {5000, 1, true, gfx::PointF(10, 10), true}, |
| 153 {6000, 1, true, gfx::PointF(10, 11), true}}; | 153 {6000, 1, true, gfx::PointF(10, 11), true}}; |
| 154 EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData))); | 154 EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData))); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace ui | 157 } // namespace ui |
| OLD | NEW |