-
Notifications
You must be signed in to change notification settings - Fork 7.6k
1.x: Run tests on Android! #3519
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
Closed
artem-zinnatullin
wants to merge
1
commit into
ReactiveX:1.x
from
artem-zinnatullin:run-tests-on-android
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -69,3 +69,6 @@ bin/ | |
# Scala build | ||
*.cache | ||
/.nb-gradle/private/ | ||
|
||
# Android build local properties | ||
local.properties |
This file contains hidden or 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
This file contains hidden or 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,61 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
// Android Gradle plugin | ||
classpath 'com.android.tools.build:gradle:1.3.1' | ||
|
||
// Resolves android-sdk dependencies | ||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
apply plugin: 'android-sdk-manager' | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion '23.0.1' | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' | ||
} | ||
|
||
sourceSets { | ||
androidTest { | ||
java.srcDir '../src/test/java' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies { | ||
compile libraries.rxJava | ||
|
||
androidTestCompile libraries.mockitoCore | ||
androidTestCompile libraries.dexMaker | ||
androidTestCompile libraries.dexMakerDx | ||
androidTestCompile libraries.dexMakerMockito | ||
androidTestCompile libraries.androidSupportTestRunner | ||
} | ||
|
||
afterEvaluate { | ||
tasks.withType(com.android.build.gradle.internal.tasks.AndroidTestTask) { task -> | ||
task.doFirst { | ||
logging.level = LogLevel.INFO | ||
} | ||
task.doLast { | ||
logging.level = LogLevel.LIFECYCLE | ||
} | ||
} | ||
} |
This file contains hidden or 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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="io.reactivex.rxjava.android_tests"> | ||
|
||
</manifest> |
This file contains hidden or 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 |
---|---|---|
@@ -1,32 +1,23 @@ | ||
buildscript { | ||
repositories { jcenter() } | ||
dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.2.3' } | ||
repositories { jcenter() } | ||
dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.2.3' } | ||
} | ||
|
||
description = 'RxJava: Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.' | ||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
apply plugin: 'rxjava-project' | ||
apply plugin: 'java' | ||
|
||
dependencies { | ||
testCompile 'junit:junit-dep:4.10' | ||
testCompile 'org.mockito:mockito-core:1.8.5' | ||
} | ||
|
||
javadoc { | ||
exclude "**/rx/internal/**" | ||
apply plugin: 'rxjava-project' | ||
} | ||
|
||
// support for snapshot/final releases with the various branches RxJava uses | ||
nebulaRelease { | ||
addReleaseBranchPattern(/\d+\.\d+\.\d+/) | ||
addReleaseBranchPattern('HEAD') | ||
} | ||
ext.libraries = [ | ||
rxJava : project(':rxjava'), | ||
|
||
if (project.hasProperty('release.useLastTag')) { | ||
tasks.prepare.enabled = false | ||
} | ||
|
||
test{ | ||
maxHeapSize = "2g" | ||
} | ||
junit : 'junit:junit-dep:4.10', | ||
mockitoCore : 'org.mockito:mockito-core:1.10.19', | ||
dexMaker : 'com.crittercism.dexmaker:dexmaker:1.4', | ||
dexMakerDx : 'com.crittercism.dexmaker:dexmaker-dx:1.4', | ||
dexMakerMockito : 'com.crittercism.dexmaker:dexmaker-mockito:1.4', | ||
androidSupportTestRunner: 'com.android.support.test:runner:0.4' | ||
] |
This file contains hidden or 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,9 @@ | ||
#!/bin/bash | ||
|
||
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
if [ "$TARGET_PLATFORM" == "jdk" ]; then | ||
sh "${SCRIPTS_DIR}/buildViaTravis.sh" | ||
elif [[ "$TARGET_PLATFORM" == android-* ]]; then | ||
sh "${SCRIPTS_DIR}/runTestsOnAndroid.sh" | ||
fi |
This file contains hidden or 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
This file contains hidden or 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,6 @@ | ||
#!/bin/bash | ||
echo no | eval "android create avd --force -n test -t $TARGET_PLATFORM" | ||
emulator -avd test -no-skin -no-audio -no-window & | ||
android-wait-for-emulator | ||
adb shell input keyevent 82 | ||
./gradlew connectedAndroidTest |
This file contains hidden or 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,43 @@ | ||
description = 'RxJava: Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.' | ||
|
||
apply plugin: 'java' | ||
|
||
sourceCompatibility = 1.7 | ||
targetCompatibility = 1.7 | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir '../src/main/java' | ||
} | ||
} | ||
|
||
test { | ||
java { | ||
srcDir '../src/test/java' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
testCompile libraries.junit | ||
testCompile libraries.mockitoCore | ||
} | ||
|
||
javadoc { | ||
exclude '**/rx/internal/**' | ||
} | ||
|
||
// support for snapshot/final releases with the various branches RxJava uses | ||
nebulaRelease { | ||
addReleaseBranchPattern(/\d+\.\d+\.\d+/) | ||
addReleaseBranchPattern('HEAD') | ||
} | ||
|
||
if (project.hasProperty('release.useLastTag')) { | ||
tasks.prepare.enabled = false | ||
} | ||
|
||
test { | ||
maxHeapSize = '2g' | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
rootProject.name='rxjava' | ||
include ':rxjava' | ||
include ':android-tests' |
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -35,6 +35,9 @@ | |
import java.util.List; | ||
import java.util.NoSuchElementException; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
@@ -55,6 +58,7 @@ | |
import rx.functions.Func2; | ||
import rx.observables.ConnectableObservable; | ||
import rx.observers.TestSubscriber; | ||
import rx.schedulers.Schedulers; | ||
import rx.schedulers.TestScheduler; | ||
import rx.subjects.ReplaySubject; | ||
import rx.subjects.Subject; | ||
|
@@ -1101,19 +1105,45 @@ public String call(Integer t1) { | |
} | ||
|
||
@Test | ||
public void testErrorThrownIssue1685() { | ||
public void testErrorThrownIssue1685() throws ExecutionException, InterruptedException { | ||
Subject<Object, Object> subject = ReplaySubject.create(); | ||
|
||
Observable.error(new RuntimeException("oops")) | ||
.materialize() | ||
.delay(1, TimeUnit.SECONDS) | ||
.dematerialize() | ||
.subscribe(subject); | ||
ExecutorService exec = Executors.newSingleThreadExecutor(); | ||
|
||
subject.subscribe(); | ||
subject.materialize().toBlocking().first(); | ||
try { | ||
|
||
final AtomicReference<Throwable> err = new AtomicReference<Throwable>(); | ||
|
||
Scheduler s = Schedulers.from(exec); | ||
exec.submit(new Runnable() { | ||
@Override | ||
public void run() { | ||
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
@Override | ||
public void uncaughtException(Thread t, Throwable e) { | ||
err.set(e); | ||
} | ||
}); | ||
} | ||
}).get(); | ||
|
||
System.out.println("Done"); | ||
Observable.error(new RuntimeException("oops")) | ||
.materialize() | ||
.delay(1, TimeUnit.SECONDS, s) | ||
.dematerialize() | ||
.subscribe(subject); | ||
|
||
subject.subscribe(); | ||
subject.materialize().toBlocking().first(); | ||
|
||
Thread.sleep(1000); // the uncaught exception comes after the terminal event reaches toBlocking | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails for some reason. Maybe the underlying thread dies off? |
||
|
||
assertNotNull("UncaughtExceptionHandler didn't get anything.", err.get()); | ||
|
||
System.out.println("Done"); | ||
} finally { | ||
exec.shutdownNow(); | ||
} | ||
} | ||
|
||
@Test | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed.
.travis.yml
takes care of this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for developers, I guess @akarnokd used it without noticing :)
On Fri, Nov 13, 2015, 07:47 Jake Wharton [email protected] wrote:
@artem_zin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm amazed it even still works.
On Thu, Nov 12, 2015 at 11:51 PM Artem Zinnatullin [email protected]
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, would be nice to see new releases! Sometimes it can not handle
support libraries updates. But anyway, great tool.
On Fri, Nov 13, 2015, 07:52 Jake Wharton [email protected] wrote:
@artem_zin