use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testDivider_directionRow_all_thickDivider.
@Test
@FlakyTest
public void testDivider_directionRow_all_thickDivider() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_divider_test_direction_row, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
Drawable thickDivider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider_thick, null);
flexboxLayout.setDividerDrawableVertical(thickDivider);
flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_BEGINNING | FlexboxLayout.SHOW_DIVIDER_MIDDLE | FlexboxLayout.SHOW_DIVIDER_END);
}
});
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
assertThat(flexboxLayout.getShowDividerVertical(), is(FlexboxLayout.SHOW_DIVIDER_BEGINNING | FlexboxLayout.SHOW_DIVIDER_MIDDLE | FlexboxLayout.SHOW_DIVIDER_END));
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_thick, null);
// The sum of three text views and the sum of thick dividers don't fit in one line.
// The last text view should be placed to the next line.
assertNotNull(divider);
int widthSumFirstRow = text1.getWidth() + text2.getWidth() + divider.getIntrinsicWidth() * 3;
assertThat(text2.getRight() + divider.getIntrinsicWidth(), is(widthSumFirstRow));
assertThat(text1.getLeft(), is(not(flexboxLayout.getLeft())));
assertThat(text3.getBottom(), is(text1.getHeight() + text2.getHeight()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testWrap_parentPadding_horizontal.
@Test
@FlakyTest
public void testWrap_parentPadding_horizontal() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_wrap_parent_padding_horizontal_test);
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
// The sum of width of TextView1 and TextView2 is not enough for wrapping, but considering
// parent padding, the second TextView should be wrapped
onView(withId(R.id.text2)).check(isBelow(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
TextView text1 = (TextView) activity.findViewById(R.id.text1);
TextView text2 = (TextView) activity.findViewById(R.id.text2);
assertThat(flexboxLayout.getHeight(), is(flexboxLayout.getPaddingTop() + flexboxLayout.getPaddingBottom() + text1.getHeight() + text2.getHeight()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testJustifyContent_center_withParentPadding.
@Test
@FlakyTest
public void testJustifyContent_center_withParentPadding() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_justify_content_with_parent_padding, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setJustifyContent(FlexboxLayout.JUSTIFY_CONTENT_CENTER);
}
});
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_CENTER));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
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.getWidth() - textView1.getWidth() - textView2.getWidth() - textView3.getWidth() - flexboxLayout.getPaddingLeft() - flexboxLayout.getPaddingRight();
space = space / 2;
assertThat(textView1.getLeft() - flexboxLayout.getPaddingLeft(), isEqualAllowingError(space));
assertThat(flexboxLayout.getWidth() - textView3.getRight() - flexboxLayout.getPaddingRight(), isEqualAllowingError(space));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testMinWidth_initial_width_less_than_minWidth.
@Test
@FlakyTest
public void testMinWidth_initial_width_less_than_minWidth() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
// This test case verifies if the minWidth attribute works as a minimum constraint
// If the initial view width is less than the value of minWidth.
// The textView1's layout_width is set to wrap_content and its text is "1" apparently
// the initial measured width is less than the value of layout_minWidth (100dp)
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_minwidth_test);
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
int minWidth = ((FlexboxLayout.LayoutParams) textView1.getLayoutParams()).minWidth;
onView(withId(R.id.text1)).check(hasWidth(minWidth));
onView(withId(R.id.text2)).check(hasWidth(flexboxLayout.getWidth() - minWidth));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testDivider_directionRow_verticalEnd.
@Test
@FlakyTest
public void testDivider_directionRow_verticalEnd() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_divider_test_direction_row, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_END);
}
});
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
assertThat(flexboxLayout.getShowDividerVertical(), is(FlexboxLayout.SHOW_DIVIDER_END));
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);
// Three text views are placed in the first row, thus two vertical middle dividers should
// be placed
int widthSumFirstRow = text1.getWidth() + text2.getWidth() + text3.getWidth() + divider.getIntrinsicWidth();
assertThat(text3.getRight() + divider.getIntrinsicWidth(), is(widthSumFirstRow));
assertThat(text1.getLeft(), is(flexboxLayout.getLeft()));
}
Aggregations