Commit 72ec6a9e authored by Olivier Li's avatar Olivier Li Committed by Commit Bot

Prepare SearchResultRankerTest for HistoryServiceUsesTaskScheduler activation.

The feature will soon be flipped to ENABLED_BY_DEFAULT. This will make
HistoryServiceBackend's task runner dispatch to the ThreadPool instead
of a dedicated base::Thread. The tests need to be prepared to stay
functional when that happens. This includes advancing mock time now that
the history backend tasks happen within the mocked time environment.

This is done as the last mile of the chrome-wide effort to coalesce as
much work as possible to the ThreadPool.

Bug: 661143
Change-Id: Id3cd0dbf77bc18bd5a407174af3b7d9b743a5db5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1979153
Auto-Submit: Oliver Li <olivierli@chromium.org>
Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Commit-Queue: Oliver Li <olivierli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728719}
parent 094b8b50
......@@ -198,11 +198,11 @@ class SearchResultRankerTest : public testing::Test {
// to.
std::list<TestSearchResult> test_search_results_;
ScopedTempDir temp_dir_;
content::BrowserTaskEnvironment task_environment_;
data_decoder::test::InProcessDataDecoder in_process_data_decoder_;
ScopedFeatureList scoped_feature_list_;
ScopedTempDir temp_dir_;
std::unique_ptr<history::HistoryService> history_service_;
std::unique_ptr<Profile> profile_;
......@@ -502,15 +502,24 @@ TEST_F(SearchResultRankerTest, QueryMixedModelDeletesURLCorrectly) {
HasIdScore("untrained", 0.5f)));
}
// Now delete |url_1| from the history service and ensure we save the model to
// disk.
// Delete the model file from disk and make sure it's gone.
base::DeleteFile(model_path, false);
EXPECT_FALSE(base::PathExists(model_path));
// Advance mock time by more than |min_seconds_between_saves| to make sure the
// file will be written again upon modification.
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(2 * 1000));
// Modify the history.
history_service()->AddPage(GURL(url_1), base::Time::Now(),
history::VisitSource::SOURCE_BROWSED);
history_service()->DeleteURLs({GURL(url_1)});
// Wait for history transactions to be complete.
history::BlockUntilHistoryProcessesPendingRequests(history_service());
Wait();
// Verify that the modifications triggered a write of the model.
EXPECT_TRUE(base::PathExists(model_path));
// Force cache expiry.
......
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