Skip to content

Commit

Permalink
[TangibleSync] Create tangible sync consent layout
Browse files Browse the repository at this point in the history
This cl creates the tangible sync layout and view. The view is guarded
by a feature flag.

Bug: 1332527
Change-Id: I23b9614834b79e2c9f1610b70d1fff2bf78f9e80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3790980
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1032482}
  • Loading branch information
Tanmoy Mollik authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent 646d3dc commit 62b296f
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 76 deletions.
1 change: 1 addition & 0 deletions chrome/android/java/res/drawable/devices_black_24dp.xml
Expand Up @@ -3,6 +3,7 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->

<!-- TODO(https://crbug.com/1350455): Check whether this can be replaced by devices_icon -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
Expand Down
Expand Up @@ -52,6 +52,11 @@ public void onAttach(Context context) {
accounts.isEmpty() ? null : accounts.get(0).name, isChild));
}

@Override
protected boolean showTangibleSyncConsentView() {
return false;
}

@Override
protected void onSyncRefused() {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.ALLOW_SYNC_OFF_FOR_CHILD_ACCOUNTS)
Expand Down
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.Nullable;

import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.sync.settings.ManageSyncSettings;
import org.chromium.chrome.browser.ui.signin.SyncConsentFragmentBase;
Expand Down Expand Up @@ -81,6 +82,11 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
recordSigninStartedHistogramAccountInfo();
}

@Override
protected boolean showTangibleSyncConsentView() {
return ChromeFeatureList.isEnabled(ChromeFeatureList.TANGIBLE_SYNC);
}

@Override
protected void onSyncRefused() {
getActivity().finish();
Expand Down
Expand Up @@ -165,65 +165,84 @@ public void tearDown() throws Exception {
@Test
@LargeTest
@Feature("RenderTest")
public void testSyncConsentFragmentNewAccount() throws IOException {
public void testSyncConsentFragmentDefaultAccount() throws IOException {
CoreAccountInfo accountInfo =
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoAddAccountFlow(
SyncConsentActivityLauncherImpl.get().launchActivityForPromoDefaultFlow(
mChromeActivityTestRule.getActivity(),
SigninAccessPoint.BOOKMARK_MANAGER);
SigninAccessPoint.BOOKMARK_MANAGER, accountInfo.getEmail());
});
mRenderTestRule.render(mSyncConsentActivity.findViewById(R.id.fragment_container),
"sync_consent_fragment_new_account");
"sync_consent_fragment_default_account");
}

@Test
@LargeTest
@Feature("RenderTest")
public void testSyncConsentFragmentNotDefaultAccountWithPrimaryAccount() throws IOException {
@EnableFeatures({ChromeFeatureList.TANGIBLE_SYNC})
public void testTangibleSyncConsentFragmentDefaultAccount() throws IOException {
CoreAccountInfo accountInfo =
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
mSigninTestRule.addAccount("test.second.account@gmail.com");
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow(
SyncConsentActivityLauncherImpl.get().launchActivityForPromoDefaultFlow(
mChromeActivityTestRule.getActivity(),
SigninAccessPoint.BOOKMARK_MANAGER, accountInfo.getEmail());
});
mRenderTestRule.render(mSyncConsentActivity.findViewById(R.id.fragment_container),
"sync_consent_fragment_choose_primary_account");
"tangible_sync_consent_fragment_default_account");
}

@Test
@LargeTest
@Feature("RenderTest")
public void testSyncConsentFragmentNotDefaultAccountWithSecondaryAccount() throws IOException {
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
String secondAccountName = "test.second.account@gmail.com";
mSigninTestRule.addAccount(secondAccountName);
public void testSyncConsentFragmentNewAccount() throws IOException {
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow(
SyncConsentActivityLauncherImpl.get().launchActivityForPromoAddAccountFlow(
mChromeActivityTestRule.getActivity(),
SigninAccessPoint.BOOKMARK_MANAGER, secondAccountName);
SigninAccessPoint.BOOKMARK_MANAGER);
});
mRenderTestRule.render(mSyncConsentActivity.findViewById(R.id.fragment_container),
"sync_consent_fragment_choose_secondary_account");
"sync_consent_fragment_new_account");
}

