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

Unified Diff: base/threading/thread_unittest.cc

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « base/threading/thread_perftest.cc ('k') | base/threading/watchdog.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread_unittest.cc
diff --git a/base/threading/thread_unittest.cc b/base/threading/thread_unittest.cc
index f4d024f1a26a79fb53ac599ff5ba3c8202727da8..e86c7582e319969116be31da9437dca975c30dba 100644
--- a/base/threading/thread_unittest.cc
+++ b/base/threading/thread_unittest.cc
@@ -7,7 +7,8 @@
#include <vector>
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
+#include "base/location.h"
+#include "base/single_thread_task_runner.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -144,7 +145,7 @@ TEST_F(ThreadTest, StartWithOptions_StackSize) {
EXPECT_TRUE(a.IsRunning());
bool was_invoked = false;
- a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked));
+ a.task_runner()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked));
// wait for the task to run (we could use a kernel event here
// instead to avoid busy waiting, but this is sufficient for
@@ -165,14 +166,12 @@ TEST_F(ThreadTest, TwoTasks) {
// Test that all events are dispatched before the Thread object is
// destroyed. We do this by dispatching a sleep event before the
// event that will toggle our sentinel value.
- a.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(
- static_cast<void (*)(base::TimeDelta)>(
- &base::PlatformThread::Sleep),
- base::TimeDelta::FromMilliseconds(20)));
- a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue,
- &was_invoked));
+ a.task_runner()->PostTask(
+ FROM_HERE, base::Bind(static_cast<void (*)(base::TimeDelta)>(
+ &base::PlatformThread::Sleep),
+ base::TimeDelta::FromMilliseconds(20)));
+ a.task_runner()->PostTask(FROM_HERE,
+ base::Bind(&ToggleValue, &was_invoked));
}
EXPECT_TRUE(was_invoked);
}
@@ -195,11 +194,12 @@ TEST_F(ThreadTest, ThreadName) {
EXPECT_EQ("ThreadName", a.thread_name());
}
-// Make sure we can't use a thread between Start() and Init().
+// Make sure Init() is called after Start() and before
+// WaitUntilThreadInitialized() returns.
TEST_F(ThreadTest, SleepInsideInit) {
SleepInsideInitThread t;
EXPECT_FALSE(t.InitCalled());
- t.Start();
+ t.StartAndWaitForTesting();
EXPECT_TRUE(t.InitCalled());
}
@@ -221,7 +221,7 @@ TEST_F(ThreadTest, CleanUp) {
// Register an observer that writes into |captured_events| once the
// thread's message loop is destroyed.
- t.message_loop()->PostTask(
+ t.task_runner()->PostTask(
FROM_HERE, base::Bind(&RegisterDestructionObserver,
base::Unretained(&loop_destruction_observer)));
« no previous file with comments | « base/threading/thread_perftest.cc ('k') | base/threading/watchdog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698