Search in sources :

Example 1 with DialogPlusBuilder

use of com.orhanobut.dialogplus.DialogPlusBuilder in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method constructorShouldNotAcceptNull.

@Test
public void constructorShouldNotAcceptNull() {
    try {
        DialogPlus.newDialog(null);
        fail();
    } catch (Exception e) {
        assertThat(e).hasMessage("Context may not be null");
    }
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    assertThat(builder).isNotNull();
}
Also used : DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) Test(org.junit.Test)

Example 2 with DialogPlusBuilder

use of com.orhanobut.dialogplus.DialogPlusBuilder in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method testContentLayoutParams_whenExpandedTrueWithHeightAndNotSet.

@Test
public void testContentLayoutParams_whenExpandedTrueWithHeightAndNotSet() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    builder.setExpanded(true, 100);
    assertThat(builder.getContentParams()).isInstanceOf(FrameLayout.LayoutParams.class);
    //when not expanded
    FrameLayout.LayoutParams params = builder.getContentParams();
    assertThat(builder.isExpanded()).isTrue();
    assertThat(params.width).isEqualTo(ViewGroup.LayoutParams.MATCH_PARENT);
    assertThat(params.height).isEqualTo(100);
    assertThat(params.gravity).isEqualTo(Gravity.BOTTOM);
}
Also used : DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) FrameLayout(android.widget.FrameLayout) Test(org.junit.Test)

Example 3 with DialogPlusBuilder

use of com.orhanobut.dialogplus.DialogPlusBuilder in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method testSetContentWidth.

@Test
public void testSetContentWidth() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    builder.setContentWidth(100);
    FrameLayout.LayoutParams params = builder.getContentParams();
    assertThat(params.width).isEqualTo(100);
}
Also used : DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) FrameLayout(android.widget.FrameLayout) Test(org.junit.Test)

Example 4 with DialogPlusBuilder

use of com.orhanobut.dialogplus.DialogPlusBuilder in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method testSetContentHeight.

@Test
public void testSetContentHeight() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    builder.setContentHeight(100);
    FrameLayout.LayoutParams params = builder.getContentParams();
    assertThat(params.height).isEqualTo(100);
}
Also used : DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) FrameLayout(android.widget.FrameLayout) Test(org.junit.Test)

Example 5 with DialogPlusBuilder

use of com.orhanobut.dialogplus.DialogPlusBuilder in project dialogplus by orhanobut.

the class DialogPlusBuilderTest method testOutMostParams.

@Test
public void testOutMostParams() {
    DialogPlusBuilder builder = DialogPlus.newDialog(context);
    FrameLayout.LayoutParams params = builder.getOutmostLayoutParams();
    assertThat(params.width).isEqualTo(ViewGroup.LayoutParams.MATCH_PARENT);
    assertThat(params.height).isEqualTo(ViewGroup.LayoutParams.MATCH_PARENT);
    // default should be 0 for all
    assertThat(params.leftMargin).isEqualTo(0);
    assertThat(params.rightMargin).isEqualTo(0);
    assertThat(params.topMargin).isEqualTo(0);
    assertThat(params.bottomMargin).isEqualTo(0);
    //set new margin
    builder.setOutMostMargin(1, 2, 3, 4);
    params = builder.getOutmostLayoutParams();
    assertThat(params.leftMargin).isEqualTo(1);
    assertThat(params.topMargin).isEqualTo(2);
    assertThat(params.rightMargin).isEqualTo(3);
    assertThat(params.bottomMargin).isEqualTo(4);
}
Also used : DialogPlusBuilder(com.orhanobut.dialogplus.DialogPlusBuilder) FrameLayout(android.widget.FrameLayout) Test(org.junit.Test)

Aggregations

DialogPlusBuilder (com.orhanobut.dialogplus.DialogPlusBuilder)28 Test (org.junit.Test)28 FrameLayout (android.widget.FrameLayout)7 DialogPlus (com.orhanobut.dialogplus.DialogPlus)5 LinearLayout (android.widget.LinearLayout)3 View (android.view.View)2 ArrayAdapter (android.widget.ArrayAdapter)1 GridHolder (com.orhanobut.dialogplus.GridHolder)1 ListHolder (com.orhanobut.dialogplus.ListHolder)1 OnBackPressListener (com.orhanobut.dialogplus.OnBackPressListener)1 OnCancelListener (com.orhanobut.dialogplus.OnCancelListener)1 OnClickListener (com.orhanobut.dialogplus.OnClickListener)1 OnDismissListener (com.orhanobut.dialogplus.OnDismissListener)1 OnItemClickListener (com.orhanobut.dialogplus.OnItemClickListener)1 ViewHolder (com.orhanobut.dialogplus.ViewHolder)1