Commit ab8160eb authored by Tommy Li's avatar Tommy Li Committed by Chromium LUCI CQ

[search_engines] Update CreateTestTemplateURL to use base::Time

This CL changes the last_mod parameter to use base::Time and renames
it to be last_modified.

It also updates all the callsites, with no functional change, just a
cleanup.

Bug: 1022775
Change-Id: I8c82d11727c20bfddff42342500f905149a468a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575043
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833858}
parent 62ad5294
......@@ -11,7 +11,6 @@
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/search_engines/chrome_template_url_service_client.h"
#include "chrome/test/base/testing_profile.h"
......@@ -68,7 +67,7 @@ std::unique_ptr<TemplateURL> CreateTestTemplateURL(
const base::string16& keyword,
const std::string& url,
const std::string& guid,
time_t last_mod,
base::Time last_modified,
bool safe_for_autoreplace,
bool created_by_policy,
int prepopulate_id) {
......@@ -83,7 +82,7 @@ std::unique_ptr<TemplateURL> CreateTestTemplateURL(
data.favicon_url = GURL("http://favicon.url");
data.safe_for_autoreplace = safe_for_autoreplace;
data.date_created = base::Time::FromTimeT(100);
data.last_modified = base::Time::FromTimeT(last_mod);
data.last_modified = last_modified;
data.created_by_policy = created_by_policy;
data.prepopulate_id = prepopulate_id;
if (!guid.empty())
......
......@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_service_observer.h"
......@@ -32,12 +33,11 @@ void RemoveManagedDefaultSearchPreferences(TestingProfile* profile);
// Creates a TemplateURL with some test values. The caller owns the returned
// TemplateURL*.
// TODO(tommycli): Change last_mod to more verbose name and make it base::Time.
std::unique_ptr<TemplateURL> CreateTestTemplateURL(
const base::string16& keyword,
const std::string& url,
const std::string& guid = std::string(),
time_t last_mod = 100,
base::Time last_modified = base::Time::FromTimeT(100),
bool safe_for_autoreplace = false,
bool created_by_policy = false,
int prepopulate_id = 999999);
......
......@@ -82,13 +82,13 @@ IN_PROC_BROWSER_TEST_F(SingleClientSearchEnginesSyncTest,
// "guid2" is newer, so it should be treated as better.
fake_server_->InjectEntity(CreateFromTemplateURL(CreateTestTemplateURL(
/*keyword=*/base::ASCIIToUTF16("key1"), /*url=*/"http://key1.com",
/*guid=*/"guid1", /*last_mod=*/10)));
/*guid=*/"guid1", base::Time::FromTimeT(10))));
fake_server_->InjectEntity(CreateFromTemplateURL(CreateTestTemplateURL(
/*keyword=*/base::ASCIIToUTF16("key1"), /*url=*/"http://key1.com",
/*guid=*/"guid2", /*last_mod=*/5)));
/*guid=*/"guid2", base::Time::FromTimeT(5))));
fake_server_->InjectEntity(CreateFromTemplateURL(CreateTestTemplateURL(
/*keyword=*/base::ASCIIToUTF16("key1"), /*url=*/"http://key1.com",
/*guid=*/"guid3", /*last_mod=*/5)));
/*guid=*/"guid3", base::Time::FromTimeT(5))));
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
......
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