use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testDivider_directionColumn_horizontalBeginning.
@Test
@FlakyTest
public void testDivider_directionColumn_horizontalBeginning() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_divider_test_direction_column);
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
assertThat(flexboxLayout.getShowDividerHorizontal(), is(FlexboxLayout.SHOW_DIVIDER_BEGINNING));
TextView text1 = (TextView) activity.findViewById(R.id.text1);
TextView text2 = (TextView) activity.findViewById(R.id.text2);
TextView text3 = (TextView) activity.findViewById(R.id.text3);
Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
assertNotNull(divider);
int heightSumFirstRow = text1.getHeight() + text2.getHeight() + text3.getHeight() + divider.getIntrinsicHeight();
assertThat(text3.getBottom(), is(heightSumFirstRow));
assertThat(text1.getTop(), is(not(flexboxLayout.getTop())));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testAlignItems_flexStart.
@Test
@FlakyTest
public void testAlignItems_flexStart() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_align_items_test);
assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_FLEX_START));
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(isTopAlignedWith(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)));
onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));
// There should be 2 flex lines in the layout with the given layout.
int flexLineSize = flexboxLayout.getHeight() / 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);
assertThat(textView1.getHeight(), not(flexLineSize));
assertThat(textView2.getHeight(), not(flexLineSize));
assertThat(textView3.getHeight(), not(flexLineSize));
assertThat(textView3.getTop(), isEqualAllowingError(flexLineSize));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testZeroWidth_wrapContentHeight_positiveFlexGrow.
@Test
@FlakyTest
public void testZeroWidth_wrapContentHeight_positiveFlexGrow() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_zero_width_positive_flexgrow);
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
TextView text1 = (TextView) activity.findViewById(R.id.text1);
TextView text2 = (TextView) activity.findViewById(R.id.text2);
// Both text view's layout_width is set to 0dp, layout_height is set to wrap_content and
// layout_flexGrow is set to 1. And the text2 has a longer text than the text1.
// So if the cross size calculation (height) is wrong, the height of two text view do not
// match because text2 is trying to expand vertically.
// This assertion verifies that isn't happening. Finally both text views expand horizontally
// enough to contain their texts in one line.
assertThat(text1.getHeight(), is(text2.getHeight()));
assertThat(text1.getWidth() + text2.getWidth(), isEqualAllowingError(flexboxLayout.getWidth()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testAlignContent_flexStart.
@Test
@FlakyTest
public void testAlignContent_flexStart() 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_FLEX_START);
}
});
assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_FLEX_START));
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(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
// the third TextView is wrapped to the next flex line
onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
assertThat(textView3.getTop(), is(textView1.getHeight()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testAlignContent_stretch_parentWrapContent.
@Test
@FlakyTest
public void testAlignContent_stretch_parentWrapContent() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_align_content_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
ViewGroup.LayoutParams parentLp = flexboxLayout.getLayoutParams();
parentLp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
flexboxLayout.setLayoutParams(parentLp);
}
});
assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
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(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
// the third TextView is wrapped to the next flex line
onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));
// alignContent is only effective if the parent's height/width mode is MeasureSpec.EXACTLY.
// The size of the flex lines don't change even if the alingContent is set to
// ALIGN_CONTENT_STRETCH
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
assertThat(textView3.getTop(), is(textView1.getHeight()));
assertThat(flexboxLayout.getFlexLines().size(), is(2));
}
Aggregations