Search in sources :

Example 61 with FlakyTest

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

the class FlexboxAndroidTest method testOrderAttribute_addViewInMiddle.

@Test
@FlakyTest
public void testOrderAttribute_addViewInMiddle() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_order_test, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            TextView fifth = createTextView(activity, String.valueOf(5), 0);
            // Add the new TextView in the middle of the indices
            flexboxLayout.addView(fifth, 2);
        }
    });
    assertNotNull(flexboxLayout);
    assertThat(flexboxLayout.getChildCount(), is(5));
    // order: -1, index 1
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(0)).getText().toString(), is(String.valueOf(2)));
    // order: 0, index 2
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(1)).getText().toString(), is(String.valueOf(5)));
    // order: 0, index 3
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(2)).getText().toString(), is(String.valueOf(3)));
    // order: 0, index 4
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(3)).getText().toString(), is(String.valueOf(4)));
    // order: 2, index 0
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(4)).getText().toString(), is(String.valueOf(1)));
}
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 62 with FlakyTest

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

the class FlexboxAndroidTest method testDivider_directionRow_horizontalMiddle.

@Test
@FlakyTest
public void testDivider_directionRow_horizontalMiddle() 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 divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
            flexboxLayout.setDividerDrawableHorizontal(divider);
            flexboxLayout.setShowDividerHorizontal(FlexboxLayout.SHOW_DIVIDER_MIDDLE);
            flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_NONE);
        }
    });
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
    assertThat(flexboxLayout.getShowDividerHorizontal(), is(FlexboxLayout.SHOW_DIVIDER_MIDDLE));
    assertThat(flexboxLayout.getShowDividerVertical(), is(FlexboxLayout.SHOW_DIVIDER_NONE));
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text4 = (TextView) activity.findViewById(R.id.text4);
    Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
    assertNotNull(divider);
    int heightSum = text1.getHeight() + text4.getHeight() + divider.getIntrinsicHeight();
    assertThat(text4.getBottom(), is(heightSum));
    assertThat(text1.getTop(), is(flexboxLayout.getTop()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) Drawable(android.graphics.drawable.Drawable) 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 63 with FlakyTest

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

the class FlexboxAndroidTest method testFlexWrap_wrap_reverse.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE);
        }
    });
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    // The width of the FlexboxLayout is not enough for placing the three text views.
    // There should be two flex lines same as FLEX_WRAP_WRAP, but the layout starts from bottom
    // to top in FLEX_WRAP_WRAP_REVERSE
    onView(withId(R.id.text3)).check(isAbove(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isAbove(withId(R.id.text2)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    assertThat(flexboxLayout.getFlexLines().size(), is(2));
}
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 64 with FlakyTest

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

the class FlexboxAndroidTest method testDivider_directionColumn_verticalEnd.

@Test
@FlakyTest
public void testDivider_directionColumn_verticalEnd() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_divider_test_direction_column, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
            flexboxLayout.setDividerDrawableHorizontal(divider);
            flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_END);
            flexboxLayout.setShowDividerHorizontal(FlexboxLayout.SHOW_DIVIDER_NONE);
        }
    });
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    assertThat(flexboxLayout.getShowDividerVertical(), is(FlexboxLayout.SHOW_DIVIDER_END));
    assertThat(flexboxLayout.getShowDividerHorizontal(), is(FlexboxLayout.SHOW_DIVIDER_NONE));
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text4 = (TextView) activity.findViewById(R.id.text4);
    Drawable divider = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.divider, null);
    assertNotNull(divider);
    int widthSum = text1.getWidth() + text4.getWidth() + divider.getIntrinsicWidth();
    assertThat(text4.getRight() + divider.getIntrinsicWidth(), is(widthSum));
    assertThat(text1.getLeft(), is(flexboxLayout.getLeft()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) Drawable(android.graphics.drawable.Drawable) 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 65 with FlakyTest

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

the class FlexboxAndroidTest method testFlexItem_match_parent.

@Test
@FlakyTest
public void testFlexItem_match_parent() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_flex_item_match_parent);
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text2 = (TextView) activity.findViewById(R.id.text2);
    TextView text3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(text1.getWidth(), is(flexboxLayout.getWidth()));
    assertThat(text2.getWidth(), is(flexboxLayout.getWidth()));
    assertThat(text3.getWidth(), is(flexboxLayout.getWidth()));
    assertThat(flexboxLayout.getHeight(), is(text1.getHeight() + text2.getHeight() + text3.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)

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