chromium/services/device/generic_sensor/platform_sensor_fusion_unittest.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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) {}

// Attempts to add a new reading to the sensor owned by |sensor_client|, and
// asserts that it does not lead to OnSensorReadingChanged() being called (i.e.
// PlatformSensor's significance check has failed).
void AddNewReadingAndExpectNoReadingChangedEvent(
    MockPlatformSensorClient* sensor_client,
    const SensorReading& new_reading,
    mojom::SensorType sensor_type) {}

// Add a new reading to the sensor owned by |sensor_client|, and expect reading
// change event.
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) {}

// A PlatformSensorFusionAlgorithm whose fusion algorithm can be customized
// at runtime via set_fusion_function().
class CustomizableFusionAlgorithm : public PlatformSensorFusionAlgorithm {};

}  // namespace

class PlatformSensorFusionTest : public testing::Test {};

// The following code tests creating a fusion sensor that needs one source
// sensor.

TEST_F(PlatformSensorFusionTest, SourceSensorAlreadyExists) {}

TEST_F(PlatformSensorFusionTest, SourceSensorWorksSeparately) {}

namespace {

void CheckConfigsCountForClient(const scoped_refptr<PlatformSensor>& sensor,
                                PlatformSensor::Client* client,
                                size_t expected_count) {}

}  // namespace

TEST_F(PlatformSensorFusionTest, SourceSensorDoesNotKeepOutdatedConfigs) {}

TEST_F(PlatformSensorFusionTest, AllSourceSensorsStoppedOnSingleSourceFailure) {}

TEST_F(PlatformSensorFusionTest, SourceSensorNeedsToBeCreated) {}

TEST_F(PlatformSensorFusionTest, SourceSensorIsNotAvailable) {}

// The following code tests creating a fusion sensor that needs two source
// sensors.

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) {}

}  //  namespace device