Commit b2598b46 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Narrow the scope of blocking observation in ThreadConditionTest to the single...

Narrow the scope of blocking observation in ThreadConditionTest to the single Wait call of interest.

Bug: 897550
Change-Id: Id34dc044bb6c5bd5e177d405015fdd909827ce18
Reviewed-on: https://chromium-review.googlesource.com/c/1298346
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602481}
parent ea82df7b
...@@ -28,25 +28,27 @@ class ThreadConditionTest : public testing::Test { ...@@ -28,25 +28,27 @@ class ThreadConditionTest : public testing::Test {
ThreadConditionTest() : condition_(mutex_) {} ThreadConditionTest() : condition_(mutex_) {}
void RunOtherThreadInfiniteWait() { void RunOtherThreadInfiniteWait() {
base::internal::SetBlockingObserverForCurrentThread(&observer_);
MutexLocker lock(mutex_); MutexLocker lock(mutex_);
ready_.Signal(); ready_.Signal();
base::internal::SetBlockingObserverForCurrentThread(&observer_);
EXPECT_CALL(observer_, BlockingStarted(base::BlockingType::MAY_BLOCK));
EXPECT_CALL(observer_, BlockingEnded());
condition_.Wait(); condition_.Wait();
testing::Mock::VerifyAndClear(&observer_);
} }
protected: protected:
// Used to make sure that the other thread gets to wait before the main thread
// signals it. Otherwise it may wait forever.
base::WaitableEvent ready_; base::WaitableEvent ready_;
testing::StrictMock<MockBlockingObserver> observer_; testing::StrictMock<MockBlockingObserver> observer_;
Mutex mutex_; Mutex mutex_;
ThreadCondition condition_; ThreadCondition condition_;
}; };
// TODO(https://crbug.com/897550): Test often flakes on its first run, only TEST_F(ThreadConditionTest, WaitReportsBlockingCall) {
// passing when retried by the TestLauncher.
TEST_F(ThreadConditionTest, DISABLED_WaitReportsBlockingCall) {
EXPECT_CALL(observer_, BlockingStarted(base::BlockingType::MAY_BLOCK));
EXPECT_CALL(observer_, BlockingEnded());
base::Thread other_thread("other thread"); base::Thread other_thread("other thread");
other_thread.StartAndWaitForTesting(); other_thread.StartAndWaitForTesting();
other_thread.task_runner()->PostTask( other_thread.task_runner()->PostTask(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment