chromium/chrome/browser/sync/test/integration/single_client_history_sync_test.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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) {}

// Used to test if the History Service Observer gets called for both
// `OnURLVisited()` and `OnURLVisitedWithNavigationId()`.
class MockHistoryServiceObserver : public history::HistoryServiceObserver {};

class SingleClientHistorySyncTest : public SyncTest {};

IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
                       DoesNotUploadRetroactively) {}

IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest,
                       DoesNotUploadUnsyncableURLs) {}

// TODO(crbug.com/40871747): EnterSyncPausedStateForPrimaryAccount is currently
// not supported on Android. Enable this test once it is.
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(SingleClientHistorySyncTest, DoesNotUploadWhilePaused) {}
#endif  // !BUILDFLAG(IS_ANDROID)

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) {}

// Signing out or turning off Sync isn't possible in ChromeOS-Ash.
#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  // !BUILDFLAG(IS_CHROMEOS_ASH)

// On Android, switches::kSyncUserForTest isn't supported (the passed-in
// username gets ignored in SyncSigninDelegateAndroid::SigninFake()), so it's
// not currently possible to simulate a [email protected] account.
#if !BUILDFLAG(IS_ANDROID)

class SingleClientHistoryNonGmailSyncTest : public SingleClientHistorySyncTest {};

IN_PROC_BROWSER_TEST_F(SingleClientHistoryNonGmailSyncTest,
                       HistorySyncDisabledForManagedAccount) {}

IN_PROC_BROWSER_TEST_F(SingleClientHistoryNonGmailSyncTest,
                       HistorySyncEnabledForNonManagedAccount) {}

#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace