Merge "More layoutlib tests." into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1f8e3de40c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,393 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:ignore="HardcodedText,LabelFor,TextFields,ContentDescription,RtlHardcoded">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/frameLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginEnd="311dp">
|
||||
|
||||
<TextView
|
||||
android:id="@id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|top"
|
||||
android:text="New Text" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/frameLayout"
|
||||
android:text="Large Text"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toEndOf="@id/textView2"
|
||||
android:text="Medium Text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/textView2"
|
||||
android:layout_toEndOf="@id/textView2"
|
||||
android:text="Small Text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<Button
|
||||
android:id="@id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/textView3"
|
||||
android:layout_toEndOf="@id/textView4"
|
||||
android:text="New Button" />
|
||||
|
||||
<Button
|
||||
android:id="@id/button2"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toEndOf="@id/button"
|
||||
android:text="New Button" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@id/checkBox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@id/button"
|
||||
android:layout_below="@id/button"
|
||||
android:text="New CheckBox" />
|
||||
|
||||
<Switch
|
||||
android:id="@id/switch1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/textView2"
|
||||
android:text="New Switch" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/imageButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/button"
|
||||
android:layout_toEndOf="@id/switch1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_launcher"
|
||||
android:layout_below="@id/button"
|
||||
android:layout_toEndOf="@id/imageButton" />
|
||||
|
||||
<GridLayout
|
||||
android:id="@id/gridLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/imageButton"
|
||||
android:columnCount="2"
|
||||
android:rowCount="2">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@id/progressBar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="0"
|
||||
android:layout_row="0" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@id/progressBar2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="1"
|
||||
android:layout_row="0" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@id/progressBar3"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="0"
|
||||
android:layout_row="1" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@id/progressBar4"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="1"
|
||||
android:layout_row="1" />
|
||||
</GridLayout>
|
||||
|
||||
<SeekBar
|
||||
android:id="@id/seekBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/gridLayout"
|
||||
android:layout_toEndOf="@id/gridLayout" />
|
||||
|
||||
<RatingBar
|
||||
android:id="@id/ratingBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/switch2"
|
||||
android:layout_toEndOf="@id/gridLayout" />
|
||||
|
||||
<Switch
|
||||
android:id="@id/switch2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/seekBar"
|
||||
android:layout_toEndOf="@id/switch1"
|
||||
android:checked="true" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/ratingBar"
|
||||
android:layout_alignParentStart="true"
|
||||
android:text="plain text" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/ratingBar"
|
||||
android:ems="3"
|
||||
android:inputType="textPersonName"
|
||||
android:text="Name" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/editText2"
|
||||
android:ems="2"
|
||||
android:inputType="textPassword"
|
||||
android:text="password" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/editText3"
|
||||
android:layout_toEndOf="@id/editText3"
|
||||
android:ems="3"
|
||||
android:inputType="numberPassword"
|
||||
android:text="numeric password" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/editText3"
|
||||
android:layout_toStartOf="@id/editText6"
|
||||
android:ems="7"
|
||||
android:inputType="textEmailAddress"
|
||||
android:text="email@domain.com" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/editText4"
|
||||
android:ems="7"
|
||||
android:inputType="phone"
|
||||
android:text="+11235554344" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText7"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/editText"
|
||||
android:layout_toEndOf="@id/editText4"
|
||||
android:ems="10"
|
||||
android:inputType="textPostalAddress"
|
||||
android:text="1600 Amphitheatre" />
|
||||
|
||||
<EditText
|
||||
android:id="@id/editText9"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/editText5"
|
||||
android:layout_alignParentStart="true"
|
||||
android:ems="3"
|
||||
android:inputType="time"
|
||||
android:text="12:12" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/editText5"
|
||||
android:layout_toEndOf="@id/editText9"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@id/radioButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="New RadioButton" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@id/radioButton2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="New RadioButton" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<CheckedTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="CheckedTextView"
|
||||
android:id="@id/checkedTextView"
|
||||
android:layout_below="@id/button2"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignStart="@id/button2" />
|
||||
|
||||
<DialerFilter
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/checkBox"
|
||||
android:layout_toStartOf="@id/quickContactBadge"
|
||||
android:id="@id/dialerFilter"
|
||||
android:layout_above="@id/ratingBar"
|
||||
android:layout_toEndOf="@id/seekBar">
|
||||
|
||||
<EditText
|
||||
android:id="@android:id/hint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hint" />
|
||||
|
||||
<EditText
|
||||
android:id="@android:id/primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/hint"
|
||||
android:text="Primary" />
|
||||
</DialerFilter>
|
||||
|
||||
<QuickContactBadge
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/quickContactBadge"
|
||||
android:layout_below="@id/checkedTextView"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
<android.inputmethodservice.ExtractEditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ExtractEditText"
|
||||
android:id="@id/extractEditText"
|
||||
android:layout_below="@id/editText9"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignStart="@id/checkedTextView" />
|
||||
|
||||
<ZoomControls
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/zoomControls"
|
||||
android:layout_below="@id/editText9"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<TextureView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/textureView"
|
||||
android:layout_below="@id/zoomControls"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignBottom="@id/extractEditText"
|
||||
android:layout_toStartOf="@id/editText3" />
|
||||
|
||||
<ListView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/listView"
|
||||
android:layout_below="@id/textureView"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignEnd="@id/textureView" />
|
||||
|
||||
<GridView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/gridView"
|
||||
android:layout_below="@id/extractEditText"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignStart="@id/extractEditText" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/scrollView"
|
||||
android:layout_below="@id/zoomControls"
|
||||
android:layout_toRightOf="@id/listView"
|
||||
android:layout_toLeftOf="@id/extractEditText">
|
||||
|
||||
<TabHost
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/tabHost">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@id/linearLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
</ScrollView>
|
||||
|
||||
<SearchView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/searchView"
|
||||
android:layout_alignBottom="@id/zoomControls"
|
||||
android:layout_toEndOf="@id/seekBar" />
|
||||
|
||||
</RelativeLayout>
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item type="id" name="button" />
|
||||
<item type="id" name="button2" />
|
||||
<item type="id" name="checkBox" />
|
||||
<item type="id" name="checkedTextView" />
|
||||
<item type="id" name="dialerFilter" />
|
||||
<item type="id" name="editText" />
|
||||
<item type="id" name="editText2" />
|
||||
<item type="id" name="editText3" />
|
||||
<item type="id" name="editText4" />
|
||||
<item type="id" name="editText5" />
|
||||
<item type="id" name="editText6" />
|
||||
<item type="id" name="editText7" />
|
||||
<item type="id" name="editText8" />
|
||||
<item type="id" name="editText9" />
|
||||
<item type="id" name="extractEditText" />
|
||||
<item type="id" name="frameLayout" />
|
||||
<item type="id" name="gridLayout" />
|
||||
<item type="id" name="gridView" />
|
||||
<item type="id" name="imageButton" />
|
||||
<item type="id" name="imageView" />
|
||||
<item type="id" name="linearLayout" />
|
||||
<item type="id" name="linearLayout2" />
|
||||
<item type="id" name="listView" />
|
||||
<item type="id" name="progressBar" />
|
||||
<item type="id" name="progressBar2" />
|
||||
<item type="id" name="progressBar3" />
|
||||
<item type="id" name="progressBar4" />
|
||||
<item type="id" name="quickContactBadge" />
|
||||
<item type="id" name="radioButton" />
|
||||
<item type="id" name="radioButton2" />
|
||||
<item type="id" name="ratingBar" />
|
||||
<item type="id" name="scrollView" />
|
||||
<item type="id" name="searchView" />
|
||||
<item type="id" name="seekBar" />
|
||||
<item type="id" name="spinner" />
|
||||
<item type="id" name="switch1" />
|
||||
<item type="id" name="switch2" />
|
||||
<item type="id" name="tabHost" />
|
||||
<item type="id" name="textView" />
|
||||
<item type="id" name="textView2" />
|
||||
<item type="id" name="textView3" />
|
||||
<item type="id" name="textView4" />
|
||||
<item type="id" name="textureView" />
|
||||
<item type="id" name="zoomControls" />
|
||||
</resources>
|
@ -275,14 +275,27 @@ public class Main {
|
||||
ConfigGenerator.getEnumMap(attrs), getLayoutLog());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new rendering session and test that rendering /layout/activity.xml on nexus 5
|
||||
* doesn't throw any exceptions.
|
||||
*/
|
||||
/** Text activity.xml */
|
||||
@Test
|
||||
public void testRendering() throws ClassNotFoundException {
|
||||
public void testActivity() throws ClassNotFoundException {
|
||||
renderAndVerify("activity.xml", "activity.png");
|
||||
|
||||
}
|
||||
|
||||
/** Test allwidgets.xml */
|
||||
@Test
|
||||
public void testAllWidgets() throws ClassNotFoundException {
|
||||
renderAndVerify("allwidgets.xml", "allwidgets.png");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new rendering session and test that rendering given layout on nexus 5
|
||||
* doesn't throw any exceptions and matches the provided image.
|
||||
*/
|
||||
private void renderAndVerify(String layoutFileName, String goldenFileName)
|
||||
throws ClassNotFoundException {
|
||||
// Create the layout pull parser.
|
||||
LayoutPullParser parser = new LayoutPullParser(APP_TEST_RES + "/layout/activity.xml");
|
||||
LayoutPullParser parser = new LayoutPullParser(APP_TEST_RES + "/layout/" + layoutFileName);
|
||||
// Create LayoutLibCallback.
|
||||
LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
|
||||
layoutLibCallback.initResources();
|
||||
@ -301,7 +314,7 @@ public class Main {
|
||||
session.getResult().getErrorMessage());
|
||||
}
|
||||
try {
|
||||
String goldenImagePath = APP_TEST_DIR + "/golden/activity.png";
|
||||
String goldenImagePath = APP_TEST_DIR + "/golden/" + goldenFileName;
|
||||
ImageUtils.requireSimilar(goldenImagePath, session.getImage());
|
||||
} catch (IOException e) {
|
||||
getLogger().error(e, e.getMessage());
|
||||
@ -309,7 +322,7 @@ public class Main {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses Theme.Material and Target sdk version as 21.
|
||||
* Uses Theme.Material and Target sdk version as 22.
|
||||
*/
|
||||
private SessionParams getSessionParams(LayoutPullParser layoutParser,
|
||||
ConfigGenerator configGenerator, LayoutLibTestCallback layoutLibCallback) {
|
||||
@ -327,7 +340,7 @@ public class Main {
|
||||
resourceResolver,
|
||||
layoutLibCallback,
|
||||
0,
|
||||
21, // TODO: Make it more configurable to run tests for various versions.
|
||||
22, // TODO: Make it more configurable to run tests for various versions.
|
||||
getLayoutLog());
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,11 @@ import com.android.ide.common.resources.configuration.CountryCodeQualifier;
|
||||
import com.android.ide.common.resources.configuration.DensityQualifier;
|
||||
import com.android.ide.common.resources.configuration.FolderConfiguration;
|
||||
import com.android.ide.common.resources.configuration.KeyboardStateQualifier;
|
||||
import com.android.ide.common.resources.configuration.LanguageQualifier;
|
||||
import com.android.ide.common.resources.configuration.LayoutDirectionQualifier;
|
||||
import com.android.ide.common.resources.configuration.LocaleQualifier;
|
||||
import com.android.ide.common.resources.configuration.NavigationMethodQualifier;
|
||||
import com.android.ide.common.resources.configuration.NetworkCodeQualifier;
|
||||
import com.android.ide.common.resources.configuration.NightModeQualifier;
|
||||
import com.android.ide.common.resources.configuration.RegionQualifier;
|
||||
import com.android.ide.common.resources.configuration.ScreenDimensionQualifier;
|
||||
import com.android.ide.common.resources.configuration.ScreenOrientationQualifier;
|
||||
import com.android.ide.common.resources.configuration.ScreenRatioQualifier;
|
||||
@ -158,10 +157,9 @@ public class ConfigGenerator {
|
||||
config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL));
|
||||
config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT));
|
||||
config.setCountryCodeQualifier(new CountryCodeQualifier());
|
||||
config.setLanguageQualifier(new LanguageQualifier());
|
||||
config.setLayoutDirectionQualifier(new LayoutDirectionQualifier());
|
||||
config.setNetworkCodeQualifier(new NetworkCodeQualifier());
|
||||
config.setRegionQualifier(new RegionQualifier());
|
||||
config.setLocaleQualifier(new LocaleQualifier());
|
||||
config.setVersionQualifier(new VersionQualifier());
|
||||
return config;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import com.android.ide.common.rendering.api.ILayoutPullParser;
|
||||
import com.android.ide.common.rendering.api.LayoutlibCallback;
|
||||
import com.android.ide.common.rendering.api.ResourceReference;
|
||||
import com.android.ide.common.rendering.api.ResourceValue;
|
||||
import com.android.resources.ResourceType;
|
||||
import com.android.ide.common.resources.IntArrayWrapper;
|
||||
import com.android.resources.ResourceType;
|
||||
import com.android.util.Pair;
|
||||
import com.android.utils.ILogger;
|
||||
|
||||
@ -36,6 +36,8 @@ import java.util.Map;
|
||||
|
||||
import com.google.android.collect.Maps;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@SuppressWarnings("deprecation") // For Pair
|
||||
public class LayoutLibTestCallback extends LayoutlibCallback {
|
||||
|
||||
@ -121,7 +123,7 @@ public class LayoutLibTestCallback extends LayoutlibCallback {
|
||||
|
||||
@Override
|
||||
public ILayoutPullParser getParser(String layoutName) {
|
||||
org.junit.Assert.fail("This method shouldn't be called by this version of LayoutLib.");
|
||||
fail("This method shouldn't be called by this version of LayoutLib.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user