#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <algorithm>
#include <memory>
#include "base/barrier_closure.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/numerics/math_constants.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/threading/thread_restrictions.h"
#include "build/chromeos_buildflags.h"
#include "services/device/generic_sensor/generic_sensor_consts.h"
#include "services/device/generic_sensor/linux/sensor_data_linux.h"
#include "services/device/generic_sensor/linux/sensor_device_manager.h"
#include "services/device/generic_sensor/platform_sensor_provider_linux.h"
#include "services/device/generic_sensor/platform_sensor_util.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading_shared_buffer.h"
#include "services/device/public/cpp/generic_sensor/sensor_traits.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
TestFuture;
_;
Invoke;
IsNull;
NiceMock;
NotNull;
Return;
namespace device {
namespace {
SensorType;
constexpr size_t kSensorValuesSize = …;
constexpr double kZero = …;
constexpr double kAmbientLightFrequencyValue = …;
constexpr double kAccelerometerFrequencyValue = …;
constexpr double kAccelerometerOffsetValue = …;
constexpr double kAccelerometerScalingValue = …;
constexpr double kGyroscopeFrequencyValue = …;
constexpr double kGyroscopeOffsetValue = …;
constexpr double kGyroscopeScalingValue = …;
constexpr double kMagnetometerFrequencyValue = …;
constexpr double kMagnetometerOffsetValue = …;
constexpr double kMagnetometerScalingValue = …;
void WriteValueToFile(const base::FilePath& path, double value) { … }
std::string ReadValueFromFile(const base::FilePath& path,
const std::string& file) { … }
double RoundAccelerometerValue(double value) { … }
double RoundGyroscopeValue(double value) { … }
double RoundMagnetometerValue(double value) { … }
}
class MockSensorDeviceManager : public SensorDeviceManager { … };
class LinuxMockPlatformSensorClient : public PlatformSensor::Client { … };
class PlatformSensorAndProviderLinuxTest : public ::testing::Test { … };
TEST_F(PlatformSensorAndProviderLinuxTest, SensorIsNotImplemented) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, SensorIsNotSupported) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, SensorIsSupported) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, StartFails) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, SensorStarted) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, SensorRemoved) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, SensorAddedAndRemoved) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, CheckAllSupportedSensors) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, GetMaximumSupportedFrequency) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
GetMaximumSupportedFrequencyDefault) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, CheckAmbientLightReadings) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckAccelerometerReadingConversion) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckLinearAccelerationSensorNotCreatedIfNoAccelerometer) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, CheckLinearAcceleration) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, CheckGyroscopeReadingConversion) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, CheckMagnetometerReadingConversion) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
SensorClientGetReadingChangedNotificationWhenSensorIsInContinuousMode) { … }
TEST_F(
PlatformSensorAndProviderLinuxTest,
CheckAbsoluteOrientationSensorNotCreatedIfNoAccelerometerAndNoMagnetometer) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckAbsoluteOrientationSensorNotCreatedIfNoAccelerometer) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckAbsoluteOrientationSensorNotCreatedIfNoMagnetometer) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckAbsoluteOrientationEulerAnglesSensor) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckAbsoluteOrientationQuaternionSensor) { … }
TEST_F(
PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationSensorNotCreatedIfNoAccelerometerAndNoGyroscope) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationSensorNotCreatedIfNoAccelerometer) { … }
TEST_F(
PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationEulerAnglesSensorUsingAccelerometerAndGyroscope) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationEulerAnglesSensorUsingAccelerometer) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationQuaternionSensorUsingAccelerometerAndGyroscope) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
CheckRelativeOrientationQuaternionSensorUsingAccelerometer) { … }
TEST_F(PlatformSensorAndProviderLinuxTest,
AccelerometerAndLinearAccelerationEnumeration) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, SensorCreationQueueManagement) { … }
TEST_F(PlatformSensorAndProviderLinuxTest, EarlyProviderDeletion) { … }
}