Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/fragment cleanup #9

Merged
merged 17 commits into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ public void testMediaSelectionConfirmedFromSingleClick() {
final MediaPickerFragment testFragment = new MediaPickerFragment();
final MediaActivity testListener = new MediaActivity();
final ArrayList<MediaSource> testMediaSources = new ArrayList<>();
testMediaSources.add(mMediaSourceOnMediaSelectedFalse);
final MediaSourceAdapter mockAdapter = mock(MediaSourceAdapter.class);

when(mockAdapter.getItem(0)).thenReturn(new MediaItem());
when(mockAdapter.getCount()).thenReturn(1);
when(mockAdapter.getViewTypeCount()).thenReturn(1);
testFragment.setAdapter(mockAdapter);
when(mockAdapter.sourceAtPosition(0)).thenReturn(mMediaSourceOnMediaSelectedFalse);

testMediaSources.add(mMediaSourceOnMediaSelectedFalse);
FragmentTestUtil.startFragment(testFragment);
testFragment.setListener(testListener);
testFragment.setMediaSources(testMediaSources);

FragmentTestUtil.startFragment(testFragment);
testFragment.setAdapter(mockAdapter);
testFragment.onItemClick(null, null, 0, 0);

Assert.assertTrue(tSelectionConfirmed);
Expand Down Expand Up @@ -123,7 +123,7 @@ public void testMediaSelectionConfirmedFromActionModeMenu() {

private MediaSource mMediaSourceOnMediaSelectedFalse = new MediaSource() {
@Override
public void gather(OnMediaLoaded callback) {
public void gather() {
}

@Override
Expand All @@ -136,7 +136,7 @@ public void setListener(OnMediaChange listener) {

@Override
public int getCount() {
return 0;
return 1;
}

@Override
Expand Down Expand Up @@ -188,7 +188,7 @@ public void onMediaSelectionCancelled() {
}

@Override
public boolean onMenuItemSelected(MenuItem menuItem) {
public boolean onMenuItemSelected(MenuItem menuItem, ArrayList<MediaItem> selectedContent) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class MediaSourceAdapterTest {
@Test
public void testViewTypeCountWithNoSources() {
final ArrayList<MediaSource> testSources = new ArrayList<>();
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(1, testAdapter.getViewTypeCount());
}
Expand All @@ -47,7 +47,7 @@ public void testViewTypeCountWithOneSource() {
final ArrayList<MediaSource> testSources = new ArrayList<>();
testSources.add(new MediaSourceDeviceImages(mock(ContentResolver.class)));

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(testSources.size(), testAdapter.getViewTypeCount());
}
Expand All @@ -61,7 +61,7 @@ public void testViewTypeCountWithManySources() {
testSources.add(new MediaSourceDeviceImages(mock(ContentResolver.class)));
testSources.add(new MediaSourceDeviceVideos(mock(ContentResolver.class)));

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(testSources.size(), testAdapter.getViewTypeCount());
}
Expand All @@ -72,7 +72,7 @@ public void testViewTypeCountWithManySources() {
@Test
public void testViewTypeWithNoSources() {
final ArrayList<MediaSource> testSources = new ArrayList<>();
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(-1, testAdapter.getItemViewType(0));
}
Expand All @@ -92,7 +92,7 @@ public void testViewTypeWithManySources() {
testSources.add(mockSource1);
testSources.add(mockSource2);

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(1, testAdapter.getItemViewType(testItemCount + 1));
}
Expand All @@ -109,7 +109,7 @@ public void testCountWithOneSource() {
when(mockSource.getCount()).thenReturn(testItemCount);
testSources.add(mockSource);

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(testItemCount, testAdapter.getCount());
}
Expand All @@ -129,7 +129,7 @@ public void testCountWithManySources() {
testSources.add(mockSource1);
testSources.add(mockSource2);

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(testItemCount * testSources.size(), testAdapter.getCount());
}
Expand All @@ -152,7 +152,7 @@ public void testGetItem() {
testSources.add(mockSource1);
testSources.add(mockSource2);

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);
final MediaItem mediaItem = testAdapter.getItem(testItemCount + 1);

Assert.assertEquals(testItem, mediaItem);
Expand Down Expand Up @@ -182,7 +182,7 @@ public void testGetView() {
testSources.add(mockSource1);
testSources.add(mockSource2);

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

Assert.assertEquals(testView, testAdapter.getView(testItemCount, null, null));
}
Expand All @@ -202,7 +202,7 @@ public void testItemId() {
testSources.add(mockSource1);
testSources.add(mockSource2);

final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null, null);
final MediaSourceAdapter testAdapter = new MediaSourceAdapter(Robolectric.application, testSources, null);

for (int i = 0; i < testItemCount * testSources.size(); ++i) {
Assert.assertEquals(i, testAdapter.getItemId(i));
Expand Down
Loading