use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testFlexboxLayout_wrapped_with_HorizontalScrollView.
@Test
@FlakyTest
public void testFlexboxLayout_wrapped_with_HorizontalScrollView() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_flexbox_wrapped_with_horizontalscrollview);
onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text1)));
onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
// The widthMode of the FlexboxLayout is set as MeasureSpec.UNSPECIFIED, the widht of the
// layout will be expanded to include the all children views
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(flexboxLayout.getWidth(), is(textView1.getWidth() + textView2.getWidth() + textView3.getWidth()));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testFlexboxLayout_wrapped_with_ScrollView.
@Test
@FlakyTest
public void testFlexboxLayout_wrapped_with_ScrollView() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_flexbox_wrapped_with_scrollview);
onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
onView(withId(R.id.text2)).check(isTopAlignedWith(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)));
onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
// The heightMode of the FlexboxLayout is set as MeasureSpec.UNSPECIFIED, the height of the
// layout will be expanded to include the all children views
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
TextView textView3 = (TextView) activity.findViewById(R.id.text3);
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 testJustifyContent_center.
@Test
@FlakyTest
public void testJustifyContent_center() 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_CENTER);
}
});
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_CENTER));
onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
onView(withId(R.id.text3)).check(isTopAlignedWith(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.getWidth() - textView1.getWidth() - textView2.getWidth() - textView3.getWidth();
space = space / 2;
assertThat(textView1.getLeft(), isEqualAllowingError(space));
assertThat(flexboxLayout.getRight() - textView3.getRight(), isEqualAllowingError(space));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testMaxWidth_initial_width_more_than_maxWidth.
@Test
@FlakyTest
public void testMaxWidth_initial_width_more_than_maxWidth() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
// This test case verifies if the maxWidth attribute works as a maximum constraint
// ff the initial view width is more than the value of maxWidth.
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_maxwidth_test);
TextView textView1 = (TextView) activity.findViewById(R.id.text1);
int maxWidth = ((FlexboxLayout.LayoutParams) textView1.getLayoutParams()).maxWidth;
onView(withId(R.id.text1)).check(hasWidth(maxWidth));
onView(withId(R.id.text2)).check(hasWidth(flexboxLayout.getWidth() - maxWidth));
}
use of android.support.test.filters.FlakyTest in project flexbox-layout by google.
the class FlexboxAndroidTest method testFlexBasisPercent_nowrap.
@Test
@FlakyTest
public void testFlexBasisPercent_nowrap() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_flex_basis_percent_test, new Configuration() {
@Override
public void apply(FlexboxLayout flexboxLayout) {
flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_NOWRAP);
}
});
// The text1 length is 50%, the text2 length is 60% and the text3 has the fixed width,
// but the flex wrap attribute is FLEX_WRAP_NOWRAP, and flexShrink attributes for all
// children are the default value (1), three text views are shrank to fit in a single flex
// line.
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_NOWRAP));
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(isTopAlignedWith(withId(R.id.flexbox_layout)));
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 totalWidth = textView1.getWidth() + textView2.getWidth() + textView3.getWidth();
// Allowing minor different length with the flex container since the sum of the three text
// views width is not always the same as the flex container's main size caused by round
// errors in calculating the percent lengths.
assertThat(flexboxLayout.getWidth(), isEqualAllowingError(totalWidth));
}
Aggregations