#ifndef CONTENT_PUBLIC_TEST_EMBEDDED_WORKER_INSTANCE_TEST_HARNESS_H_
#define CONTENT_PUBLIC_TEST_EMBEDDED_WORKER_INSTANCE_TEST_HARNESS_H_
#include <stdint.h>
#include "browser_task_environment.h"
#include "content/public/browser/browser_context.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/hid/hid.mojom.h"
#include "third_party/blink/public/mojom/usb/web_usb_service.mojom.h"
namespace content {
class EmbeddedWorkerInstance;
class EmbeddedWorkerTestHelper;
class ServiceWorkerVersion;
class EmbeddedWorkerInstanceTestHarness : public testing::Test {
public:
template <typename... TaskEnvironmentTraits>
explicit EmbeddedWorkerInstanceTestHarness(TaskEnvironmentTraits&&... traits)
: EmbeddedWorkerInstanceTestHarness(
std::make_unique<BrowserTaskEnvironment>(
std::forward<TaskEnvironmentTraits>(traits)...)) {}
EmbeddedWorkerInstanceTestHarness(const EmbeddedWorkerInstanceTestHarness&) =
delete;
EmbeddedWorkerInstanceTestHarness& operator=(
const EmbeddedWorkerInstanceTestHarness&) = delete;
~EmbeddedWorkerInstanceTestHarness() override;
void SetUp() override;
void TearDown() override;
virtual std::unique_ptr<BrowserContext> CreateBrowserContext();
void CreateAndStartWorker(const GURL& origin, const GURL& worker_url);
void StopAndResetWorker();
#if !BUILDFLAG(IS_ANDROID)
void BindHidServiceToWorker(
const GURL& origin,
mojo::PendingReceiver<blink::mojom::HidService> receiver);
#endif
void BindUsbServiceToWorker(
const GURL& origin,
mojo::PendingReceiver<blink::mojom::WebUsbService> receiver);
protected:
explicit EmbeddedWorkerInstanceTestHarness(
std::unique_ptr<BrowserTaskEnvironment> task_environment);
std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
private:
std::unique_ptr<BrowserTaskEnvironment> task_environment_;
scoped_refptr<content::ServiceWorkerVersion> worker_version_;
};
}
#endif