Search in sources :

Example 1 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig in project boxing by Bilibili.

the class PickerModuleTest method testMaxCount.

@Test
public void testMaxCount() {
    mPickerManager.setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).withMaxCount(10));
    BoxingConfig config = mPickerManager.getBoxingConfig();
    int count = config.getMaxCount();
    assertEquals(count, 10);
    mPickerManager.setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).withMaxCount(0));
    config = mPickerManager.getBoxingConfig();
    count = config.getMaxCount();
    assertEquals(count, BoxingConfig.DEFAULT_SELECTED_COUNT);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) Test(org.junit.Test)

Example 2 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig in project boxing by Bilibili.

the class PickerModuleTest method testLoadImage.

@Test
public void testLoadImage() {
    assertNotNull(mPickerManager);
    mPickerManager.setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
    BoxingConfig config = mPickerManager.getBoxingConfig();
    assertNotNull(config);
    Assert.assertEquals(config.getMode(), BoxingConfig.Mode.MULTI_IMG);
    ContentResolver cr = RuntimeEnvironment.application.getContentResolver();
    assertNotNull(cr);
    mPickerManager.loadAlbum(cr, new IAlbumTaskCallback() {

        @Override
        public void postAlbumList(List<AlbumEntity> list) {
            assertNotNull(list);
        }
    });
}
Also used : AlbumEntity(com.bilibili.boxing.model.entity.AlbumEntity) BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) IAlbumTaskCallback(com.bilibili.boxing.model.callback.IAlbumTaskCallback) ContentResolver(android.content.ContentResolver) Test(org.junit.Test)

Example 3 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig in project boxing by Bilibili.

the class PickerPresenterTest method loadImages.

@Test
public void loadImages() {
    Mockito.when(mPickerManager.getBoxingConfig()).thenReturn(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
    mPresenter.loadMedias(0, "");
    Mockito.verify(mPickerManager).loadMedia(any(ContentResolver.class), ArgumentCaptor.forClass(Integer.class).capture(), ArgumentCaptor.forClass(String.class).capture(), mLoadMediaCallback.capture());
    List<ImageMedia> imageMedias = new ArrayList<>();
    imageMedias.add(new ImageMedia.Builder("1", "test1").build());
    imageMedias.add(new ImageMedia.Builder("2", "test2").build());
    imageMedias.add(new ImageMedia.Builder("3", "test3").build());
    imageMedias.add(new ImageMedia.Builder("4", "test4").build());
    mLoadMediaCallback.getValue().postMedia(imageMedias, 4);
    ArgumentCaptor<List> showVideoCaptor = ArgumentCaptor.forClass(List.class);
    Mockito.verify(mView).showMedia(showVideoCaptor.capture(), anyInt());
    System.out.print("load video count:" + showVideoCaptor.getValue().size());
    Assert.assertTrue(showVideoCaptor.getValue().size() == 4);
    Assert.assertTrue(showVideoCaptor.getValue().get(0).equals(imageMedias.get(0)));
    Assert.assertTrue(showVideoCaptor.getValue().get(1).equals(imageMedias.get(1)));
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 4 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig in project boxing by Bilibili.

the class PickerPresenterTest method loadVideo.

@Test
public void loadVideo() {
    Mockito.when(mPickerManager.getBoxingConfig()).thenReturn(new BoxingConfig(BoxingConfig.Mode.VIDEO));
    mPresenter.loadMedias(1, "");
    Mockito.verify(mPickerManager).loadMedia(any(ContentResolver.class), ArgumentCaptor.forClass(Integer.class).capture(), ArgumentCaptor.forClass(String.class).capture(), mLoadMediaCallback.capture());
    List<VideoMedia> videoMedias = new ArrayList<>();
    videoMedias.add(new VideoMedia.Builder("1", "test1").build());
    videoMedias.add(new VideoMedia.Builder("2", "test2").build());
    videoMedias.add(new VideoMedia.Builder("3", "test3").build());
    mLoadMediaCallback.getValue().postMedia(videoMedias, 3);
    ArgumentCaptor<List> showVideoCaptor = ArgumentCaptor.forClass(List.class);
    Mockito.verify(mView).showMedia(showVideoCaptor.capture(), anyInt());
    System.out.print("load video count:" + showVideoCaptor.getValue().size());
    Assert.assertTrue(showVideoCaptor.getValue().size() == 3);
    Assert.assertTrue(showVideoCaptor.getValue().get(0).equals(videoMedias.get(0)));
    Assert.assertTrue(showVideoCaptor.getValue().get(1).equals(videoMedias.get(1)));
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) VideoMedia(com.bilibili.boxing.model.entity.impl.VideoMedia) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 5 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig in project boxing by Bilibili.

the class PickerActivityTest method testCreateSingleImageIntent.

@Test
public void testCreateSingleImageIntent() {
    Intent intent = Boxing.of(new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).needCamera(R.drawable.ic_boxing_broken_image)).withIntent(mContext, BoxingActivity.class).getIntent();
    assertNotNull(intent);
    BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
    assertNotNull(config);
    assertEquals(config.getMode(), BoxingConfig.Mode.SINGLE_IMG);
    assertEquals(config.isNeedCamera(), true);
    BoxingCropOption cropOptions = config.getCropOption();
    assertEquals(cropOptions, null);
    ArrayList<BaseMedia> list = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
    assertEquals(list, null);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) BoxingActivity(com.bilibili.boxing_impl.ui.BoxingActivity) Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Test(org.junit.Test)

Aggregations

BoxingConfig (com.bilibili.boxing.model.config.BoxingConfig)25 Test (org.junit.Test)14 Intent (android.content.Intent)7 BoxingCropOption (com.bilibili.boxing.model.config.BoxingCropOption)7 BaseMedia (com.bilibili.boxing.model.entity.BaseMedia)6 BoxingActivity (com.bilibili.boxing_impl.ui.BoxingActivity)6 Uri (android.net.Uri)4 PickerPresenter (com.bilibili.boxing.presenter.PickerPresenter)4 ArrayList (java.util.ArrayList)4 ContentResolver (android.content.ContentResolver)3 ImageMedia (com.bilibili.boxing.model.entity.impl.ImageMedia)3 MockContentResolver (android.test.mock.MockContentResolver)2 ImageView (android.widget.ImageView)2 VideoMedia (com.bilibili.boxing.model.entity.impl.VideoMedia)2 List (java.util.List)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 PrepareOnlyThisForTest (org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)2 BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)1 FragmentManager (android.support.v4.app.FragmentManager)1 View (android.view.View)1