chromium/services/device/generic_sensor/generic_sensor_service_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.

#include <algorithm>

#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/device_service.h"
#include "services/device/device_service_test_base.h"
#include "services/device/generic_sensor/fake_platform_sensor_and_provider.h"
#include "services/device/generic_sensor/platform_sensor.h"
#include "services/device/generic_sensor/platform_sensor_provider.h"
#include "services/device/generic_sensor/sensor_provider_impl.h"
#include "services/device/generic_sensor/virtual_platform_sensor.h"
#include "services/device/generic_sensor/virtual_platform_sensor_provider.h"
#include "services/device/public/cpp/device_features.h"
#include "services/device/public/cpp/generic_sensor/platform_sensor_configuration.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading_shared_buffer_reader.h"
#include "services/device/public/cpp/generic_sensor/sensor_traits.h"

_;
Invoke;

namespace device {

SensorType;

namespace {

// These values match what FakePlatformSensor reports and are somewhat
// arbitrary.
constexpr double kMinimumPlatformFrequency =;
constexpr double kMaximumPlatformFrequency =;

class TestSensorClient : public mojom::SensorClient {};

}  //  namespace

class GenericSensorServiceTest : public DeviceServiceTestBase {};

// Requests the SensorProvider to create a sensor.
TEST_F(GenericSensorServiceTest, GetSensorTest) {}

// Tests GetDefaultConfiguration.
TEST_F(GenericSensorServiceTest, GetDefaultConfigurationTest) {}

// Tests adding a valid configuration. Client should be notified by
// SensorClient::SensorReadingChanged().
TEST_F(GenericSensorServiceTest, ValidAddConfigurationTest) {}

// Tests adding an invalid configuation, the max allowed frequency is 50.0 in
// the mocked SensorImpl, while we add one with 60.0.
TEST_F(GenericSensorServiceTest, InvalidAddConfigurationTest) {}

// Tests adding more than one clients. Sensor should send notification to all
// its clients.
TEST_F(GenericSensorServiceTest, MultipleClientsTest) {}

// Tests adding more than one clients. If mojo connection is broken on one
// client, other clients should not be affected.
TEST_F(GenericSensorServiceTest, ClientMojoConnectionBrokenTest) {}

// Test add and remove configuration operations.
TEST_F(GenericSensorServiceTest, AddAndRemoveConfigurationTest) {}

// Test suspend. After suspending, the client won't be notified by
// SensorReadingChanged() after calling AddConfiguration.
// Call the AddConfiguration() twice, if the SensorReadingChanged() was
// called, it should happen before the callback triggerred by the second
// AddConfiguration(). In this way we make sure it won't be missed by the
// early quit of main thread (when there is an unexpected notification by
// SensorReadingChanged()).
TEST_F(GenericSensorServiceTest, SuspendTest) {}

// Tests that error notifications are delivered even if a sensor is suspended.
TEST_F(GenericSensorServiceTest, ErrorWhileSuspendedTest) {}

// Test suspend and resume. After resuming, client can add configuration and
// be notified by SensorReadingChanged() as usual.
TEST_F(GenericSensorServiceTest, SuspendThenResumeTest) {}

// Test suspend when there are more than one client. The suspended client won't
// receive SensorReadingChanged() notification.
TEST_F(GenericSensorServiceTest, MultipleClientsSuspendAndResumeTest) {}

TEST_F(GenericSensorServiceTest, MojoReceiverDisconnectionTest) {}

TEST_F(GenericSensorServiceTest,
       DifferentVirtualAndNonVirtualPlatformSensorsTest) {}

TEST_F(GenericSensorServiceTest, SameVirtualAndNonVirtualPlatformSensorsTest) {}

TEST_F(GenericSensorServiceTest,
       QuaternionSensorsOverrideEulerAngleSensorsTest) {}

TEST_F(GenericSensorServiceTest, VirtualEulerAngleSensorCreationTest) {}

TEST_F(GenericSensorServiceTest, VirtualPlatformOverridesNonVirtualTest) {}

TEST_F(GenericSensorServiceTest, DoubleVirtualPlatformSensorCreationTest) {}

TEST_F(GenericSensorServiceTest, GetNonOverriddenSensorTest) {}

TEST_F(GenericSensorServiceTest, UpdateNonOverriddenSensorTest) {}

}  //  namespace device