use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testView_visibility_gone_first_item_in_flex_line_horizontal.
@Test
@FlakyTest
public void testView_visibility_gone_first_item_in_flex_line_horizontal() throws Throwable {
// This test verifies if the FlexboxLayout is visible when the visibility of the first
// flex item in the second flex line (or arbitrary flex lines other than the first flex
// line)
// is set to "gone"
// There was an issue reported for that
// https://github.com/google/flexbox-layout/issues/47
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_visibility_gone_first_item_in_flex_line_row);
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
assertTrue(flexboxLayout.getHeight() > 0);
assertThat(flexboxLayout.getHeight(), is(textView1.getHeight() + textView3.getHeight()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testOrderAttribute_fromCode.
@Test
@FlakyTest
public void testOrderAttribute_fromCode() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_order_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
TextView fifth = createTextView(activity, String.valueOf(5), 0);
TextView sixth = createTextView(activity, String.valueOf(6), -10);
flexboxLayout.addView(fifth);
flexboxLayout.addView(sixth);
}
});
assertThat(flexboxLayout.getChildCount(), is(6));
// order: -10, index 5
assertThat(((TextView) flexboxLayout.getReorderedChildAt(0)).getText().toString(), is(String.valueOf(6)));
// order: -1, index 1
assertThat(((TextView) flexboxLayout.getReorderedChildAt(1)).getText().toString(), is(String.valueOf(2)));
// order: 0, index 2
assertThat(((TextView) flexboxLayout.getReorderedChildAt(2)).getText().toString(), is(String.valueOf(3)));
// order: 0, index 4
assertThat(((TextView) flexboxLayout.getReorderedChildAt(3)).getText().toString(), is(String.valueOf(5)));
// order: 1, index 3
assertThat(((TextView) flexboxLayout.getReorderedChildAt(4)).getText().toString(), is(String.valueOf(4)));
// order: 2, index 0
assertThat(((TextView) flexboxLayout.getReorderedChildAt(5)).getText().toString(), is(String.valueOf(1)));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testFlexWrap_wrap_reverse_flexDirection_column.
@Test
@FlakyTest
public void testFlexWrap_wrap_reverse_flexDirection_column() throws Throwable {
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_flex_wrap_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE);
}
});
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text1)).check(isRightAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isBelow(withId(R.id.text1)));
// The width of the FlexboxLayout is not enough for placing the three text views.
// There should be two flex lines same as FLEX_WRAP_WRAP, but the layout starts from right
// to left in FLEX_WRAP_WRAP_REVERSE
onView(withId(R.id.text3)).check(isLeftOf(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isLeftOf(withId(R.id.text2)));
onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
assertThat(flexboxLayout.getFlexLines().size(), is(2));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testDivider_directionRow_horizontalBeginning.
@Test
@FlakyTest
public void testDivider_directionRow_horizontalBeginning() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
final Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_divider_test_direction_row, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setDividerDrawableHorizontal(divider);
flexboxLayout.setShowDividerHorizontal(FlexboxLayout.SHOW_DIVIDER_BEGINNING);
flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_NONE);
}
});
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
assertThat(flexboxLayout.getShowDividerHorizontal(), is(FlexboxLayout.SHOW_DIVIDER_BEGINNING));
assertThat(flexboxLayout.getShowDividerVertical(), is(FlexboxLayout.SHOW_DIVIDER_NONE));
TextView text1 = (TextView) activity.findViewById(R.id.text1);
TextView text4 = (TextView) activity.findViewById(R.id.text4);
assertNotNull(divider);
int heightSum = text1.getHeight() + text4.getHeight() + divider.getIntrinsicHeight();
assertThat(text4.getBottom(), is(heightSum));
assertThat(text1.getTop(), is(not(flexboxLayout.getTop())));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testJustifyContent_spaceAround_flexDirection_column_withPadding.
@Test
@FlakyTest
public void testJustifyContent_spaceAround_flexDirection_column_withPadding() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
final int padding = 40;
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_justify_content_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setJustifyContent(FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND);
flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
flexboxLayout.setPadding(padding, padding, padding, padding);
}
});
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView2 = (TextView) activity.findViewById(R.id.text2);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
int space = flexboxLayout.getHeight() - textView1.getHeight() - textView2.getHeight() - textView3.getHeight() - padding * 2;
// Divide by the number of children * 2
space = space / 6;
assertThat(textView1.getTop() - padding, isEqualAllowingError(space));
int spaceInMiddle = space * 2;
assertThat(textView2.getTop() - textView1.getBottom(), isEqualAllowingError(spaceInMiddle));
assertThat(textView3.getTop() - textView2.getBottom(), isEqualAllowingError(spaceInMiddle));
assertThat(flexboxLayout.getBottom() - textView3.getBottom() - padding, isEqualAllowingError(space));
}
Aggregations