小编app*_*oll的帖子

PerformException:执行"单击"时出错

我运行android espresso测试时遇到错误:

com.google.android.apps.common.testing.ui.espresso.PerformException:在视图'上执行'单击'时出错,ID为:<2131034173>'.

我的代码很简单:

onView(withId(R.id.btn)).perform(click());
Run Code Online (Sandbox Code Playgroud)

但是这段代码没有错误:

onView(withId(R.id.btn)).check(matches(isDisplayed()));
Run Code Online (Sandbox Code Playgroud)

我找不到它为什么会发生的原因.

android android-espresso

47
推荐指数
5
解决办法
4万
查看次数

Espresso测试通知显示

我想测试一下,当我收到推送时,通知将会出现.也可以检查其属性(如标题,设置意图等).

我怎么能这样做?

 @Before
public void setupTest() {

    mData.putString(PushNotificator.KEY_PUSH_TYPE, PushType.PROJECT_OFFER.toString());
    mData.putString(PushNotificator.KEY_PUSH_OBJECT, pushObjectJsonString);
    mContext = InstrumentationRegistry.getContext();

}

@Test
public void projectOfferCreatedFromBundle() {
    mPushNotificator = new PushNotificator(mContext);
    mPushNotificator.processPush(mData);
    onView(withText("111")).check(matches(withText("111")));  //how to find notification?
}
Run Code Online (Sandbox Code Playgroud)

android android-espresso

7
推荐指数
1
解决办法
5906
查看次数

如何在C中打开文件进行阅读?

当我处理从文件中读取时,有一件事让我在C编程中感到头痛.

我不明白这两种方法的区别:

FILE *fd;
fd=fopen(name,"r");  // "r" for reading from file, "w" for writing to file
                      //"a" to edit the file
Run Code Online (Sandbox Code Playgroud)

如果文件无法打开,fd返回NULL,对吧?

我使用的第二种方法是:

int fd;
fd=open(name,O_RDONLY); 
Run Code Online (Sandbox Code Playgroud)

如果在打开文件时发生错误,fd将为-1.

有人会善意向我解释这个吗?提前致谢:)

c gcc

6
推荐指数
1
解决办法
3997
查看次数

标签 统计

android ×2

android-espresso ×2

c ×1

gcc ×1