From 8dda17e4af70393f93d8f29c1e574907ebac53b8 Mon Sep 17 00:00:00 2001 From: "qsr@chromium.org" Date: Fri, 21 Dec 2012 14:08:05 +0000 Subject: Fix flakyness in PrefMemberTest::MoveToThread In MoveToThread, a thread object is owned by a ref-counted object that is passed around thread. It means the thread object can be deleted on a thread that is not the one that created it, which will trigger a DCHECK. This CL ensures that the second thread is always stopped on the main thread. R=battre@chromium.org BUG=None Review URL: https://chromiumcodereview.appspot.com/11624023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174390 0039d316-1c4b-4281-b951-d872f2087c98 --- base/prefs/public/pref_member_unittest.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/prefs/public/pref_member_unittest.cc b/base/prefs/public/pref_member_unittest.cc index 4203db3a..eab5a4c 100644 --- a/base/prefs/public/pref_member_unittest.cc +++ b/base/prefs/public/pref_member_unittest.cc @@ -56,6 +56,12 @@ class GetPrefValueHelper event.Wait(); } + // The thread must be stopped on the main thread. GetPrefValueHelper being + // ref-counted, the destructor can be called from any thread. + void StopThread() { + pref_thread_.Stop(); + } + bool value() { return value_; } private: @@ -313,4 +319,6 @@ TEST(PrefMemberTest, MoveToThread) { helper->FetchValue(); EXPECT_TRUE(helper->value()); + + helper->StopThread(); } -- cgit v1.1