chromium/chrome/browser/sync/test/integration/sync_test.h

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

#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_TEST_H_
#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_TEST_H_

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

#include "base/callback_list.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chrome/browser/sync/test/integration/invalidations/fake_server_sync_invalidation_sender.h"
#include "chrome/common/buildflags.h"
#include "chrome/test/base/platform_browser_test.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/user_selectable_type.h"
#include "components/sync/test/fake_server.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
#include "services/network/test/test_url_loader_factory.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/app_list/app_list_syncable_service.h"
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

#if BUILDFLAG(IS_ANDROID)
#include "components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.h"
#else
#include "chrome/browser/extensions/install_verifier.h"
#endif

// The E2E tests are designed to run against real backend servers. To identify
// those tests we use *E2ETest* test name filter and run disabled tests.
//
// The following macros define how a test is run:
// - E2E_ONLY: Marks a test to run only as an E2E test against backend servers.
//             These tests DO NOT run on regular Chromium waterfalls.
// - E2E_ENABLED: Marks a test to run as an E2E test in addition to Chromium
//                waterfalls.
//
// To disable a test from running on Chromium waterfalls, you would still use
// the default DISABLED_test_name macro. To disable it from running as an E2E
// test outside Chromium waterfalls you would need to remove the E2E* macro.
#define MACRO_CONCAT(prefix, test_name)
#define E2E_ONLY(test_name)
#define E2E_ENABLED(test_name)

class FakeSyncGCMDriver;
class KeyedService;
class SyncServiceImplHarness;

namespace arc {
class SyncArcPackageHelper;
}  // namespace arc

namespace base {
class CommandLine;
class ScopedTempDir;
}  // namespace base

namespace fake_server {
class FakeServer;
}  // namespace fake_server

namespace syncer {
class SyncServiceImpl;
}  // namespace syncer

namespace switches {

inline constexpr char kPasswordFileForTest[] =;
inline constexpr char kSyncUserForTest[] =;
inline constexpr char kSyncPasswordForTest[] =;

}  // namespace switches

// This is the base class for integration tests for all sync data types. Derived
// classes must be defined for each sync data type. Individual tests are defined
// using the IN_PROC_BROWSER_TEST_F macro.
//
// The list below shows some command line switches that can customize test
// behavior. It may become non-exaustive over time.
// syncer::kSyncServiceURL - By default, tests use a fake_server::FakeServer
//    to emulate the sync server. This switch causes them to run against an
//    external server instead, pointed by the provided URL. This translates into
//    the ServerType of the test being EXTERNAL_LIVE_SERVER.
// switches::kSyncUserForTest - Overrides the username of the syncing account.
//    Mostly useful for EXTERNAL_LIVE_SERVER tests to use an allowlisted value.
// switches::kSyncPasswordForTest - Same as above, but for the password.
// switches::kPasswordFileForTests - Causes the username and password of the
//    syncing account to be read from the passed file. The username must be on
//    the first line and the password on the second. The individual switches for
//    username and password are ignored if this is set.
// Other switches may modify the behavior of helper classes frequently used in
// sync integration tests, see StatusChangeChecker for example.
class SyncTest : public PlatformBrowserTest, public ProfileObserver {};

syncer::DataTypeSet AllowedTypesInStandaloneTransportMode();

#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_TEST_H_