我对 Android 很陌生,正在使用 Robotium 编写一些基本的 Android 测试,但失败并出现异常
"android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views."
以下是基本的测试用例描述:-
测试用例:-
public void testSearch() {
Activity a = getActivity();
SearchItemActivity search = new SearchItemActivity(solo);
search.searchText("ipod", a);
}
SearchItemActivity.searchText(String) is defined as
public void searchText(final String search, Activity act) {
Button v = (Button) act
.findViewById(com.test.mobile.R.id.text_search_field);
((Button) v).setText("");
((Button) v).setText(search);
solo.sendKey(Solo.ENTER);
solo.waitForActivity("FoundItemdDetailActivity");
solo.assertCurrentActivity("Expected FoundItemDetail activity","FoundItemdDetailActivity");
}
任何我如何修改我的代码的建议都将不胜感激