Search in sources :

Example 11 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testJustifyContent_center_flexDirection_column.

@Test
@FlakyTest
public void testJustifyContent_center_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_CENTER);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_CENTER));
    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(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text2)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));
    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();
    space = space / 2;
    assertThat(textView1.getTop(), isEqualAllowingError(space));
    assertThat(flexboxLayout.getBottom() - textView3.getBottom(), 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 12 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testMaxWidth_works_as_upper_bound_expand_to.

@Test
@FlakyTest
public void testMaxWidth_works_as_upper_bound_expand_to() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    // This test case verifies if the maxWidth attribute works as a upper bound
    // when the view would expand more than the maxWidth if the maxWidth weren't set
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_maxwidth_upper_bound_test);
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    int maxWidth = ((FlexboxLayout.LayoutParams) textView1.getLayoutParams()).maxWidth;
    onView(withId(R.id.text1)).check(hasWidth(maxWidth));
    assertEquals(flexboxLayout.getWidth(), textView1.getWidth() + textView2.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 13 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testWrapBefore_nowrap.

@Test
@FlakyTest
public void testWrapBefore_nowrap() throws Throwable {
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_wrap_before_test, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_NOWRAP);
        }
    });
    // layout_wrapBefore for the text2 and text3 are set to true, but the flexWrap is set to
    // FLEX_WRAP_NOWRAP, three text views should not be wrapped.
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_NOWRAP));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
    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.text1)).check(isBottomAlignedWith(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.text2)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
    onView(withId(R.id.text3)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 14 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testAlignContent_spaceBetween_flexDirection_column.

@Test
@FlakyTest
public void testAlignContent_spaceBetween_flexDirection_column() throws Throwable {
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_align_content_test, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setAlignContent(FlexboxLayout.ALIGN_CONTENT_SPACE_BETWEEN);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_SPACE_BETWEEN));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    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(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text2)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isRightAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 15 with FlakyTest

use of android.support.test.filters.FlakyTest in project flexbox-layout by google.

the class FlexboxAndroidTest method testAlignContent_flexStart_flexDirection_column.

@Test
@FlakyTest
public void testAlignContent_flexStart_flexDirection_column() 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);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_FLEX_START));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    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(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isBelow(withId(R.id.text1)));
    // the third TextView is wrapped to the next flex line
    onView(withId(R.id.text3)).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)));
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(textView3.getLeft(), is(textView1.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)

Aggregations

FlakyTest (android.support.test.filters.FlakyTest)165 Test (org.junit.Test)162 MediumTest (android.support.test.filters.MediumTest)145 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)140 TextView (android.widget.TextView)112 Drawable (android.graphics.drawable.Drawable)19 Ignore (org.junit.Ignore)15 Intent (android.content.Intent)12 TelephonyTest (com.android.internal.telephony.TelephonyTest)12 MainActivity (com.google.android.apps.flexbox.MainActivity)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)11 Message (android.os.Message)8 AsyncResult (android.os.AsyncResult)5 NavigationView (android.support.design.widget.NavigationView)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)5 Pair (android.util.Pair)5 Menu (android.view.Menu)5 ArrayAdapter (android.widget.ArrayAdapter)5 Spinner (android.widget.Spinner)5 HashSet (java.util.HashSet)5