Commit 218f0e42 authored by Wez's avatar Wez Committed by Commit Bot

Provide webkit_unit_tests environment via a TestSuite specialization.

Update the blink/renderer/controller/tests/run_all_tests.cc e.g. used by
webkit_unit_tests, to provide the expected test environment by deriving
from base::TestSuite and overriding Initialize() and Shutdown().

Bug: 918724
Change-Id: I711e29f70517ec793b08441b05fa82e33e461613
Reviewed-on: https://chromium-review.googlesource.com/c/1395194Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619857}
parent 4861a638
...@@ -41,33 +41,43 @@ ...@@ -41,33 +41,43 @@
namespace { namespace {
int runHelper(base::TestSuite* testSuite) { class BlinkUnitTestSuite : public base::TestSuite {
content::SetUpBlinkTestEnvironment(); public:
blink::SchemeRegistry::Initialize(); BlinkUnitTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
int result = testSuite->Run(); private:
void Initialize() override {
base::TestSuite::Initialize();
// Tickle EndOfTaskRunner which among other things will flush the queue content::SetUpBlinkTestEnvironment();
// of error messages via V8Initializer::reportRejectedPromisesOnMainThread. blink::SchemeRegistry::Initialize();
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::DoNothing()); }
base::RunLoop().RunUntilIdle(); void Shutdown() override {
// Tickle EndOfTaskRunner which among other things will flush the queue
// of error messages via V8Initializer::reportRejectedPromisesOnMainThread.
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::DoNothing());
base::RunLoop().RunUntilIdle();
// Collect garbage (including threadspecific persistent handles) in order // Collect garbage (including threadspecific persistent handles) in order
// to release mock objects referred from v8 or Oilpan heap. Otherwise false // to release mock objects referred from v8 or Oilpan heap. Otherwise false
// mock leaks will be reported. // mock leaks will be reported.
blink::V8GCController::CollectAllGarbageForTesting( blink::V8GCController::CollectAllGarbageForTesting(
v8::Isolate::GetCurrent(), v8::Isolate::GetCurrent(),
v8::EmbedderHeapTracer::EmbedderStackState::kEmpty); v8::EmbedderHeapTracer::EmbedderStackState::kEmpty);
content::TearDownBlinkTestEnvironment(); content::TearDownBlinkTestEnvironment();
return result; base::TestSuite::Shutdown();
} }
DISALLOW_COPY_AND_ASSIGN(BlinkUnitTestSuite);
};
} // namespace } // namespace
int main(int argc, char** argv) { int main(int argc, char** argv) {
base::TestSuite testSuite(argc, argv); BlinkUnitTestSuite test_suite(argc, argv);
return base::LaunchUnitTests( return base::LaunchUnitTests(
argc, argv, base::Bind(&runHelper, base::Unretained(&testSuite))); argc, argv,
base::BindOnce(&BlinkUnitTestSuite::Run, base::Unretained(&test_suite)));
} }
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