diff --git a/build.gradle b/build.gradle index 8b5191c..fb3ca6f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' } @@ -14,6 +15,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } @@ -23,7 +25,7 @@ ext { minSdkVersion = 10 compileSdkVersion = 24 targetSdkVersion = compileSdkVersion - buildToolsVersion = '25.0.2' + buildToolsVersion = '26.0.2' sourceCompatibility = JavaVersion.VERSION_1_7 } diff --git a/falcon-sample/build.gradle b/falcon-sample/build.gradle index a812816..46aa8c9 100644 --- a/falcon-sample/build.gradle +++ b/falcon-sample/build.gradle @@ -6,12 +6,10 @@ buildscript { } dependencies { - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } apply plugin: 'com.android.application' -apply plugin: 'com.neenbedankt.android-apt' android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -59,20 +57,20 @@ android { } dependencies { - compile project(':falcon') + implementation project(':falcon') - compile 'com.android.support:appcompat-v7:24.1.1' - compile 'com.android.support:design:24.1.1' - compile 'com.jakewharton:butterknife:8.2.1' - apt 'com.jakewharton:butterknife-compiler:8.2.1' + implementation 'com.android.support:appcompat-v7:24.1.1' + implementation 'com.android.support:design:24.1.1' + implementation 'com.jakewharton:butterknife:8.2.1' + annotationProcessor 'com.jakewharton:butterknife-compiler:8.2.1' - androidTestCompile project(':falcon-spoon-compat') - androidTestCompile 'org.assertj:assertj-core:1.7.1' - androidTestCompile 'com.android.support.test:runner:0.5' - androidTestCompile 'com.android.support.test:rules:0.5' - androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' + androidTestImplementation project(':falcon-spoon-compat') + androidTestImplementation 'org.assertj:assertj-core:1.7.1' + androidTestImplementation 'com.android.support.test:runner:0.5' + androidTestImplementation 'com.android.support.test:rules:0.5' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2' // separately set because of test runners older dependencies - androidTestCompile 'com.android.support:support-annotations:24.1.1' + androidTestImplementation 'com.android.support:support-annotations:24.1.1' } diff --git a/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/EspressoSpoonTest.java b/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/EspressoSpoonTest.java index 786c573..334e4b5 100644 --- a/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/EspressoSpoonTest.java +++ b/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/EspressoSpoonTest.java @@ -2,7 +2,8 @@ import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import com.jraska.falcon.FalconSpoon; +import com.jraska.falcon.FalconSpoonRule; + import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -33,6 +34,9 @@ public class EspressoSpoonTest { public ActivityTestRule _activityRule = new ActivityTestRule<>( SampleActivity.class); + @Rule + public final FalconSpoonRule _falconSpoonRule = new FalconSpoonRule(); + private List takenScreenshots = new ArrayList<>(); //endregion @@ -59,13 +63,13 @@ public void after() throws Exception { public void dialogTakenInScreenshot() throws Exception { SampleActivity activity = _activityRule.getActivity(); - File screenshotWithoutDialogFile = FalconSpoon.screenshot(activity, "No_dialog"); + File screenshotWithoutDialogFile = _falconSpoonRule.screenshot(activity, "No_dialog"); takenScreenshots.add(screenshotWithoutDialogFile); onView(withId(R.id.show_dialog)).perform(click()); onView(withText("Screenshot")).check(matches(isDisplayed())); - File screenshotWithDialogFile = FalconSpoon.screenshot(activity, "Dialog_test"); + File screenshotWithDialogFile = _falconSpoonRule.screenshot(activity, "Dialog_test"); takenScreenshots.add(screenshotWithDialogFile); assertThatFile(screenshotWithDialogFile).isDarkerThan(screenshotWithoutDialogFile); diff --git a/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/FalconSpoonTest.java b/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/FalconSpoonTest.java index 11ecee8..3372150 100644 --- a/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/FalconSpoonTest.java +++ b/falcon-sample/src/androidTest/java/com/jraska/falcon/sample/FalconSpoonTest.java @@ -2,7 +2,9 @@ import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import com.jraska.falcon.FalconSpoon; + +import com.jraska.falcon.FalconSpoonRule; + import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -16,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Shows usage of {@link FalconSpoon} compat screenshots + * Shows usage of {@link FalconSpoonRule} compat screenshots */ @RunWith(AndroidJUnit4.class) public class FalconSpoonTest { @@ -27,6 +29,9 @@ public class FalconSpoonTest { public ActivityTestRule _activityRule = new ActivityTestRule<>( SampleActivity.class); + @Rule + public final FalconSpoonRule _falconSpoonRule = new FalconSpoonRule(); + private File _screenshotFile; //endregion @@ -52,18 +57,7 @@ public void after() throws Exception { @Test public void takesScreenshotToFile() throws Exception { String tag = "ExampleScreenshot"; - _screenshotFile = FalconSpoon.screenshot(_activityRule.getActivity(), tag); - - assertThat(_screenshotFile.length()).isGreaterThan(0L); - assertThatFile(_screenshotFile).isBitmap(); - } - - @Test - public void takesScreenshotToBitmap() throws Exception { - String tag = "ExampleScreenshot"; - - _screenshotFile = FalconSpoon.screenshot(_activityRule.getActivity(), tag, - "FalconSpoonTest", "CustomMethodName"); + _screenshotFile = _falconSpoonRule.screenshot(_activityRule.getActivity(), tag); assertThat(_screenshotFile.length()).isGreaterThan(0L); assertThatFile(_screenshotFile).isBitmap(); diff --git a/falcon-spoon-compat/build.gradle b/falcon-spoon-compat/build.gradle index 7f277c3..13d90d2 100644 --- a/falcon-spoon-compat/build.gradle +++ b/falcon-spoon-compat/build.gradle @@ -25,8 +25,9 @@ android { } dependencies { - compile project(':falcon') - compile 'com.squareup.spoon:spoon-client:1.7.0' + implementation 'com.android.support.test:rules:0.5' + implementation project(':falcon') + api project(':spoon-client') } ext { diff --git a/falcon-spoon-compat/src/main/java/com/jraska/falcon/FalconSpoon.java b/falcon-spoon-compat/src/main/java/com/jraska/falcon/FalconSpoon.java deleted file mode 100644 index a5f747e..0000000 --- a/falcon-spoon-compat/src/main/java/com/jraska/falcon/FalconSpoon.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jraska.falcon; - -import android.app.Activity; -import com.squareup.spoon.Spoon; - -import java.io.File; - -/** - * Utility class which simply uses Spoon API to obtain desired file - * and then write there Falcon screenshot - */ -public final class FalconSpoon { - //region Public API - - public static File screenshot(Activity activity, String tag) { - File screenshot = Spoon.screenshot(activity, tag); - - // File will be overwritten with new screenshot - Falcon.takeScreenshot(activity, screenshot); - - return screenshot; - } - - public static File screenshot(Activity activity, String tag, String testClassName, - String testMethodName) { - File screenshot = Spoon.screenshot(activity, tag, testClassName, testMethodName); - - // File will be overwritten with new screenshot - Falcon.takeScreenshot(activity, screenshot); - - return screenshot; - } - - //endregion - - //region Constructors - - private FalconSpoon() { - // No instances - } - - //endregion -} diff --git a/falcon-spoon-compat/src/main/java/com/jraska/falcon/FalconSpoonRule.java b/falcon-spoon-compat/src/main/java/com/jraska/falcon/FalconSpoonRule.java new file mode 100644 index 0000000..df82e53 --- /dev/null +++ b/falcon-spoon-compat/src/main/java/com/jraska/falcon/FalconSpoonRule.java @@ -0,0 +1,56 @@ +package com.jraska.falcon; + +import android.app.Activity; +import android.content.Context; + +import com.squareup.spoon.SpoonRule; + +import org.junit.Rule; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.io.File; + +/** + * Utility class which simply uses Spoon API to obtain desired file + * and then write there Falcon screenshot + */ +public final class FalconSpoonRule implements TestRule { + + //region Fields + + @Rule + private final SpoonRule spoonRule = new SpoonRule(); + + //endregion + + //region Public API + @Override + public Statement apply(Statement base, Description description) { + return spoonRule.apply(base, description); + } + + public File save(Context context, File file) { + return spoonRule.save(context, file); + } + + public File screenshot(Activity activity, String tag) { + File screenshot = spoonRule.screenshot(activity, tag); + + // File will be overwritten with new screenshot + Falcon.takeScreenshot(activity, screenshot); + + return screenshot; + } + + //endregion + + //region Constructors + + public FalconSpoonRule() { + // empty constructor, just like SpoonRule + } + + //endregion +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b2f0733..d2bcc69 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Feb 06 19:21:08 SGT 2017 +#Tue Dec 05 16:54:52 CET 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/settings.gradle b/settings.gradle index 54a0d15..dff07a2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':falcon-sample', ':falcon', ':falcon-spoon-compat' +include ':falcon-sample', ':falcon', ':falcon-spoon-compat', ':spoon-client' diff --git a/spoon-client/build.gradle b/spoon-client/build.gradle new file mode 100644 index 0000000..7145a36 --- /dev/null +++ b/spoon-client/build.gradle @@ -0,0 +1,2 @@ +configurations.maybeCreate("default") +artifacts.add("default", file('spoon-client-2.0.0-20171128.164926-39.aar')) \ No newline at end of file diff --git a/spoon-client/spoon-client-2.0.0-20171128.164926-39.aar b/spoon-client/spoon-client-2.0.0-20171128.164926-39.aar new file mode 100644 index 0000000..35dd408 Binary files /dev/null and b/spoon-client/spoon-client-2.0.0-20171128.164926-39.aar differ