From 84e550f5e6b286f6f2194d0a01b460df331dae03 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Tue, 17 Mar 2015 17:03:59 -0700 Subject: 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 --- .../tests/res/testApp/MyApplication/build.gradle | 12 ++++---- .../layoutlib/test/myapplication/BuildConfig.class | Bin 775 -> 777 bytes .../test/myapplication/CustomCalendar.class | Bin 0 -> 1174 bytes .../layoutlib/test/myapplication/CustomDate.class | Bin 0 -> 1300 bytes .../layoutlib/test/myapplication/MyActivity.class | Bin 1157 -> 1157 bytes .../layoutlib/test/myapplication/R$attr.class | Bin 406 -> 406 bytes .../layoutlib/test/myapplication/R$dimen.class | Bin 527 -> 527 bytes .../layoutlib/test/myapplication/R$drawable.class | Bin 473 -> 473 bytes .../layoutlib/test/myapplication/R$id.class | Bin 488 -> 488 bytes .../layoutlib/test/myapplication/R$layout.class | Bin 485 -> 515 bytes .../layoutlib/test/myapplication/R$menu.class | Bin 452 -> 452 bytes .../layoutlib/test/myapplication/R$string.class | Bin 538 -> 538 bytes .../layoutlib/test/myapplication/R$style.class | Bin 461 -> 461 bytes .../android/layoutlib/test/myapplication/R.class | Bin 897 -> 897 bytes .../res/testApp/MyApplication/golden/activity.png | Bin 3272 -> 8075 bytes .../gradle/wrapper/gradle-wrapper.properties | 4 +-- .../test/myapplication/ApplicationTest.java | 13 --------- .../test/myapplication/CustomCalendar.java | 31 +++++++++++++++++++++ .../layoutlib/test/myapplication/CustomDate.java | 31 +++++++++++++++++++++ .../MyApplication/src/main/res/layout/layout.xml | 24 ++++++++++------ .../android/layoutlib/bridge/intensive/Main.java | 19 ++++++++----- 21 files changed, 97 insertions(+), 37 deletions(-) create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomCalendar.class create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomDate.class delete mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomCalendar.java create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomDate.java (limited to 'tools') diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle index 80be12d..491dee8 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle @@ -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 { diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class index 2b4f7bf..e29e490 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomCalendar.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomCalendar.class new file mode 100644 index 0000000..4ae0da7 Binary files /dev/null and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomCalendar.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomDate.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomDate.class new file mode 100644 index 0000000..6729eb4 Binary files /dev/null and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/CustomDate.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class index d252462..985d267 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class index 9bab801..5142ca6 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class index 7ad8605..cb52ba5 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class index e9e0a33..5290cf6 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class index d109302..49b1df6 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class index 816ecc8..85b2029 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class index b034b75..428fdf4 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class index f86b1d3..027d5d3 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class index 8bbae90..c7d64f8 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class index 8af745d..8831b71 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png index 943cdf1..e38f437 100644 Binary files a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png and b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png differ diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties index 5de946b..3b51ffe 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java deleted file mode 100644 index 7304af1..0000000 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.android.layoulib.test.myapplication; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomCalendar.java b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomCalendar.java new file mode 100644 index 0000000..80bbaf1 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomCalendar.java @@ -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); + } +} diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomDate.java b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomDate.java new file mode 100644 index 0000000..cb750f4 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/CustomDate.java @@ -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); + } +} diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml index b8ec5661..c1f663e 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml @@ -1,17 +1,25 @@ - - - + - \ No newline at end of file + android:layout_height="wrap_content"/> + + \ No newline at end of file diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java index 96725af..a8c5248 100644 --- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java +++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java @@ -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)); + } } -- cgit v1.1