Commit a19f5338 authored by Wenyu Fu's avatar Wenyu Fu Committed by Commit Bot

[HomepageConversion] Add render tests for RadioButton(s)

Add render tests for RadioButtonWithDescription, RadioButtonWithEditText
and RadioButtonWithDescriptionLayout.

Bug: 1036470
Change-Id: I793aa1a17f65f6c0a2ced6a83b6216cc5df8c227
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984752Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Wenyu Fu <wenyufu@chromium.org>
Auto-Submit: Wenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731800}
parent 62553dcc
...@@ -88,6 +88,7 @@ android_library("ui_widget_java_tests") { ...@@ -88,6 +88,7 @@ android_library("ui_widget_java_tests") {
"java/src/org/chromium/chrome/browser/ui/widget/MoreProgressButtonTest.java", "java/src/org/chromium/chrome/browser/ui/widget/MoreProgressButtonTest.java",
"java/src/org/chromium/chrome/browser/ui/widget/PromoDialogTest.java", "java/src/org/chromium/chrome/browser/ui/widget/PromoDialogTest.java",
"java/src/org/chromium/chrome/browser/ui/widget/RadioButtonLayoutTest.java", "java/src/org/chromium/chrome/browser/ui/widget/RadioButtonLayoutTest.java",
"java/src/org/chromium/chrome/browser/ui/widget/RadioButtonRenderTest.java",
"java/src/org/chromium/chrome/browser/ui/widget/RadioButtonWithDescriptionLayoutTest.java", "java/src/org/chromium/chrome/browser/ui/widget/RadioButtonWithDescriptionLayoutTest.java",
"java/src/org/chromium/chrome/browser/ui/widget/RadioButtonWithEditTextTest.java", "java/src/org/chromium/chrome/browser/ui/widget/RadioButtonWithEditTextTest.java",
"java/src/org/chromium/chrome/browser/ui/widget/WrappingLayoutTest.java", "java/src/org/chromium/chrome/browser/ui/widget/WrappingLayoutTest.java",
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@id/radio_button" android:layout_toEndOf="@id/radio_button"
android:layout_centerVertical="true"
android:textAppearance="@style/TextAppearance.BlackTitle1" android:textAppearance="@style/TextAppearance.BlackTitle1"
android:inputType="text" /> android:inputType="text" />
......
// Copyright 2020 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.
package org.chromium.chrome.browser.ui.widget;
import android.app.Activity;
import android.graphics.Color;
import android.support.test.filters.SmallTest;
import android.view.LayoutInflater;
import android.view.View;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.ClassParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterSet;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ui.widget.test.R;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.test.util.DummyUiActivityTestCase;
import org.chromium.ui.test.util.NightModeTestUtils;
import org.chromium.ui.test.util.RenderTestRule;
import java.util.List;
/**
* Render test for {@link RadioButtonWithDescription}, {@link RadioButtonWithEditText} and
* {@link RadioButtonWithDescriptionLayout}.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
public class RadioButtonRenderTest extends DummyUiActivityTestCase {
@ClassParameter
private static List<ParameterSet> sClassParams =
new NightModeTestUtils.NightModeParams().getParameters();
@Rule
public RenderTestRule mRenderTestRule =
new RenderTestRule("chrome/test/data/android/render_tests");
private RadioButtonWithDescriptionLayout mLayout;
private RadioButtonWithDescription mRadioButtonWithDescription1;
private RadioButtonWithDescription mRadioButtonWithDescription2;
private RadioButtonWithEditText mRadioButtonWithEditText1;
private RadioButtonWithEditText mRadioButtonWithEditText2;
private RadioButtonWithEditText mRadioButtonWithEditText3;
private RadioButtonWithEditText mRadioButtonWithEditText4;
private final int mFakeBgColor;
public RadioButtonRenderTest(boolean nightModeEnabled) {
mFakeBgColor = nightModeEnabled ? Color.BLACK : Color.WHITE;
NightModeTestUtils.setUpNightModeForDummyUiActivity(nightModeEnabled);
mRenderTestRule.setNightModeEnabled(nightModeEnabled);
}
@Override
public void setUpTest() throws Exception {
super.setUpTest();
Activity activity = getActivity();
TestThreadUtils.runOnUiThreadBlocking(() -> {
View content = LayoutInflater.from(activity).inflate(
R.layout.radio_button_render_test, null, false);
activity.setContentView(content);
mLayout = content.findViewById(R.id.test_radio_button_layout);
mLayout.setBackgroundColor(mFakeBgColor);
mRadioButtonWithDescription1 = content.findViewById(R.id.test_radio_description_1);
mRadioButtonWithDescription2 = content.findViewById(R.id.test_radio_description_2);
mRadioButtonWithEditText1 = content.findViewById(R.id.test_radio_edit_text_1);
mRadioButtonWithEditText2 = content.findViewById(R.id.test_radio_edit_text_2);
mRadioButtonWithEditText3 = content.findViewById(R.id.test_radio_edit_text_3);
mRadioButtonWithEditText4 = content.findViewById(R.id.test_radio_edit_text_4);
});
Assert.assertNotNull(mLayout);
Assert.assertNotNull(mRadioButtonWithDescription1);
Assert.assertNotNull(mRadioButtonWithDescription2);
Assert.assertNotNull(mRadioButtonWithEditText1);
Assert.assertNotNull(mRadioButtonWithEditText2);
Assert.assertNotNull(mRadioButtonWithEditText3);
Assert.assertNotNull(mRadioButtonWithEditText4);
}
@Test
@SmallTest
@Feature({"RenderTest", "RadioButton"})
public void testRadioButtonWithDescriptionLayout() throws Exception {
mRenderTestRule.render(mRadioButtonWithDescription1, "test_radio_description_1");
mRenderTestRule.render(mRadioButtonWithDescription2, "test_radio_description_2");
mRenderTestRule.render(mRadioButtonWithEditText1, "test_radio_edit_text_1");
mRenderTestRule.render(mRadioButtonWithEditText2, "test_radio_edit_text_2");
mRenderTestRule.render(mRadioButtonWithEditText3, "test_radio_edit_text_3");
mRenderTestRule.render(mRadioButtonWithEditText4, "test_radio_edit_text_4");
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 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. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<org.chromium.chrome.browser.ui.widget.RadioButtonWithDescriptionLayout
android:id="@+id/test_radio_button_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- RadioButtonWithDescription - With primary, without description. -->
<org.chromium.chrome.browser.ui.widget.RadioButtonWithDescription
android:id="@+id/test_radio_description_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
app:primaryText="@string/test_string" />
<!-- RadioButtonWithDescription - With primary and description. -->
<org.chromium.chrome.browser.ui.widget.RadioButtonWithDescription
android:id="@+id/test_radio_description_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
app:primaryText="@string/test_string"
app:descriptionText="@string/test_string" />
<!-- RadioButtonWithDescription - With primary and description. -->
<org.chromium.chrome.browser.ui.widget.RadioButtonWithEditText
android:id="@+id/test_radio_edit_text_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:inputType="text"
android:hint="@string/test_uri"
android:background="?attr/selectableItemBackground"
app:primaryText="@string/test_string"
app:descriptionText="@string/test_string" />
<!-- RadioButtonWithDescription - With primary, without description. -->
<org.chromium.chrome.browser.ui.widget.RadioButtonWithEditText
android:id="@+id/test_radio_edit_text_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:inputType="text"
android:hint="@string/test_uri"
android:background="?attr/selectableItemBackground"
app:primaryText="@string/test_string" />
<!-- RadioButtonWithDescription - Without primary, with hint, with description. -->
<org.chromium.chrome.browser.ui.widget.RadioButtonWithEditText
android:id="@+id/test_radio_edit_text_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:inputType="text"
android:hint="@string/test_uri"
android:background="?attr/selectableItemBackground"
app:descriptionText="@string/test_string" />
<!-- RadioButtonWithDescription - Without primary, without description. -->
<org.chromium.chrome.browser.ui.widget.RadioButtonWithEditText
android:id="@+id/test_radio_edit_text_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:inputType="text"
android:hint="@string/test_uri"
android:background="?attr/selectableItemBackground" />
</org.chromium.chrome.browser.ui.widget.RadioButtonWithDescriptionLayout>
</FrameLayout>
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