@Test
@LargeTest
@Feature("RenderTest")
public void testSyncConsentFragmentDefaultAccount() throws IOException {
public void testSyncConsentFragmentNotDefaultAccountWithPrimaryAccount() throws IOException {
CoreAccountInfo accountInfo =
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
mSigninTestRule.addAccount("test.second.account@gmail.com");
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoDefaultFlow(
SyncConsentActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow(
mChromeActivityTestRule.getActivity(),
SigninAccessPoint.BOOKMARK_MANAGER, accountInfo.getEmail());
});
mRenderTestRule.render(mSyncConsentActivity.findViewById(R.id.fragment_container),
"sync_consent_fragment_default_account");
"sync_consent_fragment_choose_primary_account");
}

@Test
@LargeTest
@Feature("RenderTest")
@EnableFeatures({ChromeFeatureList.TANGIBLE_SYNC})
public void testTangibleSyncConsentFragmentNotDefaultAccountWithSecondaryAccount()
throws IOException {
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
String secondAccountName = "test.second.account@gmail.com";
mSigninTestRule.addAccount(secondAccountName);
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow(
mChromeActivityTestRule.getActivity(),
SigninAccessPoint.BOOKMARK_MANAGER, secondAccountName);
});
mRenderTestRule.render(mSyncConsentActivity.findViewById(R.id.fragment_container),
"tangible_sync_consent_fragment_choose_secondary_account");
}

@Test
Expand Down Expand Up @@ -283,6 +302,26 @@ public void testFRESyncConsentFragmentWithAdultAccount() throws IOException {
"fre_sync_consent_fragment_with_adult_account");
}

@Test
@LargeTest
@Feature("RenderTest")
@EnableFeatures({ChromeFeatureList.TANGIBLE_SYNC})
public void testFRETangibleSyncConsentFragmentWithAdultAccount() throws IOException {
HistogramDelta startPageHistogram =
new HistogramDelta("Signin.SigninStartedAccessPoint", SigninAccessPoint.START_PAGE);
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
CustomSyncConsentFirstRunFragment fragment = new CustomSyncConsentFirstRunFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(SyncConsentFirstRunFragment.IS_CHILD_ACCOUNT, false);
when(mFirstRunPageDelegateMock.getProperties()).thenReturn(bundle);
fragment.setPageDelegate(mFirstRunPageDelegateMock);

launchActivityWithFragment(fragment);
Assert.assertEquals(1, startPageHistogram.getDelta());
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(android.R.id.content),
"fre_tangible_sync_consent_fragment_with_adult_account");
}

@Test
@LargeTest
@Feature("RenderTest")
Expand Down Expand Up @@ -437,7 +476,35 @@ public void testClickingSettingsDoesNotSetFirstSetupComplete() {
.getSigninManager(Profile.getLastUsedRegularProfile())
.getIdentityManager()
.hasPrimaryAccount(ConsentLevel.SYNC);
}, CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
});
TestThreadUtils.runOnUiThreadBlocking(() -> {
Assert.assertTrue(SyncService.get().isSyncRequested());
Assert.assertFalse(SyncService.get().isFirstSetupComplete());
});
// Close the SettingsActivity.
onView(withId(R.id.cancel_button)).perform(click());
}

