Commit d7df279b authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Added min width/height to ui framework.

Bug: b/145043394
Change-Id: I58214e0073f255662c6efca3f3f1e47f1c8b94ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124711Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#754836}
parent 1343d831
......@@ -64,7 +64,7 @@ public class AssistantViewFactory {
@CalledByNative
public static void setViewLayoutParams(View view, Context context, int width, int height,
float weight, int marginStart, int marginTop, int marginEnd, int marginBottom,
int layoutGravity) {
int layoutGravity, int minimumWidth, int minimumHeight) {
if (width > 0) {
width = AssistantDimension.getPixelSizeDp(context, width);
}
......@@ -80,6 +80,8 @@ public class AssistantViewFactory {
layoutParams.bottomMargin = AssistantDimension.getPixelSizeDp(context, marginBottom);
layoutParams.gravity = layoutGravity;
view.setLayoutParams(layoutParams);
view.setMinimumWidth(AssistantDimension.getPixelSizeDp(context, minimumWidth));
view.setMinimumHeight(AssistantDimension.getPixelSizeDp(context, minimumHeight));
}
/** Creates a {@code android.widget.LinearLayout} widget. */
......
......@@ -34,6 +34,7 @@ import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUi
import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.isImportantForAccessibility;
import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.startAutofillAssistant;
import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.waitUntilViewMatchesCondition;
import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.withMinimumSize;
import android.graphics.Typeface;
import android.support.test.InstrumentationRegistry;
......@@ -49,6 +50,7 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.autofill_assistant.generic_ui.AssistantDimension;
import org.chromium.chrome.browser.autofill_assistant.proto.ActionProto;
import org.chromium.chrome.browser.autofill_assistant.proto.BooleanAndProto;
import org.chromium.chrome.browser.autofill_assistant.proto.BooleanList;
......@@ -1089,6 +1091,9 @@ public class AutofillAssistantGenericUiTest {
.setRootView(
ViewProto.newBuilder()
.setIdentifier("text_view")
.setLayoutParams(
ViewLayoutParamsProto.newBuilder().setMinimumHeight(
48))
.setTextView(TextViewProto.newBuilder().setModelIdentifier(
"date_string")))
.setInteractions(
......@@ -1115,6 +1120,10 @@ public class AutofillAssistantGenericUiTest {
startAutofillAssistant(mTestRule.getActivity(), testService);
waitUntilViewMatchesCondition(withText("date not set"), isCompletelyDisplayed());
onView(withText("date not set"))
.check(matches(withMinimumSize(0,
AssistantDimension.getPixelSizeDp(
InstrumentationRegistry.getContext(), 48))));
onView(withText("date not set")).perform(click());
onView(withClassName(equalTo(DatePicker.class.getName())))
......
......@@ -112,7 +112,7 @@ class AutofillAssistantUiTestUtil {
}
/** Checks that a text view has a specific maximum number of lines to display. */
public static TypeSafeMatcher<View> isTextMaxLines(int maxLines) {
static TypeSafeMatcher<View> isTextMaxLines(int maxLines) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View item) {
......@@ -134,7 +134,7 @@ class AutofillAssistantUiTestUtil {
* explicitly set the text style, *NOT* for text spans! @see {@link #hasTypefaceSpan(int, int,
* int)}
*/
public static TypeSafeMatcher<View> hasTypefaceStyle(/*@Typeface.Style*/ int style) {
static TypeSafeMatcher<View> hasTypefaceStyle(/*@Typeface.Style*/ int style) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View item) {
......@@ -162,7 +162,7 @@ class AutofillAssistantUiTestUtil {
* @param style The style to check for
* @return A matcher that returns true if the view satisfies the condition.
*/
public static TypeSafeMatcher<View> hasTypefaceSpan(
static TypeSafeMatcher<View> hasTypefaceSpan(
int start, int end, /*@Typeface.Style*/ int style) {
return new TypeSafeMatcher<View>() {
@Override
......@@ -195,7 +195,7 @@ class AutofillAssistantUiTestUtil {
};
}
public static Matcher<View> isImportantForAccessibility(int mode) {
static Matcher<View> isImportantForAccessibility(int mode) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View item) {
......@@ -209,7 +209,7 @@ class AutofillAssistantUiTestUtil {
};
}
public static Matcher<View> hasTintColor(final int colorResId) {
static Matcher<View> hasTintColor(final int colorResId) {
return new BoundedMatcher<View, ImageView>(ImageView.class) {
private Context mContext;
......@@ -242,7 +242,7 @@ class AutofillAssistantUiTestUtil {
};
}
public static Matcher<View> isNextAfterSibling(final Matcher<View> siblingMatcher) {
static Matcher<View> isNextAfterSibling(final Matcher<View> siblingMatcher) {
Preconditions.checkNotNull(siblingMatcher);
return new TypeSafeMatcher<View>() {
@Override
......@@ -271,7 +271,7 @@ class AutofillAssistantUiTestUtil {
};
}
public static Matcher<View> withParentIndex(int parentIndex) {
static Matcher<View> withParentIndex(int parentIndex) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
......@@ -291,7 +291,24 @@ class AutofillAssistantUiTestUtil {
};
}
public static ViewAction openTextLink(String textLink) {
static Matcher<View> withMinimumSize(int minWidthInPixels, int minHeightInPixels) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View view) {
return view.getWidth() >= minWidthInPixels && view.getHeight() >= minHeightInPixels
&& view.getMinimumWidth() == minWidthInPixels
&& view.getMinimumHeight() == minHeightInPixels;
}
@Override
public void describeTo(Description description) {
description.appendText(
"Width >= " + minWidthInPixels + " and height >= " + minHeightInPixels);
}
};
}
static ViewAction openTextLink(String textLink) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
......
......@@ -261,7 +261,9 @@ base::android::ScopedJavaGlobalRef<jobject> CreateJavaView(
proto.layout_params().margin_start(),
proto.layout_params().margin_top(), proto.layout_params().margin_end(),
proto.layout_params().margin_bottom(),
proto.layout_params().layout_gravity());
proto.layout_params().layout_gravity(),
proto.layout_params().minimum_width(),
proto.layout_params().minimum_height());
}
if (proto.view_case() == ViewProto::kViewContainer) {
......
......@@ -139,6 +139,12 @@ message ViewLayoutParamsProto {
// A bit-wise OR of the desired |Gravity| values.
optional int32 layout_gravity = 7;
// The minimum width of the view, in dp.
optional int32 minimum_width = 9;
// The minimum height of the view, in dp.
optional int32 minimum_height = 10;
}
message ViewContainerProto {
......
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