Commit 3df607a9 authored by Wez's avatar Wez Committed by Commit Bot

Migrate some tests off of RunLoop::QuitCurrent*Deprecated().

This is a partial reland of b035cfda,
which was reviewed on https://chromium-review.googlesource.com/1082980

TBR: gab, thakis
Bug: 844016
Change-Id: I56847225b6eec13f182d03de5cf831b7c5362ad7
Reviewed-on: https://chromium-review.googlesource.com/1123888Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572109}
parent 2b06c3c6
...@@ -188,12 +188,16 @@ class FilePathWatcherTest : public testing::Test { ...@@ -188,12 +188,16 @@ class FilePathWatcherTest : public testing::Test {
bool recursive_watch) WARN_UNUSED_RESULT; bool recursive_watch) WARN_UNUSED_RESULT;
bool WaitForEvents() WARN_UNUSED_RESULT { bool WaitForEvents() WARN_UNUSED_RESULT {
return WaitForEventsWithTimeout(TestTimeouts::action_timeout());
}
bool WaitForEventsWithTimeout(TimeDelta timeout) WARN_UNUSED_RESULT {
RunLoop run_loop; RunLoop run_loop;
collector_->Reset(run_loop.QuitClosure()); collector_->Reset(run_loop.QuitClosure());
// Make sure we timeout if we don't get notified. // Make sure we timeout if we don't get notified.
ThreadTaskRunnerHandle::Get()->PostDelayedTask( ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), TestTimeouts::action_timeout()); FROM_HERE, run_loop.QuitClosure(), timeout);
run_loop.Run(); run_loop.Run();
return collector_->Success(); return collector_->Success();
} }
...@@ -853,10 +857,7 @@ TEST_F(FilePathWatcherTest, DirAttributesChanged) { ...@@ -853,10 +857,7 @@ TEST_F(FilePathWatcherTest, DirAttributesChanged) {
// We should not get notified in this case as it hasn't affected our ability // We should not get notified in this case as it hasn't affected our ability
// to access the file. // to access the file.
ASSERT_TRUE(ChangeFilePermissions(test_dir1, Read, false)); ASSERT_TRUE(ChangeFilePermissions(test_dir1, Read, false));
loop_.task_runner()->PostDelayedTask( ASSERT_FALSE(WaitForEventsWithTimeout(TestTimeouts::tiny_timeout()));
FROM_HERE, RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TestTimeouts::tiny_timeout());
ASSERT_FALSE(WaitForEvents());
ASSERT_TRUE(ChangeFilePermissions(test_dir1, Read, true)); ASSERT_TRUE(ChangeFilePermissions(test_dir1, Read, true));
// We should get notified in this case because filepathwatcher can no // We should get notified in this case because filepathwatcher can no
......
...@@ -435,14 +435,21 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) { ...@@ -435,14 +435,21 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) {
chrome::GetTabAlertStateForContents(contents); chrome::GetTabAlertStateForContents(contents);
if (alert_state != last_alert_state_) { if (alert_state != last_alert_state_) {
last_alert_state_ = alert_state; last_alert_state_ = alert_state;
base::ThreadTaskRunnerHandle::Get()->PostTask( if (on_tab_changed_)
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated()); std::move(on_tab_changed_).Run();
} }
} }
void WaitForTabChange() {
base::RunLoop run_loop;
on_tab_changed_ = run_loop.QuitClosure();
run_loop.Run();
}
private: private:
Browser* const browser_; Browser* const browser_;
TabAlertState last_alert_state_; TabAlertState last_alert_state_;
base::OnceClosure on_tab_changed_;
}; };
IndicatorChangeObserver observer(browser()); IndicatorChangeObserver observer(browser());
...@@ -462,7 +469,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) { ...@@ -462,7 +469,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) {
EXPECT_EQ(TabAlertState::TAB_CAPTURING, observer.last_alert_state()); EXPECT_EQ(TabAlertState::TAB_CAPTURING, observer.last_alert_state());
return; return;
} }
content::RunMessageLoop(); observer.WaitForTabChange();
} }
} }
......
...@@ -137,7 +137,6 @@ class SyncableFileOperationRunnerTest : public testing::Test { ...@@ -137,7 +137,6 @@ class SyncableFileOperationRunnerTest : public testing::Test {
SCOPED_TRACE(testing::Message() << location.ToString()); SCOPED_TRACE(testing::Message() << location.ToString());
EXPECT_EQ(expect, status); EXPECT_EQ(expect, status);
++callback_count_; ++callback_count_;
base::RunLoop::QuitCurrentWhenIdleDeprecated();
} }
bool CreateTempFile(base::FilePath* path) { bool CreateTempFile(base::FilePath* path) {
...@@ -409,7 +408,7 @@ TEST_F(SyncableFileOperationRunnerTest, Cancel) { ...@@ -409,7 +408,7 @@ TEST_F(SyncableFileOperationRunnerTest, Cancel) {
URL(kFile), 10, ExpectStatus(FROM_HERE, File::FILE_OK)); URL(kFile), 10, ExpectStatus(FROM_HERE, File::FILE_OK));
file_system_.operation_runner()->Cancel( file_system_.operation_runner()->Cancel(
id, ExpectStatus(FROM_HERE, File::FILE_ERROR_INVALID_OPERATION)); id, ExpectStatus(FROM_HERE, File::FILE_ERROR_INVALID_OPERATION));
base::RunLoop().Run(); content::RunAllTasksUntilIdle();
EXPECT_EQ(2, callback_count_); EXPECT_EQ(2, callback_count_);
} }
......
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