#include "base/path_service.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/test/integration/history_helper.h"
#include "chrome/browser/sync/test/integration/sync_service_impl_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_service_observer.h"
#include "components/history/core/browser/history_types.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/protocol/history_specifics.pb.h"
#include "components/sync/service/sync_service_impl.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/filename_util.h"
#include "net/dns/mock_host_resolver.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#endif
CoreTransitionIs;
HasHttpResponseCode;
HasOpenerVisit;
HasReferrerURL;
HasReferringVisit;
HasVisitDuration;
IsChainEnd;
IsChainStart;
ReferrerURLIs;
StandardFieldsArePopulated;
UrlIs;
UrlsAre;
VisitRowDurationIs;
VisitRowIdIs;
_;
AllOf;
Not;
UnorderedElementsAre;
namespace {
const char kRedirectFromPath[] = …;
const char kRedirectToPath[] = …;
GURL GetFileUrl(const char* file) { … }
sync_pb::HistorySpecifics CreateSpecifics(
base::Time visit_time,
const std::string& originator_cache_guid,
const std::vector<GURL>& urls,
const std::vector<history::VisitID>& originator_visit_ids) { … }
sync_pb::HistorySpecifics CreateSpecifics(
base::Time visit_time,
const std::string& originator_cache_guid,
const GURL& url,
history::VisitID originator_visit_id = 0) { … }
std::unique_ptr<syncer::LoopbackServerEntity> CreateFakeServerEntity(
const sync_pb::HistorySpecifics& specifics) { … }
class MockHistoryServiceObserver : public history::HistoryServiceObserver { … };
class SingleClientHistorySyncTest : public SyncTest { … };
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DoesNotUploadRetroactively) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DoesNotUploadUnsyncableURLs) { … }
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, DoesNotUploadWhilePaused) { … }
#endif
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, UploadsAllFields) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
UploadsMarkVisitAsKnownToSync) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, UploadsServerRedirect) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, UploadsClientMetaRedirect) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, UploadsClientJSRedirect) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
UploadsReplaceStateNavigation) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, UploadsExternalReferrer) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, DownloadsAndMerges) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
ObserversCallBothOnURLVisitedForSyncedVisits) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DownloadsAndMarksRemoteVisitAsKnownToSync) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DownloadsServerRedirectChain) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DownloadsClientRedirectChain) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DownloadsAndRemapsReferrer) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, DownloadsExternalReferrer) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DoesNotDownloadUnwantedURLs) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
RecordsLatencyForIncrementalUpdates) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
ClearsForeignHistoryOnTurningSyncOff) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
ClearsForeignHistoryOnTurningSyncOffInTwoSteps) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
DoesNotDuplicateEntriesWhenTurningSyncOffAndOnAgain) { … }
#endif
#if !BUILDFLAG(IS_ANDROID)
class SingleClientHistoryNonGmailSyncTest : public SingleClientHistorySyncTest { … };
IN_PROC_BROWSER_TEST_F(SingleClientHistoryNonGmailSyncTest,
HistorySyncDisabledForManagedAccount) { … }
IN_PROC_BROWSER_TEST_F(SingleClientHistoryNonGmailSyncTest,
HistorySyncEnabledForNonManagedAccount) { … }
#endif
}