Search in sources :

Example 36 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testAlignContent_spaceAround_flexDirection_column.

@Test
@FlakyTest
public void testAlignContent_spaceAround_flexDirection_column() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_align_content_test, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setAlignContent(FlexboxLayout.ALIGN_CONTENT_SPACE_AROUND);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_SPACE_AROUND));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int spaceAround = flexboxLayout.getWidth() - textView1.getWidth() - textView3.getWidth();
    // Divide by the number of flex lines * 2
    spaceAround /= 4;
    assertThat(textView1.getLeft(), isEqualAllowingError(spaceAround));
    int spaceInMiddle = textView1.getRight() + spaceAround * 2;
    assertThat(textView3.getLeft(), isEqualAllowingError(spaceInMiddle));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 37 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testDivider_directionColumn_verticalMiddle.

@Test
@FlakyTest
public void testDivider_directionColumn_verticalMiddle() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_divider_test_direction_column, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
            flexboxLayout.setDividerDrawableVertical(divider);
            flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_MIDDLE);
            flexboxLayout.setShowDividerHorizontal(FlexboxLayout.SHOW_DIVIDER_NONE);
        }
    });
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    assertThat(flexboxLayout.getShowDividerVertical(), is(FlexboxLayout.SHOW_DIVIDER_MIDDLE));
    assertThat(flexboxLayout.getShowDividerHorizontal(), is(FlexboxLayout.SHOW_DIVIDER_NONE));
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text4 = (TextView) activity.findViewById(R.id.text4);
    Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
    assertNotNull(divider);
    int widthSum = text1.getWidth() + text4.getWidth() + divider.getIntrinsicWidth();
    assertThat(text4.getRight(), is(widthSum));
    assertThat(text1.getLeft(), is(flexboxLayout.getLeft()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 38 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testFirstItemLarge_horizontal.

@Test
@FlakyTest
public void testFirstItemLarge_horizontal() throws Throwable {
    // This test verifies a empty flex line is not added when the first flex item is large
    // and judged wrapping is required with the first item.
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_first_item_large_horizontal_test);
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_STRETCH));
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
    // The sum of width of TextView1 and TextView2 is not enough for wrapping, but considering
    // the margin for the TextView2, the second TextView should be wrapped
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text2 = (TextView) activity.findViewById(R.id.text2);
    TextView text3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(flexboxLayout.getHeight(), is(text1.getHeight() + text2.getHeight() + text3.getHeight()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 39 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testZeroHeight_wrapContentWidth_positiveFlexGrow.

@Test
@FlakyTest
public void testZeroHeight_wrapContentWidth_positiveFlexGrow() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_zero_height_positive_flexgrow);
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text2 = (TextView) activity.findViewById(R.id.text2);
    assertThat(text1.getWidth(), is(not(text2.getWidth())));
    assertThat(text1.getHeight() + text2.getHeight(), isEqualAllowingError(flexboxLayout.getHeight()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 40 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testFlexDirection_column_alignItems_center_margin_oneSide.

@Test
@FlakyTest
public void testFlexDirection_column_alignItems_center_margin_oneSide() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_direction_column_align_items_center_margin_oneside);
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    assertThat(text1.getLeft(), isEqualAllowingError(TestUtil.dpToPixel(activity, 30)));
    assertThat(flexboxLayout.getRight() - text1.getRight(), isEqualAllowingError(TestUtil.dpToPixel(activity, 50)));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

FlakyTest (android.support.test.filters.FlakyTest)165 Test (org.junit.Test)162 MediumTest (android.support.test.filters.MediumTest)145 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)140 TextView (android.widget.TextView)112 Drawable (android.graphics.drawable.Drawable)19 Ignore (org.junit.Ignore)15 Intent (android.content.Intent)12 TelephonyTest (com.android.internal.telephony.TelephonyTest)12 MainActivity (com.google.android.apps.flexbox.MainActivity)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)11 Message (android.os.Message)8 AsyncResult (android.os.AsyncResult)5 NavigationView (android.support.design.widget.NavigationView)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)5 Pair (android.util.Pair)5 Menu (android.view.Menu)5 ArrayAdapter (android.widget.ArrayAdapter)5 Spinner (android.widget.Spinner)5 HashSet (java.util.HashSet)5