Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spoon snapshot #25

Merged
merged 3 commits into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand All @@ -14,6 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand All @@ -23,7 +25,7 @@ ext {
minSdkVersion = 10
compileSdkVersion = 24
targetSdkVersion = compileSdkVersion
buildToolsVersion = '25.0.2'
buildToolsVersion = '26.0.2'
sourceCompatibility = JavaVersion.VERSION_1_7
}

Expand Down
24 changes: 11 additions & 13 deletions falcon-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,6 +34,9 @@ public class EspressoSpoonTest {
public ActivityTestRule<SampleActivity> _activityRule = new ActivityTestRule<>(
SampleActivity.class);

@Rule
public final FalconSpoonRule _falconSpoonRule = new FalconSpoonRule();

private List<File> takenScreenshots = new ArrayList<>();

//endregion
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -27,6 +29,9 @@ public class FalconSpoonTest {
public ActivityTestRule<SampleActivity> _activityRule = new ActivityTestRule<>(
SampleActivity.class);

@Rule
public final FalconSpoonRule _falconSpoonRule = new FalconSpoonRule();

private File _screenshotFile;

//endregion
Expand All @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions falcon-spoon-compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':falcon-sample', ':falcon', ':falcon-spoon-compat'
include ':falcon-sample', ':falcon', ':falcon-spoon-compat', ':spoon-client'
2 changes: 2 additions & 0 deletions spoon-client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
configurations.maybeCreate("default")
artifacts.add("default", file('spoon-client-2.0.0-20171128.164926-39.aar'))
Binary file not shown.