Commit 22234d1d authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Followup WorkerModuleFetchCoordinater, move test code to shared file

Both the new and old code use an identical ClientImpl test class.
In jumbo builds those end up in the same translation unit and
it won't compile. This patch moves the class to a shared file
WorkerFetchTestHelper.h

Bug: 680046
Change-Id: Iabe58f2f2c93e4d77fb36c8c454952af994d302c
Reviewed-on: https://chromium-review.googlesource.com/968363
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544077}
parent 808c21c8
...@@ -2110,6 +2110,7 @@ jumbo_source_set("unit_tests") { ...@@ -2110,6 +2110,7 @@ jumbo_source_set("unit_tests") {
"workers/DedicatedWorkerTest.cpp", "workers/DedicatedWorkerTest.cpp",
"workers/MainThreadWorkletTest.cpp", "workers/MainThreadWorkletTest.cpp",
"workers/ThreadedWorkletTest.cpp", "workers/ThreadedWorkletTest.cpp",
"workers/WorkerFetchTestHelper.h",
"workers/WorkerModuleFetchCoordinatorTest.cpp", "workers/WorkerModuleFetchCoordinatorTest.cpp",
"workers/WorkerThreadTest.cpp", "workers/WorkerThreadTest.cpp",
"workers/WorkerThreadTestHelper.h", "workers/WorkerThreadTestHelper.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WorkerFetchTestHelper_h
#define WorkerFetchTestHelper_h
#include "core/loader/modulescript/ModuleScriptCreationParams.h"
#include "core/workers/WorkerOrWorkletModuleFetchCoordinator.h"
#include "platform/loader/fetch/ResourceFetcher.h"
#include "platform/loader/testing/FetchTestingPlatformSupport.h"
#include "platform/testing/TestingPlatformSupport.h"
#include "platform/testing/UnitTestHelpers.h"
#include "platform/wtf/Optional.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
class ClientImpl final : public GarbageCollectedFinalized<ClientImpl>,
public WorkerOrWorkletModuleFetchCoordinator::Client {
USING_GARBAGE_COLLECTED_MIXIN(ClientImpl);
public:
enum class Result { kInitial, kOK, kFailed };
void OnFetched(const ModuleScriptCreationParams& params) override {
ASSERT_EQ(Result::kInitial, result_);
result_ = Result::kOK;
params_.emplace(params);
}
void OnFailed() override {
ASSERT_EQ(Result::kInitial, result_);
result_ = Result::kFailed;
}
Result GetResult() const { return result_; }
WTF::Optional<ModuleScriptCreationParams> GetParams() const {
return params_;
}
private:
Result result_ = Result::kInitial;
WTF::Optional<ModuleScriptCreationParams> params_;
};
} // namespace blink
#endif // WorkerFetchTestHelper_h
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "core/loader/modulescript/ModuleScriptCreationParams.h" #include "core/loader/modulescript/ModuleScriptCreationParams.h"
#include "core/workers/WorkerFetchTestHelper.h"
#include "core/workers/WorkerModuleFetchCoordinator.h" #include "core/workers/WorkerModuleFetchCoordinator.h"
#include "platform/loader/fetch/ResourceFetcher.h" #include "platform/loader/fetch/ResourceFetcher.h"
#include "platform/loader/testing/FetchTestingPlatformSupport.h" #include "platform/loader/testing/FetchTestingPlatformSupport.h"
...@@ -18,38 +19,6 @@ ...@@ -18,38 +19,6 @@
namespace blink { namespace blink {
namespace {
class ClientImpl final : public GarbageCollectedFinalized<ClientImpl>,
public WorkerOrWorkletModuleFetchCoordinator::Client {
USING_GARBAGE_COLLECTED_MIXIN(ClientImpl);
public:
enum class Result { kInitial, kOK, kFailed };
void OnFetched(const ModuleScriptCreationParams& params) override {
ASSERT_EQ(Result::kInitial, result_);
result_ = Result::kOK;
params_.emplace(params);
}
void OnFailed() override {
ASSERT_EQ(Result::kInitial, result_);
result_ = Result::kFailed;
}
Result GetResult() const { return result_; }
WTF::Optional<ModuleScriptCreationParams> GetParams() const {
return params_;
}
private:
Result result_ = Result::kInitial;
WTF::Optional<ModuleScriptCreationParams> params_;
};
} // namespace
class WorkerModuleFetchCoordinatorTest : public ::testing::Test { class WorkerModuleFetchCoordinatorTest : public ::testing::Test {
public: public:
WorkerModuleFetchCoordinatorTest() = default; WorkerModuleFetchCoordinatorTest() = default;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "core/loader/modulescript/ModuleScriptCreationParams.h" #include "core/loader/modulescript/ModuleScriptCreationParams.h"
#include "core/workers/WorkerFetchTestHelper.h"
#include "core/workers/WorkletModuleResponsesMap.h" #include "core/workers/WorkletModuleResponsesMap.h"
#include "platform/loader/testing/FetchTestingPlatformSupport.h" #include "platform/loader/testing/FetchTestingPlatformSupport.h"
#include "platform/loader/testing/MockFetchContext.h" #include "platform/loader/testing/MockFetchContext.h"
...@@ -17,38 +18,6 @@ ...@@ -17,38 +18,6 @@
namespace blink { namespace blink {
namespace {
class ClientImpl final : public GarbageCollectedFinalized<ClientImpl>,
public WorkerOrWorkletModuleFetchCoordinator::Client {
USING_GARBAGE_COLLECTED_MIXIN(ClientImpl);
public:
enum class Result { kInitial, kOK, kFailed };
void OnFetched(const ModuleScriptCreationParams& params) override {
ASSERT_EQ(Result::kInitial, result_);
result_ = Result::kOK;
params_.emplace(params);
}
void OnFailed() override {
ASSERT_EQ(Result::kInitial, result_);
result_ = Result::kFailed;
}
Result GetResult() const { return result_; }
WTF::Optional<ModuleScriptCreationParams> GetParams() const {
return params_;
}
private:
Result result_ = Result::kInitial;
WTF::Optional<ModuleScriptCreationParams> params_;
};
} // namespace
class WorkletModuleResponsesMapTest : public ::testing::Test { class WorkletModuleResponsesMapTest : public ::testing::Test {
public: public:
WorkletModuleResponsesMapTest() = default; WorkletModuleResponsesMapTest() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment