chromium/content/browser/service_worker/service_worker_usb_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/strings/stringprintf.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/test_future.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_registration.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/browser/service_worker/service_worker_usb_delegate_observer.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/browser/usb/usb_test_utils.h"
#include "content/browser/usb/web_usb_service_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/usb_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_usb_device_manager.h"
#include "services/device/public/mojom/usb_manager_client.mojom.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/usb/web_usb_service.mojom.h"
#include "url/origin.h"

namespace content {

namespace {

RunClosure;
TestFuture;
_;
Ref;
Return;

const char kTestUrl[] =;

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

class ServiceWorkerUsbDelegateObserverTest
    : public content::ServiceWorkerDeviceDelegateObserverTest {};

class ServiceWorkerUsbDelegateObserverNoEventHandlersTest
    : public ServiceWorkerUsbDelegateObserverTest {};

}  // namespace

TEST_F(ServiceWorkerUsbDelegateObserverTest, OnDeviceAdded) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest, OnDeviceRemoved) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest, OnDeviceManagerConnectionError) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest, OnPermissionRevoked) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest,
       RemovedFromUsbDelegateObserverWhenNoRegistration) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest,
       HasLatestUsbServiceAfterServiceWorkerStopThenStart) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest,
       RestartBrowserWithInstalledServiceWorker) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest, NoPermissionNotStartWorker) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest, ProcessPendingCallback) {}

TEST_F(ServiceWorkerUsbDelegateObserverTest,
       ClearPendingCallbackWhenWorkerStopped) {}

TEST_F(ServiceWorkerUsbDelegateObserverNoEventHandlersTest,
       DeviceAddedNotStartWorker) {}

TEST_F(ServiceWorkerUsbDelegateObserverNoEventHandlersTest,
       RestartBrowserWithInstalledServiceWorker) {}

// Shutdown the service worker context and make sure that
// ServiceWorkerUsbDelegateObserver removes itself from the usb delegate
// properly.
TEST_F(ServiceWorkerUsbDelegateObserverTest, ShutdownServiceWorkerContext) {}

}  // namespace content