CursorLoaders の使用に切り替えたばかりで、それらを使用するテストの作成に問題があります。CursorLoader 方法論を使用すると、メイン スレッドのクエリがオフになるためgetInstrumentation().waitForIdleSync()
、アダプターが更新される前に返されます (少なくともこれは私の理論です)。これを回避しようとしているのはすべて私のテストです
public void testUpdateList() throws InvalidRecord, InterruptedException {
ListView listView = frag.getListView();
// Verify list is empty
assertEquals(0, listView.getCount());
// Add transaction directly into database
transTable.addOccurrences(resolver, TestUtils.createMockTrans());
//Don't want to do this but it works.
synchronized (this) {
wait(500);
assertEquals(1, listView.getCount());
}
}
私の質問は、Android テスト フレームワーク内でこの機能をテストするためのより良い方法はありますか?