Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3086)

Unified Diff: content/test/blink_test_environment.cc

Issue 2852373004: Use ScopedTaskEnvironment instead of MessageLoop in tests that use v8. (Closed)
Patch Set: Reset-RenderViewTest Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/v8_unit_test.cc ('k') | content/test/ppapi_unittest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/blink_test_environment.cc
diff --git a/content/test/blink_test_environment.cc b/content/test/blink_test_environment.cc
index 2b9a55c35ab30766e0069268225d88e961c189ea..95305214fa5f81dc99171e82176ce47740eb16dd 100644
--- a/content/test/blink_test_environment.cc
+++ b/content/test/blink_test_environment.cc
@@ -7,9 +7,9 @@
#include <string>
#include "base/command_line.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_tokenizer.h"
+#include "base/test/scoped_task_environment.h"
#include "base/test/test_discardable_memory_allocator.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "build/build_config.h"
@@ -36,20 +36,13 @@ namespace {
class TestEnvironment {
public:
-#if defined(OS_ANDROID)
- // Android UI message loop goes through Java, so don't use it in tests.
- typedef base::MessageLoop MessageLoopType;
-#else
- typedef base::MessageLoopForUI MessageLoopType;
+ TestEnvironment()
+#if !defined(OS_ANDROID)
+ // On Android, Java pumps UI messages.
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI)
#endif
-
- TestEnvironment() {
- main_message_loop_.reset(new MessageLoopType);
-
- // TestBlinkWebUnitTestSupport must be instantiated after MessageLoopType.
- blink_test_support_.reset(new TestBlinkWebUnitTestSupport);
- content_initializer_.reset(new content::TestContentClientInitializer());
-
+ {
base::DiscardableMemoryAllocator::SetInstance(
&discardable_memory_allocator_);
}
@@ -57,14 +50,13 @@ class TestEnvironment {
~TestEnvironment() {
}
- TestBlinkWebUnitTestSupport* blink_platform_impl() const {
- return blink_test_support_.get();
- }
-
private:
- std::unique_ptr<MessageLoopType> main_message_loop_;
- std::unique_ptr<TestBlinkWebUnitTestSupport> blink_test_support_;
- std::unique_ptr<TestContentClientInitializer> content_initializer_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
+
+ // Must be instantiated after ScopedTaskEnvironment.
+ TestBlinkWebUnitTestSupport blink_test_support_;
+
+ TestContentClientInitializer content_initializer_;
base::TestDiscardableMemoryAllocator discardable_memory_allocator_;
};
« no previous file with comments | « chrome/test/base/v8_unit_test.cc ('k') | content/test/ppapi_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698