Skip to content

Commit b4041fd

Browse files
author
Daniel Jette
committed
Create Ext module
1 parent 63929ce commit b4041fd

9 files changed

Lines changed: 305 additions & 0 deletions

File tree

Ext/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Ext/bintray.build.gradle

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
ext {
2+
pom = [
3+
publishedGroupId : 'com.shopify.testify',
4+
artifact : 'testify',
5+
libraryName : 'testify',
6+
libraryDescription: 'Android screenshot instrumentation tests.',
7+
siteUrl : 'https://github.com/Shopify/android-testify',
8+
gitUrl : 'https://github.com/Shopify/android-testify.git',
9+
licenseName : 'The MIT License',
10+
licenseUrl : 'https://opensource.org/licenses/MIT'
11+
]
12+
}
13+
14+
group = pom.publishedGroupId
15+
16+
install {
17+
repositories.mavenInstaller {
18+
pom {
19+
project {
20+
packaging 'aar'
21+
groupId project.ext.pom.publishedGroupId
22+
artifactId project.ext.pom.artifact
23+
name project.ext.pom.libraryName
24+
description project.ext.pom.libraryDescription
25+
url project.ext.pom.siteUrl
26+
licenses {
27+
license {
28+
name project.ext.pom.licenseName
29+
url project.ext.pom.licenseUrl
30+
}
31+
}
32+
scm {
33+
connection project.ext.pom.gitUrl
34+
developerConnection project.ext.pom.gitUrl
35+
url project.ext.pom.siteUrl
36+
}
37+
}
38+
}
39+
}
40+
}
41+
42+
dokka {
43+
outputFormat = "html"
44+
outputDirectory = "$buildDir/javadoc"
45+
46+
configuration {
47+
includeNonPublic = false
48+
reportUndocumented = false
49+
}
50+
}
51+
52+
task javadocJar(type: Jar, dependsOn: dokka) {
53+
classifier = 'javadoc'
54+
baseName = 'testify'
55+
from dokka.outputDirectory
56+
}
57+
58+
task sourcesJar(type: Jar) {
59+
from android.sourceSets.main.java.srcDirs
60+
classifier = 'sources'
61+
}
62+
63+
ext {
64+
bintray = [
65+
org : 'shopify',
66+
repo : 'shopify-android',
67+
name : 'testify',
68+
allLicenses: ["MIT"]
69+
]
70+
}
71+
72+
artifacts {
73+
archives javadocJar
74+
archives sourcesJar
75+
}
76+
77+
bintray {
78+
// These values can be found on https://bintray.com/profile/edit
79+
user = System.getenv('BINTRAY_USER')
80+
// BINTRAY_USER : your personal profile name (from "Your Profile")
81+
key = System.getenv('BINTRAY_KEY') // BINTRAY_KEY : found on the left menu, under "API Key"
82+
83+
configurations = ['archives']
84+
85+
pkg {
86+
userOrg = project.ext.bintray.org
87+
repo = project.ext.bintray.repo
88+
name = project.ext.bintray.name
89+
desc = project.ext.pom.libraryDescription
90+
websiteUrl = project.ext.pom.siteUrl
91+
vcsUrl = project.ext.pom.gitUrl
92+
licenses = project.ext.bintray.allLicenses
93+
publish = true
94+
publicDownloadNumbers = true
95+
version {
96+
desc = project.ext.pom.libraryDescription
97+
}
98+
}
99+
}
100+
101+
bintrayUpload {
102+
dependsOn install
103+
doFirst {
104+
if (System.getenv('BINTRAY_USER').isEmpty()) {
105+
throw new IllegalArgumentException("BINTRAY_USER must be defined")
106+
}
107+
if (System.getenv('BINTRAY_KEY').isEmpty()) {
108+
throw new IllegalArgumentException("BINTRAY_KEY must be defined")
109+
}
110+
}
111+
}

