Skip to content

Commit

Permalink
Prepare release 4.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovgs committed Apr 23, 2020
1 parent 6a3b698 commit c8f1f32
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Setup the Gradle plugin:
// ...
dependencies {
// ...
classpath 'com.karumi:shot:4.0.0'
classpath 'com.karumi:shot:4.1.1'
}
}
apply plugin: 'shot'
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/com/karumi/shot/domain/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Config {
val androidDependencyMode: FilePath = "androidTestImplementation"
val androidDependencyGroup: String = "com.karumi"
val androidDependencyName: String = "shot-android"
val androidDependencyVersion: String = "4.1.1-SNAPSHOT"
val androidDependencyVersion: String = "4.1.1"
val androidDependency: FilePath =
s"$androidDependencyGroup:$androidDependencyName:$androidDependencyVersion"
def screenshotsFolderName(flavor: String, buildType: String): FilePath =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.scalatest.{FlatSpec, Matchers}
class ConfigSpec extends FlatSpec with Matchers {

"Config" should "use the screenshot tests library implemented by Facebook" in {
Config.androidDependency shouldBe "com.karumi:shot-android:4.1.1-SNAPSHOT"
Config.androidDependency shouldBe "com.karumi:shot-android:4.1.1"
}

it should "add the dependency using the androidTestImplementation mode" in {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=4.1.1-SNAPSHOT
VERSION_NAME=4.1.1
VERSION_CODE=400101
GROUP=com.karumi
POM_DESCRIPTION=Gradle plugin developed to facilitate screenshot testing for Android.
Expand Down
32 changes: 26 additions & 6 deletions shot-android/src/main/java/com/karumi/shot/ScreenshotTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.util.DisplayMetrics
import android.util.Log
import android.view.View
import android.view.WindowManager
import android.widget.EditText
Expand Down Expand Up @@ -39,7 +40,7 @@ interface ScreenshotTest {

if (heightInPx == null && widthInPx == null) {
disableFlakyComponentsAndWaitForIdle(view)
snapActivity(activity).record()
takeActivitySnapshot(activity)
} else {
runOnUi {
view.setBackgroundResource(backgroundColor)
Expand Down Expand Up @@ -86,11 +87,7 @@ interface ScreenshotTest {
.setExactWidthPx(width)
.layout()
}
val testName = name ?: TestNameDetector.getTestName()
Screenshot
.snap(view)
.setName("${TestNameDetector.getTestClass()}_$testName")
.record()
takeViewSnapshot(name, view)
}

fun disableFlakyComponentsAndWaitForIdle(view: View) {
Expand All @@ -108,6 +105,29 @@ interface ScreenshotTest {
getInstrumentation().runOnMainSync { block() }
}

private fun takeViewSnapshot(name: String?, view: View) {
val testName = name ?: TestNameDetector.getTestName()
val snapshotName = "${TestNameDetector.getTestClass()}_$testName"
try {
Screenshot
.snap(view)
.setName(snapshotName)
.record()
} catch (t: Throwable) {
Log.e("Shot", "Exception captured while taking screenshot for snapshot with name $snapshotName", t)
}
}

private fun takeActivitySnapshot(activity: Activity) {
val testName = TestNameDetector.getTestName()
val snapshotName = "${TestNameDetector.getTestClass()}_$testName"
try {
snapActivity(activity).record()
} catch (t: Throwable) {
Log.e("Shot", "Exception captured while taking screenshot for snapshot with name $snapshotName", t)
}
}

private fun disableAnimatedComponents(view: View) {
runOnUi {
hideEditTextCursors(view)
Expand Down
2 changes: 1 addition & 1 deletion shot-consumer-flavors/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath "com.neenbedankt.gradle.plugins:android-apt:1.7"
classpath "com.karumi:shot:4.1.1-SNAPSHOT"
classpath "com.karumi:shot:4.1.1"
classpath "com.github.trevjonez.composer-gradle-plugin:plugin:0.12.0"
}
}
Expand Down
2 changes: 1 addition & 1 deletion shot-consumer/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath "com.neenbedankt.gradle.plugins:android-apt:1.7"
classpath "com.karumi:shot:4.1.1-SNAPSHOT"
classpath "com.karumi:shot:4.1.1"
classpath "com.github.trevjonez.composer-gradle-plugin:plugin:0.12.0"
}
}
Expand Down
2 changes: 1 addition & 1 deletion shot-consumer/app2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath "com.neenbedankt.gradle.plugins:android-apt:1.7"
classpath "com.karumi:shot:4.1.1-SNAPSHOT"
classpath "com.karumi:shot:4.1.1"
classpath "com.github.trevjonez.composer-gradle-plugin:plugin:0.12.0"
}
}
Expand Down
2 changes: 1 addition & 1 deletion shot-consumer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.karumi:shot:4.1.1-SNAPSHOT'
classpath 'com.karumi:shot:4.1.1'
}
}

Expand Down
8 changes: 3 additions & 5 deletions shot/src/main/scala/com/karumi/shot/ShotPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ class ShotPlugin extends Plugin[Project] {
project.getConfigurations.forEach(config => {
shotAndroidDependencyHasBeenAdded |= config.getAllDependencies
.toArray(new Array[Dependency](0))
.exists(
dependency =>
Config.androidDependencyGroup == dependency.getGroup
&& Config.androidDependencyName == dependency.getName
&& Config.androidDependencyVersion == dependency.getVersion)
.exists(dependency =>
Config.androidDependencyGroup == dependency.getGroup
&& Config.androidDependencyName == dependency.getName)
})

if (!shotAndroidDependencyHasBeenAdded) {
Expand Down

0 comments on commit c8f1f32

Please sign in to comment.