Commit d845bf71 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

PlatformSensorAndProviderLinuxTest: Make InitializeMockUdevMethods() implicit.

Instead of requiring each test to call InitializeMockUdevMethods(), install
the mocks automatically in MockSensorDeviceManager itself.

There is no functional change, but the code should look cleaner.

Change-Id: I428cca938b3d13163f23f7bd2a093ca168081833
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214389
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771946}
parent bb7a673f
...@@ -90,9 +90,40 @@ double RoundGyroscopeValue(double value) { ...@@ -90,9 +90,40 @@ double RoundGyroscopeValue(double value) {
// to SensorDeviceManager. // to SensorDeviceManager.
class MockSensorDeviceManager : public SensorDeviceManager { class MockSensorDeviceManager : public SensorDeviceManager {
public: public:
MockSensorDeviceManager(base::WeakPtr<SensorDeviceManager::Delegate> delegate) ~MockSensorDeviceManager() override = default;
: SensorDeviceManager(std::move(delegate)) {}
~MockSensorDeviceManager() override {} // static
static std::unique_ptr<NiceMock<MockSensorDeviceManager>> Create(
base::WeakPtr<SensorDeviceManager::Delegate> delegate) {
auto device_manager =
std::make_unique<NiceMock<MockSensorDeviceManager>>(delegate);
{
base::ScopedAllowBlockingForTesting allow_blocking;
if (!device_manager->sensors_dir_.CreateUniqueTempDir())
return nullptr;
}
const base::FilePath& base_path = device_manager->GetSensorsBasePath();
ON_CALL(*device_manager, GetUdevDeviceGetSubsystem(IsNull()))
.WillByDefault(Invoke([](udev_device*) { return "iio"; }));
ON_CALL(*device_manager, GetUdevDeviceGetSyspath(IsNull()))
.WillByDefault(
Invoke([base_path](udev_device*) { return base_path.value(); }));
ON_CALL(*device_manager, GetUdevDeviceGetDevnode(IsNull()))
.WillByDefault(Invoke([](udev_device*) { return "/dev/test"; }));
ON_CALL(*device_manager, GetUdevDeviceGetSysattrValue(IsNull(), _))
.WillByDefault(
Invoke([base_path](udev_device*, const std::string& attribute) {
base::ScopedAllowBlockingForTesting allow_blocking;
return ReadValueFromFile(base_path, attribute);
}));
return device_manager;
}
MOCK_METHOD1(GetUdevDeviceGetSubsystem, std::string(udev_device*)); MOCK_METHOD1(GetUdevDeviceGetSubsystem, std::string(udev_device*));
MOCK_METHOD1(GetUdevDeviceGetSyspath, std::string(udev_device*)); MOCK_METHOD1(GetUdevDeviceGetSyspath, std::string(udev_device*));
...@@ -101,6 +132,10 @@ class MockSensorDeviceManager : public SensorDeviceManager { ...@@ -101,6 +132,10 @@ class MockSensorDeviceManager : public SensorDeviceManager {
std::string(udev_device*, const std::string&)); std::string(udev_device*, const std::string&));
MOCK_METHOD0(Start, void()); MOCK_METHOD0(Start, void());
const base::FilePath& GetSensorsBasePath() const {
return sensors_dir_.GetPath();
}
void EnumerationReady() { void EnumerationReady() {
bool success = delegate_task_runner_->PostTask( bool success = delegate_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
...@@ -117,7 +152,14 @@ class MockSensorDeviceManager : public SensorDeviceManager { ...@@ -117,7 +152,14 @@ class MockSensorDeviceManager : public SensorDeviceManager {
SensorDeviceManager::OnDeviceRemoved(nullptr /* unused */); SensorDeviceManager::OnDeviceRemoved(nullptr /* unused */);
} }
protected:
explicit MockSensorDeviceManager(
base::WeakPtr<SensorDeviceManager::Delegate> delegate)
: SensorDeviceManager(std::move(delegate)) {}
private: private:
base::ScopedTempDir sensors_dir_;
DISALLOW_COPY_AND_ASSIGN(MockSensorDeviceManager); DISALLOW_COPY_AND_ASSIGN(MockSensorDeviceManager);
}; };
...@@ -155,22 +197,13 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test { ...@@ -155,22 +197,13 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test {
void SetUp() override { void SetUp() override {
provider_ = base::WrapUnique(new PlatformSensorProviderLinux); provider_ = base::WrapUnique(new PlatformSensorProviderLinux);
auto manager = std::make_unique<NiceMock<MockSensorDeviceManager>>( auto manager = MockSensorDeviceManager::Create(
provider_->weak_ptr_factory_.GetWeakPtr()); provider_->weak_ptr_factory_.GetWeakPtr());
manager_ = manager.get(); manager_ = manager.get();
provider_->SetSensorDeviceManagerForTesting(std::move(manager)); provider_->SetSensorDeviceManagerForTesting(std::move(manager));
{
base::ScopedAllowBlockingForTesting allow_blocking;
ASSERT_TRUE(sensors_dir_.CreateUniqueTempDir());
}
} }
void TearDown() override { void TearDown() override {
{
base::ScopedAllowBlockingForTesting allow_blocking;
ASSERT_TRUE(sensors_dir_.Delete());
}
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
...@@ -204,7 +237,7 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test { ...@@ -204,7 +237,7 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test {
{ {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath sensor_dir = sensors_dir_.GetPath(); const base::FilePath& sensor_dir = manager_->GetSensorsBasePath();
if (!data.sensor_scale_name.empty() && scaling != 0) { if (!data.sensor_scale_name.empty() && scaling != 0) {
base::FilePath sensor_scale_file = base::FilePath sensor_scale_file =
base::FilePath(sensor_dir).Append(data.sensor_scale_name); base::FilePath(sensor_dir).Append(data.sensor_scale_name);
...@@ -239,28 +272,6 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test { ...@@ -239,28 +272,6 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test {
} }
} }
// Initializes mock udev methods that emulate system methods by
// just reading values from files, which SensorDeviceService has specified
// calling udev methods.
void InitializeMockUdevMethods(const base::FilePath& sensor_dir) {
ON_CALL(*manager_, GetUdevDeviceGetSubsystem(IsNull()))
.WillByDefault(Invoke([](udev_device* dev) { return "iio"; }));
ON_CALL(*manager_, GetUdevDeviceGetSyspath(IsNull()))
.WillByDefault(Invoke(
[sensor_dir](udev_device* dev) { return sensor_dir.value(); }));
ON_CALL(*manager_, GetUdevDeviceGetDevnode(IsNull()))
.WillByDefault(Invoke([](udev_device* dev) { return "/dev/test"; }));
ON_CALL(*manager_, GetUdevDeviceGetSysattrValue(IsNull(), _))
.WillByDefault(Invoke(
[sensor_dir](udev_device* dev, const std::string& attribute) {
base::ScopedAllowBlockingForTesting allow_blocking;
return ReadValueFromFile(sensor_dir, attribute);
}));
}
// Emulates device enumerations and initial udev events. Once all // Emulates device enumerations and initial udev events. Once all
// devices are added, tells manager its ready. // devices are added, tells manager its ready.
void SetServiceStart() { void SetServiceStart() {
...@@ -320,8 +331,6 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test { ...@@ -320,8 +331,6 @@ class PlatformSensorAndProviderLinuxTest : public ::testing::Test {
MockSensorDeviceManager* manager_; MockSensorDeviceManager* manager_;
std::unique_ptr<PlatformSensorProviderLinux> provider_; std::unique_ptr<PlatformSensorProviderLinux> provider_;
// Holds base dir where a sensor dir is located.
base::ScopedTempDir sensors_dir_;
// Used to simulate the non-test scenario where we're running in an IO thread // Used to simulate the non-test scenario where we're running in an IO thread
// that forbids blocking operations. // that forbids blocking operations.
...@@ -351,7 +360,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorIsSupported) { ...@@ -351,7 +360,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorIsSupported) {
double sensor_value[3] = {5}; double sensor_value[3] = {5};
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -365,7 +373,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, StartFails) { ...@@ -365,7 +373,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, StartFails) {
double sensor_value[3] = {5}; double sensor_value[3] = {5};
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -383,7 +390,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorStarted) { ...@@ -383,7 +390,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorStarted) {
double sensor_value[3] = {5}; double sensor_value[3] = {5};
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -402,7 +408,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorRemoved) { ...@@ -402,7 +408,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorRemoved) {
double sensor_value[3] = {1}; double sensor_value[3] = {1};
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -412,7 +417,7 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorRemoved) { ...@@ -412,7 +417,7 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorRemoved) {
std::make_unique<NiceMock<LinuxMockPlatformSensorClient>>(sensor); std::make_unique<NiceMock<LinuxMockPlatformSensorClient>>(sensor);
PlatformSensorConfiguration configuration(5); PlatformSensorConfiguration configuration(5);
EXPECT_TRUE(sensor->StartListening(client.get(), configuration)); EXPECT_TRUE(sensor->StartListening(client.get(), configuration));
GenerateDeviceRemovedEvent(sensors_dir_.GetPath()); GenerateDeviceRemovedEvent(manager_->GetSensorsBasePath());
WaitOnSensorErrorEvent(client.get()); WaitOnSensorErrorEvent(client.get());
} }
...@@ -422,7 +427,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorAddedAndRemoved) { ...@@ -422,7 +427,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, SensorAddedAndRemoved) {
double sensor_value[3] = {1, 2, 4}; double sensor_value[3] = {1, 2, 4};
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto als_sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto als_sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -453,7 +457,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckAllSupportedSensors) { ...@@ -453,7 +457,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckAllSupportedSensors) {
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::MAGNETOMETER, kMagnetometerFrequencyValue, SensorType::MAGNETOMETER, kMagnetometerFrequencyValue,
kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value); kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto als_sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto als_sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -487,7 +490,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, GetMaximumSupportedFrequency) { ...@@ -487,7 +490,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, GetMaximumSupportedFrequency) {
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, SensorType::ACCELEROMETER, kAccelerometerFrequencyValue,
kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value); kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::ACCELEROMETER); auto sensor = CreateSensor(SensorType::ACCELEROMETER);
...@@ -503,7 +505,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -503,7 +505,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
double sensor_value[3] = {5}; double sensor_value[3] = {5};
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -524,7 +525,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckAmbientLightReadings) { ...@@ -524,7 +525,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckAmbientLightReadings) {
InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero, InitializeSupportedSensor(SensorType::AMBIENT_LIGHT, kZero, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -566,7 +566,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -566,7 +566,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
kAccelerometerOffsetValue, kAccelerometerOffsetValue,
kAccelerometerScalingValue, sensor_values); kAccelerometerScalingValue, sensor_values);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::ACCELEROMETER); auto sensor = CreateSensor(SensorType::ACCELEROMETER);
...@@ -610,7 +609,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -610,7 +609,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
// not available. // not available.
TEST_F(PlatformSensorAndProviderLinuxTest, TEST_F(PlatformSensorAndProviderLinuxTest,
CheckLinearAccelerationSensorNotCreatedIfNoAccelerometer) { CheckLinearAccelerationSensorNotCreatedIfNoAccelerometer) {
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::LINEAR_ACCELERATION); auto sensor = CreateSensor(SensorType::LINEAR_ACCELERATION);
...@@ -633,7 +631,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckLinearAcceleration) { ...@@ -633,7 +631,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckLinearAcceleration) {
kAccelerometerFrequencyValue, kZero, kZero, kAccelerometerFrequencyValue, kZero, kZero,
sensor_values); sensor_values);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::LINEAR_ACCELERATION); auto sensor = CreateSensor(SensorType::LINEAR_ACCELERATION);
...@@ -679,7 +676,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckGyroscopeReadingConversion) { ...@@ -679,7 +676,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckGyroscopeReadingConversion) {
InitializeSupportedSensor(SensorType::GYROSCOPE, kZero, kGyroscopeOffsetValue, InitializeSupportedSensor(SensorType::GYROSCOPE, kZero, kGyroscopeOffsetValue,
kGyroscopeScalingValue, sensor_values); kGyroscopeScalingValue, sensor_values);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::GYROSCOPE); auto sensor = CreateSensor(SensorType::GYROSCOPE);
...@@ -740,7 +736,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckMagnetometerReadingConversion) { ...@@ -740,7 +736,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, CheckMagnetometerReadingConversion) {
kMagnetometerOffsetValue, kMagnetometerScalingValue, kMagnetometerOffsetValue, kMagnetometerScalingValue,
sensor_values); sensor_values);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::MAGNETOMETER); auto sensor = CreateSensor(SensorType::MAGNETOMETER);
...@@ -784,7 +779,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -784,7 +779,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
kAmbientLightFrequencyValue, kZero, kZero, kAmbientLightFrequencyValue, kZero, kZero,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT); auto sensor = CreateSensor(SensorType::AMBIENT_LIGHT);
...@@ -812,7 +806,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -812,7 +806,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
TEST_F( TEST_F(
PlatformSensorAndProviderLinuxTest, PlatformSensorAndProviderLinuxTest,
CheckAbsoluteOrientationSensorNotCreatedIfNoAccelerometerAndNoMagnetometer) { CheckAbsoluteOrientationSensorNotCreatedIfNoAccelerometerAndNoMagnetometer) {
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
{ {
...@@ -834,7 +827,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -834,7 +827,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::MAGNETOMETER, kMagnetometerFrequencyValue, SensorType::MAGNETOMETER, kMagnetometerFrequencyValue,
kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value); kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
{ {
...@@ -856,7 +848,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -856,7 +848,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, SensorType::ACCELEROMETER, kAccelerometerFrequencyValue,
kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value); kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
{ {
...@@ -880,7 +871,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -880,7 +871,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::MAGNETOMETER, kMagnetometerFrequencyValue, SensorType::MAGNETOMETER, kMagnetometerFrequencyValue,
kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value); kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES); auto sensor = CreateSensor(SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES);
...@@ -897,7 +887,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -897,7 +887,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::MAGNETOMETER, kMagnetometerFrequencyValue, SensorType::MAGNETOMETER, kMagnetometerFrequencyValue,
kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value); kMagnetometerOffsetValue, kMagnetometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::ABSOLUTE_ORIENTATION_QUATERNION); auto sensor = CreateSensor(SensorType::ABSOLUTE_ORIENTATION_QUATERNION);
...@@ -909,7 +898,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -909,7 +898,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
TEST_F( TEST_F(
PlatformSensorAndProviderLinuxTest, PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationSensorNotCreatedIfNoAccelerometerAndNoGyroscope) { CheckRelativeOrientationSensorNotCreatedIfNoAccelerometerAndNoGyroscope) {
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
{ {
...@@ -931,7 +919,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -931,7 +919,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor(SensorType::GYROSCOPE, kGyroscopeFrequencyValue, InitializeSupportedSensor(SensorType::GYROSCOPE, kGyroscopeFrequencyValue,
kGyroscopeOffsetValue, kGyroscopeScalingValue, kGyroscopeOffsetValue, kGyroscopeScalingValue,
sensor_value); sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
{ {
...@@ -957,7 +944,6 @@ TEST_F( ...@@ -957,7 +944,6 @@ TEST_F(
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, SensorType::ACCELEROMETER, kAccelerometerFrequencyValue,
kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value); kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_EULER_ANGLES); auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_EULER_ANGLES);
...@@ -972,7 +958,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -972,7 +958,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, SensorType::ACCELEROMETER, kAccelerometerFrequencyValue,
kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value); kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_EULER_ANGLES); auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_EULER_ANGLES);
...@@ -990,7 +975,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -990,7 +975,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, SensorType::ACCELEROMETER, kAccelerometerFrequencyValue,
kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value); kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_QUATERNION); auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_QUATERNION);
...@@ -1005,7 +989,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest, ...@@ -1005,7 +989,6 @@ TEST_F(PlatformSensorAndProviderLinuxTest,
InitializeSupportedSensor( InitializeSupportedSensor(
SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, SensorType::ACCELEROMETER, kAccelerometerFrequencyValue,
kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value); kAccelerometerOffsetValue, kAccelerometerScalingValue, sensor_value);
InitializeMockUdevMethods(sensors_dir_.GetPath());
SetServiceStart(); SetServiceStart();
auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_QUATERNION); auto sensor = CreateSensor(SensorType::RELATIVE_ORIENTATION_QUATERNION);
......
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