Methods Summary |
---|
private android.content.ContentValues | createAudioContent()
ContentValues values = new ContentValues();
values.put("_data", "/mnt/sdcard/audio" + ++mAudioCounter);
return values;
|
private android.content.ContentValues | createContent(android.net.Uri uri)
if (uri == sFilesUri) return createFileContent();
else if (uri == sAudioUri) return createAudioContent();
else if (uri == sVideoUri) return createVideoContent();
else if (uri == sImagesUri) return createImageContent();
else throw new IllegalArgumentException("Unknown URL: " + uri.toString());
|
private android.content.ContentValues | createFileContent()
ContentValues values = new ContentValues();
values.put("_data", "/mnt/sdcard/file" + ++mFilesCounter);
return values;
|
private android.content.ContentValues | createImageContent()
ContentValues values = new ContentValues();
values.put("_data", "/mnt/sdcard/image" + ++mImagesCounter);
return values;
|
private android.content.ContentValues | createVideoContent()
ContentValues values = new ContentValues();
values.put("_data", "/mnt/sdcard/video" + ++mVideoCounter);
return values;
|
private void | fillBuffer(android.net.Uri uri, int numberOfFiles)
ContentValues values;
for (int i = 0; i < numberOfFiles; ++i) {
values = createContent(uri);
mMediaInserter.insert(uri, values);
}
|
protected void | setUp()
super.setUp();
mMockProvider = EasyMock.createMock(IContentProvider.class);
mMediaInserter = new MediaInserter(mMockProvider,
mPackageName, TEST_BUFFER_SIZE);
mPackageName = getInstrumentation().getContext().getPackageName();
mFilesCounter = 0;
mAudioCounter = 0;
mVideoCounter = 0;
mImagesCounter = 0;
|
public void | testFlushAllWithEmptyContents()
EasyMock.replay(mMockProvider);
mMediaInserter.flushAll();
EasyMock.verify(mMockProvider);
|
public void | testFlushAllWithSomeContents()
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
(Uri) EasyMock.anyObject(), (ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(4);
EasyMock.replay(mMockProvider);
fillBuffer(sFilesUri, TEST_BUFFER_SIZE - 4);
fillBuffer(sAudioUri, TEST_BUFFER_SIZE - 3);
fillBuffer(sVideoUri, TEST_BUFFER_SIZE - 2);
fillBuffer(sImagesUri, TEST_BUFFER_SIZE - 1);
mMediaInserter.flushAll();
EasyMock.verify(mMockProvider);
|
public void | testInsertContentsAfterFlushAll()
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
(Uri) EasyMock.anyObject(), (ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(8);
EasyMock.replay(mMockProvider);
fillBuffer(sFilesUri, TEST_BUFFER_SIZE - 4);
fillBuffer(sAudioUri, TEST_BUFFER_SIZE - 3);
fillBuffer(sVideoUri, TEST_BUFFER_SIZE - 2);
fillBuffer(sImagesUri, TEST_BUFFER_SIZE - 1);
mMediaInserter.flushAll();
fillBuffer(sFilesUri, TEST_BUFFER_SIZE + 1);
fillBuffer(sAudioUri, TEST_BUFFER_SIZE + 2);
fillBuffer(sVideoUri, TEST_BUFFER_SIZE + 3);
fillBuffer(sImagesUri, TEST_BUFFER_SIZE + 4);
EasyMock.verify(mMockProvider);
|
public void | testInsertContentsEqualToBufferSize()
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
(Uri) EasyMock.anyObject(), (ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(4);
EasyMock.replay(mMockProvider);
fillBuffer(sFilesUri, TEST_BUFFER_SIZE);
fillBuffer(sAudioUri, TEST_BUFFER_SIZE);
fillBuffer(sVideoUri, TEST_BUFFER_SIZE);
fillBuffer(sImagesUri, TEST_BUFFER_SIZE);
EasyMock.verify(mMockProvider);
|
public void | testInsertContentsLessThanBufferSize()
EasyMock.replay(mMockProvider);
fillBuffer(sFilesUri, TEST_BUFFER_SIZE - 4);
fillBuffer(sAudioUri, TEST_BUFFER_SIZE - 3);
fillBuffer(sVideoUri, TEST_BUFFER_SIZE - 2);
fillBuffer(sImagesUri, TEST_BUFFER_SIZE - 1);
EasyMock.verify(mMockProvider);
|
public void | testInsertContentsMoreThanBufferSize()
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
(Uri) EasyMock.anyObject(), (ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(4);
EasyMock.replay(mMockProvider);
fillBuffer(sFilesUri, TEST_BUFFER_SIZE + 1);
fillBuffer(sAudioUri, TEST_BUFFER_SIZE + 2);
fillBuffer(sVideoUri, TEST_BUFFER_SIZE + 3);
fillBuffer(sImagesUri, TEST_BUFFER_SIZE + 4);
EasyMock.verify(mMockProvider);
|
public void | testInsertContentsWithDifferentSizePerContentType()
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
MediaUriMatcher.expectMediaUri(sFilesUri),
(ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(1);
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
MediaUriMatcher.expectMediaUri(sAudioUri),
(ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(2);
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
MediaUriMatcher.expectMediaUri(sVideoUri),
(ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(3);
EasyMock.expect(mMockProvider.bulkInsert(mPackageName,
MediaUriMatcher.expectMediaUri(sImagesUri),
(ContentValues[]) EasyMock.anyObject())).andReturn(1);
EasyMock.expectLastCall().times(4);
EasyMock.replay(mMockProvider);
for (int i = 0; i < TEST_BUFFER_SIZE; ++i) {
fillBuffer(sFilesUri, 1);
fillBuffer(sAudioUri, 2);
fillBuffer(sVideoUri, 3);
fillBuffer(sImagesUri, 4);
}
EasyMock.verify(mMockProvider);
|