base: Remove MessageLoop usage from ObserverListThreadSafeTest
Replace explicit thread usage in ObserverListThreadSafeTest with a
number of tasks that run on dedicated worker pool threads.
We also replace an instance of MessageLoop in WeakNsObjectTest with a
scoped task environment.
Bug: 891670
Change-Id: I3b65f9b3ed54a42f40f38e98ef9b890d21003368
Reviewed-on: https://chromium-review.googlesource.com/c/1350914
Commit-Queue: Sami Kyöstilä <[email protected]>
Reviewed-by: François Doray <[email protected]>
Cr-Commit-Position: refs/heads/master@{#612141}
diff --git a/base/ios/weak_nsobject_unittest.mm b/base/ios/weak_nsobject_unittest.mm
index ba85217..c138570 100644
--- a/base/ios/weak_nsobject_unittest.mm
+++ b/base/ios/weak_nsobject_unittest.mm
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/bind.h"
#include "base/ios/weak_nsobject.h"
+#include "base/bind.h"
#include "base/mac/scoped_nsobject.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/test/scoped_task_environment.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -119,14 +120,14 @@
// Tests that the weak object can be copied on a different thread.
TEST(WeakNSObjectTest, WeakNSObjectCopyOnOtherThread) {
- MessageLoop loop;
+ test::ScopedTaskEnvironment scoped_task_environment;
Thread other_thread("WeakNSObjectCopyOnOtherThread");
other_thread.Start();
scoped_nsobject<NSMutableData> data([[NSMutableData alloc] init]);
WeakNSObject<NSMutableData> weak(data);
- scoped_refptr<SingleThreadTaskRunner> runner = loop.task_runner();
+ scoped_refptr<SingleThreadTaskRunner> runner = ThreadTaskRunnerHandle::Get();
other_thread.task_runner()->PostTask(
FROM_HERE, Bind(&CopyWeakNSObjectAndPost, weak, runner));
other_thread.Stop();