use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testOrderAttribute_removeLastView.
@Test
@FlakyTest
public void testOrderAttribute_removeLastView() throws Throwable {
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_order_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.removeViewAt(flexboxLayout.getChildCount() - 1);
}
});
assertNotNull(flexboxLayout);
assertThat(flexboxLayout.getChildCount(), is(3));
// order: -1, index 1
assertThat(((TextView) flexboxLayout.getReorderedChildAt(0)).getText().toString(), is(String.valueOf(2)));
// order: 0, index 2
assertThat(((TextView) flexboxLayout.getReorderedChildAt(1)).getText().toString(), is(String.valueOf(3)));
// order: 2, index 0
assertThat(((TextView) flexboxLayout.getReorderedChildAt(2)).getText().toString(), is(String.valueOf(1)));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testAlignContent_spaceAround.
@Test
@FlakyTest
public void testAlignContent_spaceAround() 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);
}
});
assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_SPACE_AROUND));
onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
int spaceAround = flexboxLayout.getHeight() - textView1.getHeight() - textView3.getHeight();
// Divide by the number of flex lines * 2
spaceAround /= 4;
assertThat(textView1.getTop(), isEqualAllowingError(spaceAround));
int spaceInMiddle = textView1.getBottom() + spaceAround * 2;
assertThat(textView3.getTop(), isEqualAllowingError(spaceInMiddle));
assertThat(flexboxLayout.getFlexLines().size(), is(2));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testAlignItems_center_wrapReverse_flexDirection_column.
@Test
@FlakyTest
public void testAlignItems_center_wrapReverse_flexDirection_column() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_align_items_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE);
flexboxLayout.setAlignItems(FlexboxLayout.ALIGN_ITEMS_CENTER);
flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
}
});
assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_CENTER));
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.text2)).check(isBelow(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
// There should be 2 flex lines in the layout with the given layout.
int flexLineSize = flexboxLayout.getWidth() / 2;
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView2 = (TextView) activity.findViewById(R.id.text2);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
// All TextView's widths are the same. No issues should be found if using the first
// TextView to calculate the space above and below
int spaceLeftAndRight = (flexLineSize - textView1.getWidth()) / 2;
assertThat(textView1.getWidth(), not(flexLineSize));
assertThat(textView2.getWidth(), not(flexLineSize));
assertThat(textView3.getWidth(), not(flexLineSize));
assertThat(textView1.getRight(), isEqualAllowingError(flexboxLayout.getWidth() - spaceLeftAndRight));
assertThat(textView2.getRight(), isEqualAllowingError(flexboxLayout.getWidth() - spaceLeftAndRight));
assertThat(textView3.getRight(), isEqualAllowingError(flexboxLayout.getWidth() - flexLineSize - spaceLeftAndRight));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testFlexItem_match_parent_flexDirection_column.
@Test
@FlakyTest
public void testFlexItem_match_parent_flexDirection_column() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_flex_item_match_parent_direction_column, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
}
});
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(text1.getHeight(), is(flexboxLayout.getHeight()));
assertThat(text2.getHeight(), is(flexboxLayout.getHeight()));
assertThat(text3.getHeight(), is(flexboxLayout.getHeight()));
assertThat(flexboxLayout.getWidth(), is(text1.getWidth() + text2.getWidth() + text3.getWidth()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testJustifyContent_spaceAround_flexDirection_column.
@Test
@FlakyTest
public void testJustifyContent_spaceAround_flexDirection_column() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
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);
}
});
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
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)));
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();
// Divide by the number of children * 2
space = space / 6;
assertThat(textView1.getTop(), 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(), isEqualAllowingError(space));
}
Aggregations