@Test
@LargeTest
@EnableFeatures({ChromeFeatureList.TANGIBLE_SYNC})
public void testClickingSettingsDoesNotSetFirstSetupCompleteWithTangibleSync() {
CoreAccountInfo accountInfo =
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoDefaultFlow(
mChromeActivityTestRule.getActivity(), SigninAccessPoint.SETTINGS,
accountInfo.getEmail());
});
onView(withId(R.id.sync_consent_details_description)).perform(clickOnClickableSpan());
// Wait for sign in process to finish.
CriteriaHelper.pollUiThread(() -> {
return IdentityServicesProvider.get()
.getSigninManager(Profile.getLastUsedRegularProfile())
.getIdentityManager()
.hasPrimaryAccount(ConsentLevel.SYNC);
});
TestThreadUtils.runOnUiThreadBlocking(() -> {
Assert.assertTrue(SyncService.get().isSyncRequested());
Assert.assertFalse(SyncService.get().isFirstSetupComplete());
Expand All @@ -446,6 +513,25 @@ public void testClickingSettingsDoesNotSetFirstSetupComplete() {
onView(withId(R.id.cancel_button)).perform(click());
}

@Test
@LargeTest
@EnableFeatures({ChromeFeatureList.TANGIBLE_SYNC})
public void testTangibleSyncConsentFragmentWhenSelectedAccountIsRemoved() {
mSigninTestRule.addAccount("test.default.account@gmail.com");
CoreAccountInfo selectedAccountInfo =
mSigninTestRule.addAccount(AccountManagerTestRule.TEST_ACCOUNT_EMAIL);
mSyncConsentActivity = ActivityTestUtils.waitForActivity(
InstrumentationRegistry.getInstrumentation(), SyncConsentActivity.class, () -> {
SyncConsentActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow(
mChromeActivityTestRule.getActivity(), SigninAccessPoint.SETTINGS,
selectedAccountInfo.getEmail());
});

mSigninTestRule.removeAccount(selectedAccountInfo.getEmail());

ApplicationTestUtils.waitForActivityState(mSyncConsentActivity, Stage.DESTROYED);
}

@Test
@LargeTest
public void testFRESyncConsentFragmentWithoutSelectedAccount() {
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/android/signin/BUILD.gn
Expand Up @@ -57,6 +57,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/ui/signin/SigninView.java",
"java/src/org/chromium/chrome/browser/ui/signin/SyncConsentActivityLauncher.java",
"java/src/org/chromium/chrome/browser/ui/signin/SyncConsentFragmentBase.java",
"java/src/org/chromium/chrome/browser/ui/signin/SyncConsentView.java",
"java/src/org/chromium/chrome/browser/ui/signin/TangibleSyncCoordinator.java",
"java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetCoordinator.java",
"java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetMediator.java",
Expand Down Expand Up @@ -89,7 +90,9 @@ android_resources("java_resources") {
"java/res/drawable-xhdpi/ic_account_child_20dp.png",
"java/res/drawable-xxhdpi/ic_account_child_20dp.png",
"java/res/drawable-xxxhdpi/ic_account_child_20dp.png",
"java/res/drawable/autofill_key.xml",
"java/res/drawable/chrome_sync_logo.xml",
"java/res/drawable/devices_icon.xml",
"java/res/drawable/ic_expand_more_in_circle_24dp.xml",
"java/res/drawable/sync_promo_illustration.xml",
"java/res/layout/account_picker_bottom_sheet_continue_button.xml",
Expand Down Expand Up @@ -119,6 +122,7 @@ android_resources("java_resources") {
"java/res/layout/signin_progress_bar_dialog.xml",
"java/res/layout/signin_view.xml",
"java/res/layout/signout_wipe_storage_dialog.xml",
"java/res/layout/sync_consent_view.xml",
"java/res/values-sw320dp/styles.xml",
"java/res/values/dimens.xml",
"java/res/values/styles.xml",
Expand Down
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M7,17.5Q4.7,17.5 3.1,15.9Q1.5,14.3 1.5,12Q1.5,9.7 3.1,8.1Q4.7,6.5 7,6.5Q8.55,6.5 9.875,7.325Q11.2,8.15 11.9,9.5H22.5V14.5H20.5V17.5H15.5V14.5H11.9Q11.2,15.85 9.875,16.675Q8.55,17.5 7,17.5ZM7,16Q8.65,16 9.65,14.988Q10.65,13.975 10.85,13H17V16H19V13H21V11H10.85Q10.65,10.025 9.65,9.012Q8.65,8 7,8Q5.35,8 4.175,9.175Q3,10.35 3,12Q3,13.65 4.175,14.825Q5.35,16 7,16ZM7,13.625Q7.675,13.625 8.15,13.15Q8.625,12.675 8.625,12Q8.625,11.325 8.15,10.85Q7.675,10.375 7,10.375Q6.325,10.375 5.85,10.85Q5.375,11.325 5.375,12Q5.375,12.675 5.85,13.15Q6.325,13.625 7,13.625ZM7,12Q7,12 7,12Q7,12 7,12Q7,12 7,12Q7,12 7,12Q7,12 7,12Q7,12 7,12Q7,12 7,12Q7,12 7,12Z"
android:fillColor="@macro/default_control_color_active" />
</vector>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M2.5,19.375V17.125H4.5V6.3Q4.5,5.525 5.025,5Q5.55,4.475 6.3,4.475H20.75V5.975H6.3Q6.175,5.975 6.088,6.075Q6,6.175 6,6.3V17.125H11.75V19.375ZM15.4,19.375Q15.025,19.375 14.762,19.125Q14.5,18.875 14.5,18.5V9.25Q14.5,8.875 14.762,8.625Q15.025,8.375 15.4,8.375H20.625Q21,8.375 21.25,8.625Q21.5,8.875 21.5,9.25V18.5Q21.5,18.875 21.25,19.125Q21,19.375 20.625,19.375ZM16,17.125H20V9.875H16Z"
android:fillColor="@macro/default_control_color_active" />
</vector>

0 comments on commit 62b296f

Please sign in to comment.