summaryrefslogtreecommitdiffstats
path: root/gin
diff options
context:
space:
mode:
authorssid <ssid@chromium.org>2015-05-07 05:11:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-07 12:11:45 +0000
commit93b23d9f113f01c0c19078bed47a47283dec0fbd (patch)
treeb30802822f629833fbf844d80ea962045dc22612 /gin
parent679ad34856a0c3307e832c8a4c599d0522e9a327 (diff)
downloadchromium_src-93b23d9f113f01c0c19078bed47a47283dec0fbd.zip
chromium_src-93b23d9f113f01c0c19078bed47a47283dec0fbd.tar.gz
chromium_src-93b23d9f113f01c0c19078bed47a47283dec0fbd.tar.bz2
Reland of "Adding task runner/ message loop to tests that use IsolateHolder."
Reason for reland: Fixed mac build. Original CL: crrev.com/1130433002 For adding v8 heap memory dump provider, the gin::IsolateHolder needs to have a task runner at initialization. The tests which don't initiallize task runner when initialization are changed in this CL to have either the message loop initializaed earlier or a dummy task runner. Refer crrev.com/1088683003 for the dump provider. BUG=476013 TBR=jochen@chromium.org,skyostil@chromium.org Review URL: https://codereview.chromium.org/1129873002 Cr-Commit-Position: refs/heads/master@{#328747}
Diffstat (limited to 'gin')
-rw-r--r--gin/converter_unittest.cc4
-rw-r--r--gin/modules/module_registry_unittest.cc2
-rw-r--r--gin/modules/timer_unittest.cc22
-rw-r--r--gin/shell_runner_unittest.cc2
-rw-r--r--gin/test/v8_test.h2
5 files changed, 17 insertions, 15 deletions
diff --git a/gin/converter_unittest.cc b/gin/converter_unittest.cc
index 940d4a2..8b9adf4 100644
--- a/gin/converter_unittest.cc
+++ b/gin/converter_unittest.cc
@@ -14,6 +14,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
+namespace gin {
+
using v8::Array;
using v8::Boolean;
using v8::HandleScope;
@@ -26,8 +28,6 @@ using v8::String;
using v8::Undefined;
using v8::Value;
-namespace gin {
-
typedef V8Test ConverterTest;
TEST_F(ConverterTest, Bool) {
diff --git a/gin/modules/module_registry_unittest.cc b/gin/modules/module_registry_unittest.cc
index 2d6e6daf..00c6a94 100644
--- a/gin/modules/module_registry_unittest.cc
+++ b/gin/modules/module_registry_unittest.cc
@@ -5,7 +5,6 @@
#include "gin/modules/module_registry.h"
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
#include "gin/modules/module_registry_observer.h"
#include "gin/modules/module_runner_delegate.h"
#include "gin/public/context_holder.h"
@@ -25,7 +24,6 @@ struct TestHelper {
scope(runner.get()) {
}
- base::MessageLoop message_loop;
ModuleRunnerDelegate delegate;
scoped_ptr<ShellRunner> runner;
Runner::Scope scope;
diff --git a/gin/modules/timer_unittest.cc b/gin/modules/timer_unittest.cc
index 705bdc5..612275e 100644
--- a/gin/modules/timer_unittest.cc
+++ b/gin/modules/timer_unittest.cc
@@ -64,9 +64,10 @@ struct TestHelper {
result->GetWrapper(isolate));
}
- void QuitSoon() {
- loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
- base::TimeDelta::FromMilliseconds(0));
+ void QuitSoon(base::MessageLoop* message_loop) {
+ message_loop->PostDelayedTask(FROM_HERE,
+ base::MessageLoop::QuitWhenIdleClosure(),
+ base::TimeDelta::FromMilliseconds(0));
}
ShellRunnerDelegate delegate;
@@ -74,7 +75,6 @@ struct TestHelper {
Runner::Scope scope;
Handle<TimerModule> timer_module;
Handle<Result> result;
- base::MessageLoop loop;
};
} // namespace
@@ -91,8 +91,8 @@ TEST_F(TimerUnittest, OneShot) {
helper.runner->Run(source, "script");
EXPECT_EQ(0, helper.result->count());
- helper.QuitSoon();
- helper.loop.Run();
+ helper.QuitSoon(&message_loop_);
+ message_loop_.Run();
EXPECT_EQ(1, helper.result->count());
}
@@ -107,8 +107,8 @@ TEST_F(TimerUnittest, OneShotCancel) {
helper.runner->Run(source, "script");
EXPECT_EQ(0, helper.result->count());
- helper.QuitSoon();
- helper.loop.Run();
+ helper.QuitSoon(&message_loop_);
+ message_loop_.Run();
EXPECT_EQ(0, helper.result->count());
}
@@ -128,7 +128,7 @@ TEST_F(TimerUnittest, Repeating) {
helper.runner->Run(source, "script");
EXPECT_EQ(0, helper.result->count());
- helper.loop.Run();
+ message_loop_.Run();
EXPECT_EQ(3, helper.result->count());
}
@@ -143,9 +143,9 @@ TEST_F(TimerUnittest, TimerCallbackToDestroyedRunner) {
EXPECT_EQ(0, helper.result->count());
// Destroy runner, which should destroy the timer object we created.
- helper.QuitSoon();
+ helper.QuitSoon(&message_loop_);
helper.runner.reset(NULL);
- helper.loop.Run();
+ message_loop_.Run();
// Timer should not have run because it was deleted.
EXPECT_EQ(0, helper.result->count());
diff --git a/gin/shell_runner_unittest.cc b/gin/shell_runner_unittest.cc
index 340b673..4e4b9c2f 100644
--- a/gin/shell_runner_unittest.cc
+++ b/gin/shell_runner_unittest.cc
@@ -5,6 +5,7 @@
#include "gin/shell_runner.h"
#include "base/compiler_specific.h"
+#include "base/message_loop/message_loop.h"
#include "gin/array_buffer.h"
#include "gin/converter.h"
#include "gin/public/isolate_holder.h"
@@ -23,6 +24,7 @@ using v8::String;
namespace gin {
TEST(RunnerTest, Run) {
+ base::MessageLoop message_loop;
std::string source = "this.result = 'PASS';\n";
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
diff --git a/gin/test/v8_test.h b/gin/test/v8_test.h
index e9209ce..592b889 100644
--- a/gin/test/v8_test.h
+++ b/gin/test/v8_test.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
@@ -26,6 +27,7 @@ class V8Test : public testing::Test {
void TearDown() override;
protected:
+ base::MessageLoop message_loop_;
scoped_ptr<IsolateHolder> instance_;
v8::Persistent<v8::Context> context_;