chromium/content/browser/generic_sensor/web_contents_sensor_provider_proxy_unittest.cc

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

#include <memory>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/test/bind.h"
#include "content/browser/generic_sensor/web_contents_sensor_provider_proxy.h"
#include "content/public/browser/permission_request_description.h"
#include "content/public/test/mock_permission_manager.h"
#include "content/public/test/test_browser_context.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/cpp/test/fake_sensor_and_provider.h"
#include "services/device/public/mojom/sensor.mojom.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/mojom/sensor/web_sensor_provider.mojom.h"

namespace content {

namespace {

// MockPermissionManager with a RequestPermission() implementation that always
// grants blink::PermissionType::SENSORS requests.
class TestPermissionManager : public MockPermissionManager {};

class WebContentsSensorProviderProxyTest
    : public RenderViewHostImplTestHarness {};

}  //  namespace

// Allows callers to run a custom callback before running
// FakeSensorProvider::GetSensor().
class InterceptingFakeSensorProvider : public device::FakeSensorProvider {};

// Test for https://crbug.com/1240814: destroying
// WebContentsSensorProviderProxyTest between calling
// device::mojom::SensorProvider::GetSensor() and it running the callback does
// not crash.
TEST_F(WebContentsSensorProviderProxyTest,
       DestructionOrderWithOngoingCallback) {}

}  //  namespace content