Skip to content

Commit

Permalink
[CredManager]Allow clicks on the Password Manager when setting is man…
Browse files Browse the repository at this point in the history
…aged

The item should display the standard message for settings that are
managed, but should allow the user to click through and launch the
Credential Manager when UPM is enabled.

(cherry picked from commit 9dea430)

Bug: 1329806
Change-Id: Icdb0328013d80ddce4f8b9fbd8eee4638e0cf98c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3673058
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Reviewed-by: Andrey Zaytsev <andzaytsev@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1009078}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3689574
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Maria Kazinova <kazinova@google.com>
Cr-Commit-Position: refs/branch-heads/5060@{#637}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
Ioana Pandele authored and Chromium LUCI CQ committed Jun 7, 2022
1 parent 6aa377d commit ae8db80
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ public boolean isPreferenceClickDisabledByPolicy(Preference preference) {
return TemplateUrlServiceFactory.get().isDefaultSearchManaged();
}
if (usesUnifiedPasswordManagerUI() && PREF_PASSWORDS.equals(preference.getKey())) {
return UserPrefs.get(Profile.getLastUsedRegularProfile())
.isManagedPreference(Pref.CREDENTIALS_ENABLE_SERVICE);
return false;
}
return isPreferenceControlledByPolicy(preference)
|| isPreferenceControlledByCustodian(preference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.hasSibling;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.not;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -436,16 +438,33 @@ public void testSyncPromoShownIsNotOverCounted() {
@SmallTest
@EnableFeatures(ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID)
@Policies.Add({ @Policies.Item(key = "PasswordManagerEnabled", string = "false") })
public void testPasswordsItemDisabledWhenManaged() {
public void testPasswordsItemClickableWhenManaged() {
launchSettingsActivity();
Assert.assertFalse(mMainSettings.findPreference(MainSettings.PREF_PASSWORDS).isEnabled());
String prefTitleWithoutNewLabel =
SpanApplier
.removeSpanText(
mMainSettings.getString(R.string.password_settings_title_gpm),
new SpanInfo("<new>", "</new>"))
.trim();
onViewWaiting(allOf(withText(R.string.managed_by_your_organization),
hasSibling(withText(prefTitleWithoutNewLabel)), isDisplayed()));
Assert.assertTrue(mMainSettings.findPreference(MainSettings.PREF_PASSWORDS).isEnabled());
}

@Test
@SmallTest
@EnableFeatures(ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID)
@Policies.Remove({ @Policies.Item(key = "PasswordManagerEnabled", string = "false") })
public void testPasswordsItemEnabledWhenNotManaged() throws InterruptedException {
launchSettingsActivity();
String prefTitleWithoutNewLabel =
SpanApplier
.removeSpanText(
mMainSettings.getString(R.string.password_settings_title_gpm),
new SpanInfo("<new>", "</new>"))
.trim();
onViewWaiting(allOf(withText(prefTitleWithoutNewLabel),
not(hasSibling(withText(R.string.managed_by_your_organization))), isDisplayed()));
Assert.assertTrue(mMainSettings.findPreference(MainSettings.PREF_PASSWORDS).isEnabled());
}

Expand All @@ -455,6 +474,8 @@ public void testPasswordsItemEnabledWhenNotManaged() throws InterruptedException
@Policies.Add({ @Policies.Item(key = "PasswordManagerEnabled", string = "false") })
public void testPasswordsItemEnabledWhenManagedWithoutUPM() {
launchSettingsActivity();
onViewWaiting(allOf(withText(R.string.password_settings_title),
not(hasSibling(withText(R.string.managed_by_your_organization))), isDisplayed()));
Assert.assertTrue(mMainSettings.findPreference(MainSettings.PREF_PASSWORDS).isEnabled());
}

Expand Down

0 comments on commit ae8db80

Please sign in to comment.