Ext/build.gradle

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'kotlin-android'
4+
id 'com.github.dcendents.android-maven'
5+
id 'com.jfrog.bintray'
6+
id 'org.jetbrains.dokka'
7+
}
8+
9+
def VERSION_NAME = "$project.versions.testify"
10+
11+
version = VERSION_NAME
12+
13+
android {
14+
compileSdkVersion coreVersions.compileSdk
15+
16+
lintOptions {
17+
abortOnError true
18+
warningsAsErrors true
19+
textOutput 'stdout'
20+
textReport true
21+
xmlReport false
22+
}
23+
24+
defaultConfig {
25+
minSdkVersion coreVersions.minSdk
26+
targetSdkVersion coreVersions.targetSdk
27+
versionCode 1
28+
versionName VERSION_NAME
29+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
30+
31+
kotlinOptions {
32+
allWarningsAsErrors = true
33+
}
34+
}
35+
36+
libraryVariants.all { variant ->
37+
variant.outputs.all {
38+
outputFileName = "${archivesBaseName}-${version}.aar"
39+
}
40+
}
41+
42+
testOptions {
43+
unitTests.returnDefaultValues = true
44+
unitTests.all {
45+
testLogging {
46+
events "passed", "skipped", "failed", "standardOut", "standardError"
47+
outputs.upToDateWhen { false }
48+
showStandardStreams = true
49+
}
50+
}
51+
}
52+
53+
dependencies {
54+
implementation project(":Library")
55+
implementation "androidx.appcompat:appcompat:${versions.androidx.appCompat}"
56+
implementation "androidx.test.espresso:espresso-core:${versions.androidx.test.espresso}"
57+
implementation "androidx.test:rules:${versions.androidx.test.rules}"
58+
implementation "androidx.test:runner:${versions.androidx.test.runner}"
59+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
60+
// implementation "com.github.ajalt:colormath:${versions.colormath}"
61+
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3") {
62+
// exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
63+
// exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
64+
// exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
65+
// exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
66+
// }
67+
//
68+
// testImplementation "org.mockito:mockito-core:${versions.mockito2}"
69+
// testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:${versions.mockitokotlin}"
70+
//
71+
// androidTestImplementation "androidx.test.ext:junit:${versions.androidx.test.junit}"
72+
// androidTestImplementation "androidx.test:runner:${versions.androidx.test.runner}"
73+
// androidTestImplementation "androidx.test:rules:${versions.androidx.test.rules}"
74+
// androidTestImplementation "androidx.test.espresso:espresso-core:${versions.androidx.test.espresso}"
75+
// androidTestImplementation "androidx.test.espresso:espresso-contrib:${versions.androidx.test.espresso}"
76+
// androidTestImplementation "com.google.android.material:material:${versions.material}"
77+
// androidTestImplementation "androidx.appcompat:appcompat:${versions.androidx.appCompat}"
78+
}
79+
}
80+
81+
apply from: "bintray.build.gradle"
82+
apply from: '../ktlint.gradle'

Ext/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/opt/android-sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}

Ext/src/main/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.shopify.testify.ext">
4+
5+
<application >
6+
<activity android:name=".TestHarnessActivity" />
7+
</application>
8+
9+
</manifest>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 Shopify Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
package com.shopify.testify.ext
25+
26+
import android.graphics.Color
27+
import android.os.Bundle
28+
import android.view.View
29+
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
30+
import android.widget.FrameLayout
31+
import androidx.annotation.VisibleForTesting
32+
import androidx.appcompat.app.AppCompatActivity
33+
import androidx.test.rule.ActivityTestRule
34+
import com.shopify.testify.ScreenshotRule
35+
36+
/**
37+
* The TestHarnessActivity is used as scaffolding for testing arbitrary views.
38+
* Testify's [ScreenshotRule] is a subclass of [ActivityTestRule] which means that an Activity
39+
* is required to "host" a UI that you wish to capture in your screenshot.
40+
* This empty activity can be used as a generic container for testing your custom [View] classes.
41+
*/
42+
@VisibleForTesting
43+
open class TestHarnessActivity : AppCompatActivity() {
44+
45+
override fun onCreate(savedInstanceState: Bundle?) {
46+
super.onCreate(savedInstanceState)
47+
48+
setContentView(FrameLayout(this).apply {
49+
layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
50+
setBackgroundColor(Color.WHITE)
51+
id = R.id.harness_root
52+
})
53+
}
54+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021 Shopify Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.shopify.testify.ext
26+

Ext/src/main/res/values/ids.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<item name="harness_root" type="id" />
4+
</resources>

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include ':Sample'
22
include ':Plugin'
33
include ':Library'
4+
include ':Ext'
45

56
project(':Plugin').projectDir = new File("./Plugins/Gradle")

0 commit comments

Comments
 (0)