Commit 3508f614 authored by Mathias Carlen's avatar Mathias Carlen Committed by Commit Bot

[Autofill Assistant] Hardcode script argument.

For testing purposes we want to already expose an argument for a
specific action.

The correct way to address this is to use the action specs given in the
proto and properly report the args configured therein.

R=szermatt@chromium.org

Bug: b/138833619
Change-Id: I4d5d0795e6a1249879b2675428e9418264251ca0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883076
Commit-Queue: Mathias Carlen <mcarlen@chromium.org>
Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710263}
parent f0798027
...@@ -152,9 +152,11 @@ public class AutofillAssistantDirectActionHandlerTest { ...@@ -152,9 +152,11 @@ public class AutofillAssistantDirectActionHandlerTest {
// Now we expect 2 dyamic actions "search" and "action2". // Now we expect 2 dyamic actions "search" and "action2".
FakeDirectActionDefinition search = reporter.mActions.get(1); FakeDirectActionDefinition search = reporter.mActions.get(1);
assertEquals("search", search.mId); assertEquals("search", search.mId);
assertEquals(1, search.mParameters.size()); assertEquals(2, search.mParameters.size());
assertEquals("experiment_ids", search.mParameters.get(0).mName); assertEquals("experiment_ids", search.mParameters.get(0).mName);
assertEquals(Type.STRING, search.mParameters.get(0).mType); assertEquals(Type.STRING, search.mParameters.get(0).mType);
assertEquals("SEARCH_QUERY", search.mParameters.get(1).mName);
assertEquals(Type.STRING, search.mParameters.get(1).mType);
assertEquals(1, search.mResults.size()); assertEquals(1, search.mResults.size());
assertEquals("success", search.mResults.get(0).mName); assertEquals("success", search.mResults.get(0).mName);
assertEquals(Type.BOOLEAN, search.mResults.get(0).mType); assertEquals(Type.BOOLEAN, search.mResults.get(0).mType);
......
...@@ -13,6 +13,7 @@ import org.chromium.base.Callback; ...@@ -13,6 +13,7 @@ import org.chromium.base.Callback;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.chrome.browser.directactions.DirectActionHandler; import org.chromium.chrome.browser.directactions.DirectActionHandler;
import org.chromium.chrome.browser.directactions.DirectActionReporter; import org.chromium.chrome.browser.directactions.DirectActionReporter;
import org.chromium.chrome.browser.directactions.DirectActionReporter.Definition;
import org.chromium.chrome.browser.directactions.DirectActionReporter.Type; import org.chromium.chrome.browser.directactions.DirectActionReporter.Type;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.widget.ScrimView; import org.chromium.chrome.browser.widget.ScrimView;
...@@ -84,9 +85,16 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler ...@@ -84,9 +85,16 @@ public class AutofillAssistantDirectActionHandler implements DirectActionHandler
// Additionally report if there are dynamic actions. // Additionally report if there are dynamic actions.
if (mDelegate != null) { if (mDelegate != null) {
for (String action : mDelegate.getActions()) { for (String action : mDelegate.getActions()) {
reporter.addDirectAction(action) Definition definition =
.withParameter(EXPERIMENT_IDS, Type.STRING, /* required= */ false) reporter.addDirectAction(action)
.withResult(AA_ACTION_RESULT, Type.BOOLEAN); .withParameter(EXPERIMENT_IDS, Type.STRING, /* required= */ false)
.withResult(AA_ACTION_RESULT, Type.BOOLEAN);
// TODO(b/138833619): For testing purposes only. Remove this when script
// parameters are properly supported.
if (action.equals("search")) {
definition.withParameter("SEARCH_QUERY", Type.STRING, /* required= */ true);
}
} }
} }
} }
......
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