Search in sources :

Example 66 with FlakyTest

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

the class FlexboxAndroidTest method testDivider_directionColumn_verticalAll.

@Test
@FlakyTest
public void testDivider_directionColumn_verticalAll() 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.setDividerDrawableVertical(divider);
            flexboxLayout.setShowDividerVertical(FlexboxLayout.SHOW_DIVIDER_BEGINNING | FlexboxLayout.SHOW_DIVIDER_MIDDLE | 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_BEGINNING | FlexboxLayout.SHOW_DIVIDER_MIDDLE | FlexboxLayout.SHOW_DIVIDER_END));
    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() * 3;
    assertThat(text4.getRight() + divider.getIntrinsicWidth(), is(widthSum));
    assertThat(text1.getLeft(), is(not(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 67 with FlakyTest

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

the class FlexboxAndroidTest method testJustifyContent_spaceBetween_flexDirection_column_withPadding.

@Test
@FlakyTest
public void testJustifyContent_spaceBetween_flexDirection_column_withPadding() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    final int padding = 40;
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_justify_content_test, new Configuration() {

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setJustifyContent(FlexboxLayout.JUSTIFY_CONTENT_SPACE_BETWEEN);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
            flexboxLayout.setPadding(padding, padding, padding, padding);
        }
    });
    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_BETWEEN));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    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() - padding * 2;
    space = space / 2;
    assertThat(textView1.getTop(), is(padding));
    assertThat(flexboxLayout.getBottom() - textView3.getBottom(), is(padding));
    assertThat(textView2.getTop() - textView1.getBottom(), isEqualAllowingError(space));
    assertThat(textView3.getTop() - textView2.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 68 with FlakyTest

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

the class FlexboxAndroidTest method testFlexWrap_wrap_flexDirection_column.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    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)));
    // The height of the FlexboxLayout is not enough for placing the three text views.
    // The third text view should be placed right of the first one
    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)));
    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 69 with FlakyTest

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

the class FlexboxAndroidTest method testMinHeight_works_as_lower_bound_shrink_to.

@Test
@FlakyTest
public void testMinHeight_works_as_lower_bound_shrink_to() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    // This test case verifies if the minHeight attribute works as a lower bound
    // when the view would shrink less than the minHeight if the minHeight weren't set
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_minheight_lower_bound_test);
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    TextView textView4 = (TextView) activity.findViewById(R.id.text4);
    int minHeight = ((FlexboxLayout.LayoutParams) textView1.getLayoutParams()).minHeight;
    onView(withId(R.id.text1)).check(hasHeight(minHeight));
    assertEquals(flexboxLayout.getHeight(), textView1.getHeight() + textView2.getHeight() + textView3.getHeight() + textView4.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 70 with FlakyTest

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

the class FlexboxAndroidTest method testAlignItems_flexEnd.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setAlignItems(FlexboxLayout.ALIGN_ITEMS_FLEX_END);
        }
    });
    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_FLEX_END));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(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(isBottomAlignedWith(withId(R.id.flexbox_layout)));
    // There should be 2 flex lines in the layout with the given layout.
    int flexLineSize = flexboxLayout.getHeight() / 2;
    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(textView1.getHeight(), not(flexLineSize));
    assertThat(textView2.getHeight(), not(flexLineSize));
    assertThat(textView3.getHeight(), not(flexLineSize));
    assertThat(textView1.getBottom(), isEqualAllowingError(flexLineSize));
    assertThat(textView2.getBottom(), isEqualAllowingError(flexLineSize));
    assertThat(textView3.getBottom(), is(flexboxLayout.getBottom()));
}
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