Commit 0a36ad98 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Rename a header so that it has the .h suffix

input_predictor_unittest.cc is used purely as a header file so
it should have the .h suffix. Now it looks like some .cc files
are trying to include another .cc file.

The class was too large to have an implicit inline
constructor/destructor so those remain in a cc file. This presubmit
check didn't work before because the file was named *.cc.

Change-Id: I67740f4181ea60d02cd3149ce57b0d4e8c36aaf2
Reviewed-on: https://chromium-review.googlesource.com/1255638Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#595838}
parent 839b2e8d
...@@ -452,6 +452,8 @@ if (!is_ios) { ...@@ -452,6 +452,8 @@ if (!is_ios) {
"blink/fling_booster_unittest.cc", "blink/fling_booster_unittest.cc",
"blink/input_handler_proxy_unittest.cc", "blink/input_handler_proxy_unittest.cc",
"blink/input_scroll_elasticity_controller_unittest.cc", "blink/input_scroll_elasticity_controller_unittest.cc",
"blink/prediction/input_predictor_unittest_helpers.cc",
"blink/prediction/input_predictor_unittest_helpers.h",
"blink/prediction/kalman_predictor_unittest.cc", "blink/prediction/kalman_predictor_unittest.cc",
"blink/prediction/least_squares_predictor_unittest.cc", "blink/prediction/least_squares_predictor_unittest.cc",
"blink/scroll_predictor_unittest.cc", "blink/scroll_predictor_unittest.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
namespace ui {
InputPredictorTest::InputPredictorTest() = default;
InputPredictorTest::~InputPredictorTest() = default;
void InputPredictorTest::ValidatePredictor(
const std::vector<double>& x,
const std::vector<double>& y,
const std::vector<double>& timestamp_ms) {
predictor_->Reset();
for (size_t i = 0; i < timestamp_ms.size(); i++) {
if (predictor_->HasPrediction()) {
ui::InputPredictor::InputData result;
EXPECT_TRUE(predictor_->GeneratePrediction(
FromMilliseconds(timestamp_ms[i]), &result));
EXPECT_NEAR(result.pos.x(), x[i], kEpsilon);
EXPECT_NEAR(result.pos.y(), y[i], kEpsilon);
}
InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
FromMilliseconds(timestamp_ms[i])};
predictor_->Update(data);
}
}
} // namespace ui
...@@ -2,25 +2,21 @@ ...@@ -2,25 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_H_ #ifndef UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_HELPERS_H_
#define UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_H_ #define UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_HELPERS_H_
#include "ui/events/blink/prediction/input_predictor.h" #include "ui/events/blink/prediction/input_predictor.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/blink/blink_event_util.h" #include "ui/events/blink/blink_event_util.h"
namespace {
constexpr double kEpsilon = 0.1;
} // namespace
namespace ui { namespace ui {
// Base class for predictor unit tests // Base class for predictor unit tests
class InputPredictorTest : public testing::Test { class InputPredictorTest : public testing::Test {
public: public:
InputPredictorTest() {} InputPredictorTest();
~InputPredictorTest() override;
static base::TimeTicks FromMilliseconds(int64_t ms) { static base::TimeTicks FromMilliseconds(int64_t ms) {
return blink::WebInputEvent::GetStaticTimeStampForTests() + return blink::WebInputEvent::GetStaticTimeStampForTests() +
...@@ -29,23 +25,11 @@ class InputPredictorTest : public testing::Test { ...@@ -29,23 +25,11 @@ class InputPredictorTest : public testing::Test {
void ValidatePredictor(const std::vector<double>& x, void ValidatePredictor(const std::vector<double>& x,
const std::vector<double>& y, const std::vector<double>& y,
const std::vector<double>& timestamp_ms) { const std::vector<double>& timestamp_ms);
predictor_->Reset();
for (size_t i = 0; i < timestamp_ms.size(); i++) {
if (predictor_->HasPrediction()) {
ui::InputPredictor::InputData result;
EXPECT_TRUE(predictor_->GeneratePrediction(
FromMilliseconds(timestamp_ms[i]), &result));
EXPECT_NEAR(result.pos.x(), x[i], kEpsilon);
EXPECT_NEAR(result.pos.y(), y[i], kEpsilon);
}
InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
FromMilliseconds(timestamp_ms[i])};
predictor_->Update(data);
}
}
protected: protected:
static constexpr double kEpsilon = 0.1;
std::unique_ptr<InputPredictor> predictor_; std::unique_ptr<InputPredictor> predictor_;
DISALLOW_COPY_AND_ASSIGN(InputPredictorTest); DISALLOW_COPY_AND_ASSIGN(InputPredictorTest);
...@@ -53,4 +37,4 @@ class InputPredictorTest : public testing::Test { ...@@ -53,4 +37,4 @@ class InputPredictorTest : public testing::Test {
} // namespace ui } // namespace ui
#endif // UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_H_ #endif // UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_HELPERS_H_
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <vector> #include <vector>
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/blink/prediction/input_predictor_unittest.cc" #include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
#include "ui/events/blink/prediction/kalman_predictor.h" #include "ui/events/blink/prediction/kalman_predictor.h"
namespace ui { namespace ui {
...@@ -13,7 +13,6 @@ namespace test { ...@@ -13,7 +13,6 @@ namespace test {
namespace { namespace {
constexpr uint32_t kExpectedStableIterNum = 4; constexpr uint32_t kExpectedStableIterNum = 4;
constexpr double kEpsilon = 0.001;
struct DataSet { struct DataSet {
double initial_observation; double initial_observation;
...@@ -26,6 +25,7 @@ struct DataSet { ...@@ -26,6 +25,7 @@ struct DataSet {
void ValidateSingleKalmanFilter(const DataSet& data) { void ValidateSingleKalmanFilter(const DataSet& data) {
std::unique_ptr<KalmanFilter> kalman_filter = std::unique_ptr<KalmanFilter> kalman_filter =
std::make_unique<KalmanFilter>(); std::make_unique<KalmanFilter>();
constexpr double kEpsilon = 0.001;
constexpr double kDtMillisecond = 8; constexpr double kDtMillisecond = 8;
kalman_filter->Update(data.initial_observation, kDtMillisecond); kalman_filter->Update(data.initial_observation, kDtMillisecond);
for (size_t i = 0; i < data.observation.size(); i++) { for (size_t i = 0; i < data.observation.size(); i++) {
......
...@@ -10,12 +10,12 @@ namespace ui { ...@@ -10,12 +10,12 @@ namespace ui {
namespace { namespace {
constexpr double kEpsilon = std::numeric_limits<double>::epsilon();
// Solve XB = y. // Solve XB = y.
static bool SolveLeastSquares(const gfx::Matrix3F& x, static bool SolveLeastSquares(const gfx::Matrix3F& x,
const std::deque<double>& y, const std::deque<double>& y,
gfx::Vector3dF& result) { gfx::Vector3dF& result) {
constexpr double kEpsilon = std::numeric_limits<double>::epsilon();
// return last point if y didn't change. // return last point if y didn't change.
if (std::abs(y[0] - y[1]) < kEpsilon && std::abs(y[1] - y[2]) < kEpsilon) { if (std::abs(y[0] - y[1]) < kEpsilon && std::abs(y[1] - y[2]) < kEpsilon) {
result = gfx::Vector3dF(y[2], 0, 0); result = gfx::Vector3dF(y[2], 0, 0);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "ui/events/blink/prediction/least_squares_predictor.h" #include "ui/events/blink/prediction/least_squares_predictor.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/blink/prediction/input_predictor_unittest.cc" #include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
namespace ui { namespace ui {
namespace test { namespace test {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment