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

// Copyright 2012 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/strings/stringprintf.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/apps_helper.h"
#include "chrome/browser/sync/test/integration/apps_sync_test_base.h"
#include "chrome/browser/sync/test/integration/extension_settings_helper.h"
#include "chrome/browser/sync/test/integration/extensions_helper.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/sync/base/features.h"
#include "components/sync/service/sync_service_impl.h"
#include "content/public/test/browser_test.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_features.h"
#endif

namespace {

InstallHostedAppForAllProfiles;
AllExtensionSettingsSameAsVerifier;
SetExtensionSettings;
SetExtensionSettingsForAllProfiles;
InstallExtensionForAllProfiles;
test;

// Generic mutations done after the initial setup of all tests. Note that
// unfortuately we can't test existing configurations of the sync server since
// the tests don't support that.
void MutateSomeSettings(
    int seed,  // used to modify the mutation values, not keys.
    const std::string& extension0,
    const std::string& extension1,
    const std::string& extension2) {}

class TwoClientAppSettingsSyncTest
    : public AppsSyncTestBase {};

// For three independent extensions:
//
// Set up each extension with the same (but not necessarily empty) settings for
// all profiles, start syncing, add some new settings, sync, mutate those
// settings, sync.
testing::AssertionResult StartWithSameSettingsTest(
    const std::string& extension0,
    const std::string& extension1,
    const std::string& extension2) {}

// For three independent extensions:
//
// Set up each extension with different settings for each profile, start
// syncing, add some settings, sync, mutate those settings, sync, have a no-op
// (non-)change to those settings, sync, mutate again, sync.
testing::AssertionResult StartWithDifferentSettingsTest(
    const std::string& extension0,
    const std::string& extension1,
    const std::string& extension2) {}

IN_PROC_BROWSER_TEST_F(TwoClientAppSettingsSyncTest,
                       AppsStartWithSameSettings) {}

IN_PROC_BROWSER_TEST_F(TwoClientAppSettingsSyncTest,
                       AppsStartWithDifferentSettings) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
// Tests for ChromeOS-Ash, which uses a different DataTypeController for
// syncer::APP_SETTINGS.
class TwoClientAppSettingsOsSyncTest : public SyncTest {
 public:
  TwoClientAppSettingsOsSyncTest() : SyncTest(TWO_CLIENT) {}
  ~TwoClientAppSettingsOsSyncTest() override = default;

  bool UseVerifier() override {
    // TODO(crbug.com/40724949): rewrite tests to not use verifier.
    return true;
  }
};

IN_PROC_BROWSER_TEST_F(TwoClientAppSettingsOsSyncTest,
                       AppsStartWithSameSettings) {
  ASSERT_TRUE(SetupClients());
  ASSERT_PRED3(StartWithSameSettingsTest, InstallHostedAppForAllProfiles(0),
               InstallHostedAppForAllProfiles(1),
               InstallHostedAppForAllProfiles(2));
}

IN_PROC_BROWSER_TEST_F(TwoClientAppSettingsOsSyncTest,
                       AppsStartWithDifferentSettings) {
  ASSERT_TRUE(SetupClients());
  ASSERT_PRED3(
      StartWithDifferentSettingsTest, InstallHostedAppForAllProfiles(0),
      InstallHostedAppForAllProfiles(1), InstallHostedAppForAllProfiles(2));
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

}  // namespace