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

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

#include <memory>
#include <string>
#include <vector>

#include "base/command_line.h"
#include "base/containers/span.h"
#include "base/scoped_observation.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/plus_addresses/plus_address_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/test/integration/status_change_checker.h"
#include "chrome/browser/sync/test/integration/sync_service_impl_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/plus_addresses/features.h"
#include "components/plus_addresses/plus_address_service.h"
#include "components/plus_addresses/plus_address_test_utils.h"
#include "components/plus_addresses/plus_address_types.h"
#include "components/plus_addresses/webdata/plus_address_sync_util.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_manager.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/engine/loopback_server/persistent_tombstone_entity.h"
#include "components/sync/engine/loopback_server/persistent_unique_client_entity.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/test/fake_server.h"
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

EntityDataFromPlusProfile;
PlusAddressService;
PlusProfile;
CreatePlusProfile;

// Blocks until `service->GetPlusProfiles()` matches `matcher`.
// Since `PlusAddressService` lives on a different sequence than the bridge,
// waiting is necessary even after `SetupSync()`.
class PlusProfileChecker : public StatusChangeChecker,
                           public PlusAddressService::Observer {};

// PLUS_ADDRESS is supposed to behave the same in and outside of transport mode.
// These tests are parameterized by whether the test should run in transport
// mode (true) or not (false).
class SingleClientPlusAddressSyncTest
    : public SyncTest,
      public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSyncTest, InitialSync) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSyncTest, IncrementalUpdate_Add) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSyncTest,
                       IncrementalUpdate_Update) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSyncTest,
                       IncrementalUpdate_Remove) {}

// ChromeOS does not support signing out of the primary account.
#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSyncTest, Signout_DataCleared) {}
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

// Overwrites the Sync test account with a non-gmail account to treat it as a
// Dasher account.
// On Android, `switches::kSyncUserForTest` isn't supported, so it's currently
// not possible to simulate a non-gmail account.
#if !BUILDFLAG(IS_ANDROID)
class SingleClientPlusAddressManagedAccountTest
    : public SingleClientPlusAddressSyncTest {};

IN_PROC_BROWSER_TEST_F(SingleClientPlusAddressManagedAccountTest,
                       DisabledForManagedAccounts) {}
#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace