Commit 34373c08 authored by Luca Hunkeler's avatar Luca Hunkeler Committed by Chromium LUCI CQ

[Autofill Assistant] Follow up to proactive help settings

Moved a test to a more appropriate class and added a comment.

Bug: b/176071036
Change-Id: I569842e3403cddf000d4b44ceefa8ca77ec2e253
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611256Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Commit-Queue: Luca Hunkeler <hluca@google.com>
Cr-Commit-Position: refs/heads/master@{#841057}
parent 41b29808
......@@ -17,6 +17,8 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.Features;
......@@ -63,4 +65,31 @@ public class AutofillAssistantFacadeTest {
intent.putExtra(extrasPrefix + "REQUEST_TRIGGER_SCRIPT", true);
Assert.assertTrue(AutofillAssistantFacade.isAutofillAssistantEnabled(intent));
}
/**
* Tests that the preconditions for triggering proactive help work correctly.
*/
@Test
@MediumTest
@Features.EnableFeatures(ChromeFeatureList.AUTOFILL_ASSISTANT_PROACTIVE_HELP)
public void proactiveHelpConditions() {
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, false);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, true);
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, false);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, true);
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
}
}
......@@ -572,28 +572,4 @@ public class AutofillAssistantTriggerScriptIntegrationTest {
Espresso.pressBack();
waitUntilViewMatchesCondition(withText("Hello world"), isCompletelyDisplayed());
}
@Test
@MediumTest
@Features.EnableFeatures(ChromeFeatureList.AUTOFILL_ASSISTANT_PROACTIVE_HELP)
public void proactiveHelpConditions() {
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, false);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, true);
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, false);
Assert.assertFalse(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
SharedPreferencesManager.getInstance().writeBoolean(
ChromePreferenceKeys.AUTOFILL_ASSISTANT_PROACTIVE_HELP, true);
Assert.assertTrue(AutofillAssistantPreferencesUtil.isProactiveHelpOn());
}
}
......@@ -31,7 +31,11 @@ public class AutofillAssistantPreferencesUtil {
return isProactiveHelpSwitchOn() && isAutofillAssistantSwitchOn();
}
/** Checks whether the proactive help switch preference in settings is on. */
/**
* Checks whether the proactive help switch preference in settings is on.
* Warning: even if the switch is on, it can appear disabled if the Autofill Assistant switch is
* off. Use {@link #isProactiveHelpOn()} to determine whether to trigger proactive help.
*/
private static boolean isProactiveHelpSwitchOn() {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_ASSISTANT_PROACTIVE_HELP)) {
return false;
......
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