Search in sources :

Example 91 with FlakyTest

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()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 92 with FlakyTest

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()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 93 with FlakyTest

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));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 94 with FlakyTest

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));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 95 with FlakyTest

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));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

FlakyTest (android.support.test.filters.FlakyTest)141 MediumTest (android.support.test.filters.MediumTest)141 Test (org.junit.Test)141 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)140 TextView (android.widget.TextView)112 Drawable (android.graphics.drawable.Drawable)19 MainActivity (com.google.android.apps.flexbox.MainActivity)12 NavigationView (android.support.design.widget.NavigationView)5 Menu (android.view.Menu)5 ArrayAdapter (android.widget.ArrayAdapter)5 Spinner (android.widget.Spinner)5 Espresso.onView (android.support.test.espresso.Espresso.onView)2 View (android.view.View)2