This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added integration test and travis config
- Loading branch information
Showing
3 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: android | ||
sudo: false | ||
jdk: oraclejdk8 | ||
|
||
android: | ||
components: | ||
- tools | ||
- tools # Include again to work around travis not using the latest. | ||
# https://github.com/travis-ci/travis-ci/issues/6193 | ||
# Required to get the newest platform-tools. | ||
- platform-tools | ||
- build-tools-26.0.1 | ||
- android-26 | ||
licenses: | ||
- '.+' | ||
before_script: | ||
- chmod +x gradlew | ||
script: | ||
- ./gradlew build | ||
after_failure: | ||
- cat build/reports/lint-results.xml | ||
- cat build/outputs/lint-results-debug.xml | ||
- cd ../.. | ||
- pwd | ||
- ls -la $HOME | ||
- ls -la $HOME/android-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
src/test/groovy/com/onesignal/androidsdk/MainTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import spock.lang.Specification | ||
import org.junit.Rule | ||
import org.junit.rules.TemporaryFolder | ||
|
||
import org.gradle.testkit.runner.GradleRunner | ||
|
||
class MainTest extends Specification { | ||
|
||
@Rule final TemporaryFolder testProjectDir = new TemporaryFolder() | ||
File buildFile | ||
List<File> pluginClasspath | ||
|
||
def setup() { | ||
buildFile = testProjectDir.newFile('build.gradle') | ||
} | ||
|
||
def createBuildFile(compileVersion, compileLines) { | ||
def gradleProps = testProjectDir.newFile('gradle.properties') | ||
gradleProps <<'''\ | ||
android.enableAapt2=false | ||
'''.stripIndent() | ||
|
||
testProjectDir.newFolder("src", "main") | ||
def androidManifest = testProjectDir.newFile('src/main/AndroidManifest.xml') | ||
androidManifest << '''\ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.app.example"> | ||
</manifest> | ||
'''.stripIndent() | ||
|
||
buildFile << """\ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
maven { url 'https://maven.google.com' } | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.0.0-beta6' | ||
} | ||
} | ||
plugins { | ||
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' | ||
} | ||
allprojects { | ||
repositories { | ||
jcenter() | ||
maven { url 'https://maven.google.com' } | ||
} | ||
} | ||
apply plugin: 'com.android.application' | ||
android { | ||
compileSdkVersion ${compileVersion} | ||
buildToolsVersion '26.0.1' | ||
defaultConfig { | ||
applicationId 'com.app.example' | ||
minSdkVersion 15 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
} | ||
dependencies { | ||
${compileLines} | ||
} | ||
"""\ | ||
} | ||
|
||
def runGradleProject() { | ||
return GradleRunner.create() | ||
.withProjectDir(testProjectDir.root) | ||
.withArguments('dependencies', '--configuration', 'compile') | ||
.withPluginClasspath() | ||
.build() | ||
} | ||
|
||
def "Aligns support library"() { | ||
def compileLines = """\ | ||
compile 'com.android.support:appcompat-v7:25.0.0' | ||
compile 'com.android.support:support-v4:26.0.0' | ||
""" | ||
|
||
createBuildFile(26, compileLines) | ||
|
||
when: | ||
def result = runGradleProject() | ||
|
||
then: | ||
result.output.contains('+--- com.android.support:appcompat-v7:25.0.0 -> 26.1.0') | ||
} | ||
|
||
def "Uses support library 25 when compileSdkVersion is 25"() { | ||
def compileLines = """\ | ||
compile 'com.android.support:support-v4:26.0.0' | ||
""" | ||
|
||
createBuildFile(25, compileLines) | ||
|
||
when: | ||
def result = runGradleProject() | ||
|
||
then: | ||
result.output.contains('\\--- com.android.support:support-v4:26.0.0 -> 25.4.0') | ||
} | ||
|
||
def "Aligns gms and firebase"() { | ||
def compileLines = """\ | ||
compile 'com.google.firebase:firebase-core:11.0.0' | ||
compile 'com.google.android.gms:play-services-gcm:11.2.0' | ||
compile 'com.google.android.gms:play-services-location:11.4.0' | ||
""" | ||
|
||
createBuildFile(26, compileLines) | ||
|
||
when: | ||
def result = runGradleProject() | ||
|
||
then: | ||
result.output.contains('+--- com.google.firebase:firebase-core:11.0.0 -> 11.4.2') | ||
result.output.contains('+--- com.google.android.gms:play-services-gcm:11.2.0 -> 11.4.2') | ||
result.output.contains('+--- com.google.android.gms:play-services-gcm:11.2.0 -> 11.4.2') | ||
} | ||
|
||
} |