chromium/content/browser/service_worker/service_worker_hid_delegate_observer_unittest.cc

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

#include <cstddef>
#include <memory>
#include <vector>

#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/stringprintf.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/test_future.h"
#include "content/browser/hid/hid_service.h"
#include "content/browser/hid/hid_test_utils.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/service_worker_device_delegate_observer_unittest.h"
#include "content/browser/service_worker/service_worker_hid_delegate_observer.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/hid_delegate.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_utils.h"
#include "content/test/test_web_contents.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/device/public/cpp/test/fake_hid_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
#include "third_party/blink/public/mojom/hid/hid.mojom.h"
#include "url/origin.h"

namespace content {

namespace {

RunClosure;
TestFuture;
_;
Ref;
Return;

const char kTestUrl[] =;
const char kTestGuid[] =;

// This TestServiceWorkerObserver observes starting, started, and stopped of
// the worker with `version_id`.
class TestServiceWorkerObserver : public ServiceWorkerContextCoreObserver {};

class FakeHidConnectionClient : public device::mojom::HidConnectionClient {};

class MockHidManagerClient : public device::mojom::HidManagerClient {};

class ServiceWorkerHidDelegateObserverTest
    : public ServiceWorkerDeviceDelegateObserverTest {};

class ServiceWorkerHidDelegateObserverNoEventHandlersTest
    : public ServiceWorkerHidDelegateObserverTest {};

}  // namespace

TEST_F(ServiceWorkerHidDelegateObserverTest, DeviceAdded) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, DeviceRemoved) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, DeviceChanged) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, OnHidManagerConnectionError) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, OnPermissionRevoked) {}

TEST_F(ServiceWorkerHidDelegateObserverTest,
       RemovedFromHidDelegateObserverWhenNoRegistration) {}

TEST_F(ServiceWorkerHidDelegateObserverTest,
       HasLatestHidServiceAfterServiceWorkerStopThenStart) {}

TEST_F(ServiceWorkerHidDelegateObserverTest,
       RestartBrowserWithInstalledServiceWorker) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, NoPermissionNotStartWorker) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, NoReportsDeviceNotStartWorker) {}

TEST_F(ServiceWorkerHidDelegateObserverTest, ProcessPendingCallback) {}

TEST_F(ServiceWorkerHidDelegateObserverTest,
       ClearPendingCallbackWhenWorkerStopped) {}

TEST_F(ServiceWorkerHidDelegateObserverNoEventHandlersTest,
       DeviceAddedNotStartWorker) {}

TEST_F(ServiceWorkerHidDelegateObserverNoEventHandlersTest,
       RestartBrowserWithInstalledServiceWorker) {}

// Shutdown the service worker context and make sure that
// ServiceWorkerHidDelegateObserver removes itself from the hid delegate
// properly.
TEST_F(ServiceWorkerHidDelegateObserverTest, ShutdownServiceWorkerContext) {}

}  // namespace content