/**
* Tests performance of {@link com.db.oliviergoutay.greendao_vs_realm.realm.RealmDailyMealManager#updateDatabase(Context, List)}
*/
@MediumTest
public void testUpdateDatabaseListPerformance() throws InterruptedException {
List<DailyMealRealm> mList = new ArrayList<>();
Date date = new Date();
for (int i = 0; i < 365; i++) {
mList.add(getMockDailyMealForDate(date));
date = getYesterday(date);
}
CountDownLatch countDownLatch = new CountDownLatch(1);
realmDailyMealManager.setTestCountDownLatch(countDownLatch);
long start = System.currentTimeMillis();
realmDailyMealManager.updateDatabase(mContext, mList);
countDownLatch.await();
long end = System.currentTimeMillis();
Log.i(TAG, "Mass insert of 365 DailyMealRealm took : " + (end - start) + " milliseconds");
//Check time is less than 3000 millis
assertTrue(3000 > end - start);
//Check all were inserted
assertEquals(365, DbApp.getRealm().where(DailyMealRealm.class).count());
assertEquals(365 * 4, DbApp.getRealm().where(MealRealm.class).count());
assertEquals(365 * 3, DbApp.getRealm().where(MealItemRealm.class).count());
}
java类android.test.suitebuilder.annotation.MediumTest的实例源码
RealmPerformanceTest.java 文件源码
项目:GreenDao-vs-Realm
阅读 22
收藏 0
点赞 0
评论 0
DatabaseGeneralTest.java 文件源码
项目:sqlite-android
阅读 23
收藏 0
点赞 0
评论 0
@MediumTest
public void testUnionsWithBindArgs() {
/* make sure unions with bindargs work http://b/issue?id=1061291 */
mDatabase.execSQL("CREATE TABLE A (i int);");
mDatabase.execSQL("create table B (k int);");
mDatabase.execSQL("create table C (n int);");
mDatabase.execSQL("insert into A values(1);");
mDatabase.execSQL("insert into A values(2);");
mDatabase.execSQL("insert into A values(3);");
mDatabase.execSQL("insert into B values(201);");
mDatabase.execSQL("insert into B values(202);");
mDatabase.execSQL("insert into B values(203);");
mDatabase.execSQL("insert into C values(901);");
mDatabase.execSQL("insert into C values(902);");
String s = "select i from A where i > 2 " +
"UNION select k from B where k > 201 " +
"UNION select n from C where n !=900;";
Cursor c = mDatabase.rawQuery(s, null);
int n = c.getCount();
c.close();
String s1 = "select i from A where i > ? " +
"UNION select k from B where k > ? " +
"UNION select n from C where n != ?;";
Cursor c1 = mDatabase.rawQuery(s1, new String[]{"2", "201", "900"});
assertEquals(n, c1.getCount());
c1.close();
}
MainActivityTest.java 文件源码
项目:intellij-ce-playground
阅读 29
收藏 0
点赞 0
评论 0
@MediumTest
public void testJavaStrings() {
assertEquals("SUCCESS-APP", mAppTextView2.getText().toString());
assertEquals("SUCCESS-LIB1", mLib1TextView2.getText().toString());
assertEquals("SUCCESS-LIB2", mLib2TextView2.getText().toString());
assertEquals("SUCCESS-LIB2b", mLib2bTextView2.getText().toString());
assertEquals("SUCCESS-LIBAPP", mLibappTextView2.getText().toString());
}
NodeRepositoryTest.java 文件源码
项目:Freifunk-App
阅读 23
收藏 0
点赞 0
评论 0
@Test
@MediumTest
public void load_withoutFile_returnsEmpty() throws Exception {
NodeRepository sut = makeSut();
sut.setNodes(NodeRepository.load(getTestContext()));
assertEquals(0, sut.getNodes().count());
}
TrackRecordingServiceTest.java 文件源码
项目:mytracks
阅读 19
收藏 0
点赞 0
评论 0
@MediumTest
public void testRecording_oldTracks() throws Exception {
createDummyTrack(123L, -1L, false);
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertFalse(service.isRecording());
assertEquals(-1L, service.getRecordingTrackId());
}
TrackRecordingServiceTest.java 文件源码
项目:mytracks
阅读 19
收藏 0
点赞 0
评论 0
@MediumTest
public void testRecording_orphanedRecordingTrack() throws Exception {
// Just set recording track to a bogus value.
PreferencesUtils.setLong(context, R.string.recording_track_id_key, 256L);
// Make sure that the service will not start recording and will clear
// the bogus track.
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertFalse(service.isRecording());
assertEquals(-1L, service.getRecordingTrackId());
}
TrackRecordingServiceTest.java 文件源码
项目:mytracks
阅读 21
收藏 0
点赞 0
评论 0
@MediumTest
public void testStartNewTrack_alreadyRecording() throws Exception {
createDummyTrack(123L, -1L, true);
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertTrue(service.isRecording());
// Starting a new track when there is a recording should just return -1L.
long newTrack = service.startNewTrack();
assertEquals(-1L, newTrack);
assertEquals(123L, PreferencesUtils.getLong(context, R.string.recording_track_id_key));
assertEquals(123L, service.getRecordingTrackId());
}
MainTest.java 文件源码
项目:intellij-ce-playground
阅读 29
收藏 0
点赞 0
评论 0
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertNotNull(mNoOverlayIV);
assertNotNull(mTypeOverlayIV);
assertNotNull(mFlavorOverlayIV);
assertNotNull(mTypeFlavorOverlayIV);
assertNotNull(mVariantTypeFlavorOverlayIV);
}
MainActivityTest.java 文件源码
项目:intellij-ce-playground
阅读 43
收藏 0
点赞 0
评论 0
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertNotNull(mLib1TextView1);
// use some of Guava's class as they should be accessible through the
// classpath from the library
Iterable<String> segments = Splitter.on("-").split(mLib1TextView1.getText());
assertEquals("SUCCESS", segments.iterator().next());
}
TrackRecordingServiceTest.java 文件源码
项目:mytracks
阅读 22
收藏 0
点赞 0
评论 0
@MediumTest
public void testInsertStatisticsMarker_noRecordingTrack() throws Exception {
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertFalse(service.isRecording());
long waypointId = service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS);
assertEquals(-1L, waypointId);
}