Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Added integration test and travis config
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Oct 20, 2017
1 parent 9c54fd7 commit 5001741
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
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
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
plugins {
id 'com.gradle.plugin-publish' version '0.9.8'
id 'java-gradle-plugin'
}

repositories {
mavenCentral()
}

apply plugin: 'groovy'
apply plugin: 'java-gradle-plugin'

dependencies {
compile gradleApi()
compile localGroovy()

testCompile gradleTestKit()
testCompile 'junit:junit:4.12'
testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude module: 'groovy-all'
}
}


group = 'com.onesignal'
version = '0.5.0'
description 'OneSignal Gradle Plugin'
Expand All @@ -30,6 +39,17 @@ pluginBundle {
}
}

gradlePlugin {
pluginSourceSet project.sourceSets.main
testSourceSets project.sourceSets.test
plugins {
plugin {
id = 'com.onesignal.androidsdk.onesignal-gradle-plugin'
implementationClass = 'com.onesignal.androidsdk.GradleProjectPlugin'
}
}
}


// Build for Local Testing
apply plugin: 'maven'
Expand Down
130 changes: 130 additions & 0 deletions src/test/groovy/com/onesignal/androidsdk/MainTest.groovy
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')
}

}

0 comments on commit 5001741

Please sign in to comment.