我运行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)
我找不到它为什么会发生的原因.
我想测试一下,当我收到推送时,通知将会出现.也可以检查其属性(如标题,设置意图等).
我怎么能这样做?
@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) 当我处理从文件中读取时,有一件事让我在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.
有人会善意向我解释这个吗?提前致谢:)