Fix layoutlib tests.
The date picker and calendar widgets show the current date. Comparing widgets showing current date with a static golden image wasn't the best idea. - Change the widgets to custom widgets that set a predefined date/time so that the rendering is independent of the system date. - Change the layout slightly to make it look nicer. - Update gradle plugin version. Change-Id: Ia3fb4965a372a28087a0d8c9df40fd6779df6050
This commit is contained in:
@@ -3,7 +3,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.12.+'
|
||||
classpath 'com.android.tools.build:gradle:1.1.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
@@ -19,23 +19,21 @@ allprojects {
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 20
|
||||
buildToolsVersion '20'
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion '21.1.2'
|
||||
defaultConfig {
|
||||
applicationId 'com.android.layoutlib.test.myapplication'
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 20
|
||||
targetSdkVersion 21
|
||||
versionCode 1
|
||||
versionName '1.0'
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard false
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
productFlavors {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 7.9 KiB |
@@ -1,6 +1,6 @@
|
||||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
#Tue Mar 17 15:13:06 PDT 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.android.layoulib.test.myapplication;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.android.layoutlib.test.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.CalendarView;
|
||||
|
||||
public class CustomCalendar extends CalendarView {
|
||||
public CustomCalendar(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CustomCalendar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CustomCalendar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public CustomCalendar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDate(871703200000L, false, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.android.layoutlib.test.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.DatePicker;
|
||||
|
||||
public class CustomDate extends DatePicker {
|
||||
public CustomDate(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CustomDate(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CustomDate(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public CustomDate(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
init(2015, 0, 20, null);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:columnCount="2"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Some text"/>
|
||||
<DatePicker
|
||||
<Switch
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:checked="true"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
<com.android.layoutlib.test.myapplication.CustomDate
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"/>
|
||||
<CalendarView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"/>
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content"/>
|
||||
<com.android.layoutlib.test.myapplication.CustomCalendar
|
||||
android:layout_width="200dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="200dp"/>
|
||||
</GridLayout>
|
||||
@@ -300,7 +300,8 @@ public class Main {
|
||||
FolderConfiguration config = configGenerator.getFolderConfig();
|
||||
ResourceResolver resourceResolver =
|
||||
ResourceResolver.create(mProjectResources.getConfiguredResources(config),
|
||||
mFrameworkRepo.getConfiguredResources(config), "Theme.Material", false);
|
||||
mFrameworkRepo.getConfiguredResources(config),
|
||||
"Theme.Material.Light.DarkActionBar", false);
|
||||
|
||||
return new SessionParams(
|
||||
layoutParser,
|
||||
@@ -320,7 +321,7 @@ public class Main {
|
||||
@Override
|
||||
public void warning(String tag, String message, Object data) {
|
||||
System.out.println("Warning " + tag + ": " + message);
|
||||
fail(message);
|
||||
failWithMsg(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,13 +331,13 @@ public class Main {
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
fail(message);
|
||||
failWithMsg(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String tag, String message, Object data) {
|
||||
System.out.println("Error " + tag + ": " + message);
|
||||
fail(message);
|
||||
failWithMsg(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -345,7 +346,7 @@ public class Main {
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
fail(message);
|
||||
failWithMsg(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -360,12 +361,12 @@ public class Main {
|
||||
if (t != null) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
fail(String.format(msgFormat, args));
|
||||
failWithMsg(msgFormat, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String msgFormat, Object... args) {
|
||||
fail(String.format(msgFormat, args));
|
||||
failWithMsg(msgFormat, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -381,4 +382,8 @@ public class Main {
|
||||
}
|
||||
return mLogger;
|
||||
}
|
||||
|
||||
private static void failWithMsg(String msgFormat, Object... args) {
|
||||
fail(msgFormat == null || args == null ? "" : String.format(msgFormat, args));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user