chromium/chrome/browser/sync/test/integration/single_client_plus_address_setting_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 "base/test/scoped_feature_list.h"
#include "chrome/browser/plus_addresses/plus_address_setting_service_factory.h"
#include "chrome/browser/sync/test/integration/fake_server_match_status_checker.h"
#include "chrome/browser/sync/test/integration/single_client_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/settings/plus_address_setting_service.h"
#include "components/plus_addresses/settings/plus_address_setting_sync_test_util.h"
#include "components/plus_addresses/settings/plus_address_setting_sync_util.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/engine/loopback_server/persistent_unique_client_entity.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/plus_address_setting_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 {

constexpr char kIsEnabledSettingName[] =;

CreateSettingSpecifics;
HasBoolSetting;
PlusAddressSettingService;
Property;

// Waits until `PlusAddressSettingService::GetIsPlusAddressesEnabled()` has the
// `expected_state`.
// The condition is checked whenever sync's status changes - in particular, each
// time a sync cycle completes. This works, since setting changes are exposed
// through PlusAddressSettingService synchronously after the operation on the
// bridge completes.
class PlusAddressEnabledChecker : public SingleClientStatusChangeChecker {};

// Waits until the fake server's PlusAddressSettingSpecifics contain matching
// specifics.
class FakeServerSpecificsChecker
    : public fake_server::FakeServerMatchStatusChecker {};

// PLUS_ADDRESS_SETTING 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 SingleClientPlusAddressSettingSyncTest
    : public SyncTest,
      public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSettingSyncTest, InitialSync) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSettingSyncTest,
                       IncrementalUpdate_Add) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSettingSyncTest,
                       IncrementalUpdate_Update) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSettingSyncTest,
                       IncrementalUpdate_Remove) {}

IN_PROC_BROWSER_TEST_P(SingleClientPlusAddressSettingSyncTest,
                       WriteAcceptedNotice) {}

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

}  // namespace