Commit 1667cd2f authored by Sven Zheng's avatar Sven Zheng Committed by Commit Bot

Get the first sync test work on Android

This cl get SingleClientTypedUrlsSyncTest works on Android. Clank
doesn't support multiple profiles, and all sync tests need multiple
profiles. For single client test on desktop, it need at least 2 profiles:
1 The default browser and profile, started by browser test;
2 The browser and profile under test, created by AddBrowser();
3 If verifier is enabled, create another verifier profile.
For Android, we can't do that. This cl does:
* Only support single client test on Android.
* For 1 and 2, we only use the default browser and profile as SUT.
* For 3, we don't support it for Android.

android_sync_integration_tests.
$ autoninja -C out/Clank android_sync_integration_tests
$ out/Clank/android_sync_integration_tests

TEST: Locally tested on a Next 5X device for target
BUG: 1117345
Change-Id: I0167164334fc63be5cc278c145daf130ba16912e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387404Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Sven Zheng <svenzheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803930}
parent acbc2641
...@@ -334,6 +334,9 @@ void SyncTest::BeforeSetupClient(int index, ...@@ -334,6 +334,9 @@ void SyncTest::BeforeSetupClient(int index,
bool SyncTest::CreateProfile(int index) { bool SyncTest::CreateProfile(int index) {
base::FilePath profile_path; base::FilePath profile_path;
// For Android, we don't create profile because Clank doesn't support
// multiple profiles.
#if !defined(OS_ANDROID)
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
if (UsingExternalServers() && (num_clients_ > 1 || use_new_user_data_dir_)) { if (UsingExternalServers() && (num_clients_ > 1 || use_new_user_data_dir_)) {
scoped_temp_dirs_.push_back(std::make_unique<base::ScopedTempDir>()); scoped_temp_dirs_.push_back(std::make_unique<base::ScopedTempDir>());
...@@ -363,6 +366,7 @@ bool SyncTest::CreateProfile(int index) { ...@@ -363,6 +366,7 @@ bool SyncTest::CreateProfile(int index) {
profile_path = user_data_dir.AppendASCII( profile_path = user_data_dir.AppendASCII(
base::StringPrintf("SyncIntegrationTestClient%d", index)); base::StringPrintf("SyncIntegrationTestClient%d", index));
} }
#endif
BeforeSetupClient(index, profile_path); BeforeSetupClient(index, profile_path);
...@@ -371,6 +375,12 @@ bool SyncTest::CreateProfile(int index) { ...@@ -371,6 +375,12 @@ bool SyncTest::CreateProfile(int index) {
// GAIA server. This requires creating profiles with no test hooks. // GAIA server. This requires creating profiles with no test hooks.
InitializeProfile(index, MakeProfileForUISignin(profile_path)); InitializeProfile(index, MakeProfileForUISignin(profile_path));
} else { } else {
// Use default profile for Android.
#if defined(OS_ANDROID)
DCHECK(index == 0);
Profile* profile = ProfileManager::GetLastUsedProfile();
InitializeProfile(index, profile);
#else
// Without need of real GAIA authentication, we create new test profiles. // Without need of real GAIA authentication, we create new test profiles.
// For test profiles, a custom delegate needs to be used to do the // For test profiles, a custom delegate needs to be used to do the
// initialization work before the profile is registered. // initialization work before the profile is registered.
...@@ -378,6 +388,8 @@ bool SyncTest::CreateProfile(int index) { ...@@ -378,6 +388,8 @@ bool SyncTest::CreateProfile(int index) {
std::make_unique<SyncProfileDelegate>(base::Bind( std::make_unique<SyncProfileDelegate>(base::Bind(
&SyncTest::InitializeProfile, base::Unretained(this), index)); &SyncTest::InitializeProfile, base::Unretained(this), index));
Profile* profile = MakeTestProfile(profile_path, index); Profile* profile = MakeTestProfile(profile_path, index);
#endif
SetupMockGaiaResponsesForProfile(profile); SetupMockGaiaResponsesForProfile(profile);
} }
...@@ -565,6 +577,12 @@ bool SyncTest::SetupClients() { ...@@ -565,6 +577,12 @@ bool SyncTest::SetupClients() {
if (UsingExternalServers()) if (UsingExternalServers())
DisableVerifier(); DisableVerifier();
// Verifier needs to create a test profile. But Clank doesn't support multiple
// profiles.
#if defined(OS_ANDROID)
DisableVerifier();
#endif
// Create the verifier profile. // Create the verifier profile.
if (use_verifier_) { if (use_verifier_) {
base::FilePath user_data_dir; base::FilePath user_data_dir;
...@@ -817,6 +835,13 @@ void SyncTest::ClearProfiles() { ...@@ -817,6 +835,13 @@ void SyncTest::ClearProfiles() {
} }
bool SyncTest::SetupSync() { bool SyncTest::SetupSync() {
#if defined(OS_ANDROID)
// For Android, currently the framework only supports one client.
// The client uses the default profile.
DCHECK(num_clients_ == 1) << "For Android, currently it only supports "
<< "one client.";
#endif
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
SetupSyncInternal(/*setup_mode=*/WAIT_FOR_SYNC_SETUP_TO_COMPLETE); SetupSyncInternal(/*setup_mode=*/WAIT_FOR_SYNC_SETUP_TO_COMPLETE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment