#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/device/generic_sensor/platform_sensor_fusion.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "services/device/generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.h"
#include "services/device/generic_sensor/fake_platform_sensor_and_provider.h"
#include "services/device/generic_sensor/generic_sensor_consts.h"
#include "services/device/generic_sensor/linear_acceleration_fusion_algorithm_using_accelerometer.h"
#include "services/device/generic_sensor/platform_sensor.h"
#include "services/device/generic_sensor/platform_sensor_fusion_algorithm.h"
#include "services/device/generic_sensor/platform_sensor_provider.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
TestFuture;
_;
Invoke;
NiceMock;
Return;
namespace device {
SensorType;
namespace {
void ExpectNoReadingChangedEvent(MockPlatformSensorClient* sensor_client,
mojom::SensorType sensor_type) { … }
void ExpectReadingChangedEvent(MockPlatformSensorClient* sensor_client,
mojom::SensorType sensor_type) { … }
void AddNewReadingAndExpectNoReadingChangedEvent(
MockPlatformSensorClient* sensor_client,
const SensorReading& new_reading,
mojom::SensorType sensor_type) { … }
void AddNewReadingAndExpectReadingChangedEvent(
MockPlatformSensorClient* sensor_client,
const SensorReading& new_reading,
mojom::SensorType sensor_type) { … }
void FusionAlgorithmCopyLowLevelValues(const SensorReading& low_level_reading,
SensorReading* fused_reading) { … }
void FusionAlgorithmSubtractEpsilonFromX(const SensorReading& low_level_reading,
SensorReading* fused_reading) { … }
class CustomizableFusionAlgorithm : public PlatformSensorFusionAlgorithm { … };
}
class PlatformSensorFusionTest : public testing::Test { … };
TEST_F(PlatformSensorFusionTest, SourceSensorAlreadyExists) { … }
TEST_F(PlatformSensorFusionTest, SourceSensorWorksSeparately) { … }
namespace {
void CheckConfigsCountForClient(const scoped_refptr<PlatformSensor>& sensor,
PlatformSensor::Client* client,
size_t expected_count) { … }
}
TEST_F(PlatformSensorFusionTest, SourceSensorDoesNotKeepOutdatedConfigs) { … }
TEST_F(PlatformSensorFusionTest, AllSourceSensorsStoppedOnSingleSourceFailure) { … }
TEST_F(PlatformSensorFusionTest, SourceSensorNeedsToBeCreated) { … }
TEST_F(PlatformSensorFusionTest, SourceSensorIsNotAvailable) { … }
TEST_F(PlatformSensorFusionTest, BothSourceSensorsAlreadyExist) { … }
TEST_F(PlatformSensorFusionTest, BothSourceSensorsNeedToBeCreated) { … }
TEST_F(PlatformSensorFusionTest, BothSourceSensorsAreNotAvailable) { … }
TEST_F(PlatformSensorFusionTest,
OneSourceSensorAlreadyExistsTheOtherSourceSensorNeedsToBeCreated) { … }
TEST_F(PlatformSensorFusionTest,
OneSourceSensorAlreadyExistsTheOtherSourceSensorIsNotAvailable) { … }
TEST_F(PlatformSensorFusionTest,
OneSourceSensorNeedsToBeCreatedTheOtherSourceSensorIsNotAvailable) { … }
TEST_F(PlatformSensorFusionTest,
FusionSensorMaximumSupportedFrequencyIsTheMaximumOfItsSourceSensors) { … }
TEST_F(PlatformSensorFusionTest, FusionIsSignificantlyDifferent) { … }
TEST_F(PlatformSensorFusionTest, OnSensorReadingChanged) { … }
TEST_F(PlatformSensorFusionTest, ProviderDestroyedWhileCreatingFusedSensor) { … }
}