Uh oh!
There was an error while loading. Please reload this page.
- 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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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 | ||
| } | ||
| } | ||
| } | ||
| 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> |
| 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' | ||
| ] |
| 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 |
| 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 |
| 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' | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| rootProject.name='rxjava' | ||
| include ':rxjava' | ||
| include ':android-tests' |
| 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 | ||
Member 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 | ||
Uh oh!
There was an error while loading. Please reload this page.
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.ymltakes 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 notifications@github.com 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 notifications@github.com
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 notifications@github.com wrote:
@artem_zin