小编ele*_*ven的帖子

Espresso - 如何检查是否显示其中一个视图

在我的测试中,在一次操作之后,有两种可能的视图可以出现并且它们都是正确的.如何检查是否显示其中一个视图.对于我可以检查的单个视图是Displayed().但如果其他视图可见则会失败.如果显示这两个视图中的任何一个,我想通过测试.

onMyButton.perform(click());

onMyPageOne.check(matches(isDisplayed())); //view 1
or
onMyPageTwo.check(matches(isDisplayed())); //view 2
Run Code Online (Sandbox Code Playgroud)

之后,执行单击MyButton,预计会出现任何一个视图(1或2),但不会同时出现.不确定哪一个会被显示.如何检查是否显示其中任何一个?

java listview android-testing android-espresso

50
推荐指数
7
解决办法
5万
查看次数

Gradle无法解析otto库

我尝试嵌入位于Maven Central的Otto库.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.3'

    }
}

apply plugin: 'android'

dependencies {
    compile 'com.google.android.gms:play-services:4.0.30'
    compile 'com.android.support:support-v13:19.0.0'
    compile 'com.squareup:otto:1.3.4'
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了例外:

A problem occurred configuring root project 'sample-project'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':_DebugCompile'.
      > Could not find com.squareup:otto:otto:1.3.4.
        Required by:
            :sample-project:unspecified
Run Code Online (Sandbox Code Playgroud)

我试图刷新依赖项(gradle --refresh-dependencies)但它没有帮助.

dependencies android repository gradle maven-central

3
推荐指数
1
解决办法
1464
查看次数

使用Scheduler时,System.out.println在RxJava中不打印任何内容

我正在摆弄RxJava和Schedulers.我使用调度程序实现了一个非常简单的流:

Observable.just(1, 2, 3)
      .doOnNext(v -> Thread.currentThread().getName())
      .subscribeOn(Schedulers.newThread())
      .subscribe(v -> System.out.println(v));
Run Code Online (Sandbox Code Playgroud)

上面的示例在控制台中不打印任何内容.

我注意到,当我使用Thread.sleep()阻塞主线程时,System.out.println会输出正确的值 - 1 2 3:

Observable.just(1, 2, 3)
        .doOnNext(v -> Thread.currentThread().getName())
        .subscribeOn(Schedulers.newThread())
        .subscribe(v -> System.out.println(v));

        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

有人能帮我理解这种行为吗?

java multithreading scheduler rx-java

2
推荐指数
1
解决办法
551
查看次数