Index: components/sync/driver/glue/ui_model_worker_unittest.cc |
diff --git a/components/sync/driver/glue/ui_model_worker_unittest.cc b/components/sync/driver/glue/ui_model_worker_unittest.cc |
index d091f317a5c60f2896c0a05ec84abbea9095a730..5af7a1ca2be2a8ddd0123f2fbfb94013891b9dcb 100644 |
--- a/components/sync/driver/glue/ui_model_worker_unittest.cc |
+++ b/components/sync/driver/glue/ui_model_worker_unittest.cc |
@@ -39,11 +39,23 @@ class SyncUIModelWorkerTest : public testing::Test { |
worker_ = new UIModelWorker(base::ThreadTaskRunnerHandle::Get()); |
} |
- void PostWorkToSyncThread(WorkCallback work) { |
+ void PostWorkToSyncThread(base::Closure work) { |
sync_thread_.task_runner()->PostTask( |
FROM_HERE, |
base::Bind(base::IgnoreResult(&UIModelWorker::DoWorkAndWaitUntilDone), |
- worker_, work)); |
+ worker_, ClosureToWorkCallback(work))); |
+ } |
+ |
+ // Work function for ShutdownNoDeadlock below. |
+ void DeadlockTest(base::Closure quit_closure) { |
+ // Unblock the sync thread. |
+ worker_->RequestStop(); |
+ |
+ // Join the sync thread. |
+ sync_thread_.Stop(); |
+ |
+ // Let the test complete. |
+ quit_closure.Run(); |
} |
private: |
@@ -54,10 +66,18 @@ class SyncUIModelWorkerTest : public testing::Test { |
TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { |
base::RunLoop run_loop; |
- PostWorkToSyncThread(ClosureToWorkCallback(run_loop.QuitClosure())); |
+ PostWorkToSyncThread(run_loop.QuitClosure()); |
// This won't quit until the QuitClosure is run. |
run_loop.Run(); |
} |
+TEST_F(SyncUIModelWorkerTest, ShutdownNoDeadlock) { |
+ base::RunLoop run_loop; |
+ PostWorkToSyncThread(base::Bind(&SyncUIModelWorkerTest::DeadlockTest, |
+ base::Unretained(this), |
+ run_loop.QuitClosure())); |
+ run_loop.Run(); |
+} |
+ |
} // namespace |
} // namespace syncer |