Search in sources :

Example 71 with FlakyTest

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

the class FlexboxAndroidTest method testOrderAttribute_fromLayoutXml.

@Test
@FlakyTest
public void testOrderAttribute_fromLayoutXml() throws Throwable {
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_order_test);
    assertNotNull(flexboxLayout);
    assertThat(flexboxLayout.getChildCount(), is(4));
    // 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(3)));
    // order: 1, index 3
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(2)).getText().toString(), is(String.valueOf(4)));
    // order: 2, index 0
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(3)).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 72 with FlakyTest

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

the class FlexboxAndroidTest method testAlignItems_flexEnd_flexDirection_column.

@Test
@FlakyTest
public void testAlignItems_flexEnd_flexDirection_column() 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);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_FLEX_END));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    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.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)));
    onView(withId(R.id.text3)).check(isRightAlignedWith(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.getWidth(), not(flexLineSize));
    assertThat(textView2.getWidth(), not(flexLineSize));
    assertThat(textView3.getWidth(), not(flexLineSize));
    assertThat(textView1.getRight(), isEqualAllowingError(flexLineSize));
    assertThat(textView2.getRight(), isEqualAllowingError(flexLineSize));
    assertThat(textView3.getRight(), is(flexboxLayout.getRight()));
}
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 73 with FlakyTest

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

the class FlexboxAndroidTest method testFlexBasisPercent_nowrap_flexDirection_column.

@Test
@FlakyTest
public void testFlexBasisPercent_nowrap_flexDirection_column() 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);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    // The text1 length is 50%, the text2 length is 60% and the text3 has the fixed height,
    // 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));
    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)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(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 totalHeight = textView1.getHeight() + textView2.getHeight() + textView3.getHeight();
    // 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.getHeight(), isEqualAllowingError(totalHeight));
}
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 74 with FlakyTest

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

the class FlexboxAndroidTest method testEmptyChildren.

@Test
@FlakyTest
public void testEmptyChildren() throws Throwable {
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_empty_children);
    assertThat(flexboxLayout.getChildCount(), is(0));
}
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 75 with FlakyTest

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

the class FlexboxAndroidTest method testJustifyContent_flexEnd_flexDirection_column.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setJustifyContent(FlexboxLayout.JUSTIFY_CONTENT_FLEX_END);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_FLEX_END));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    onView(withId(R.id.text3)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isRightAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isAbove(withId(R.id.text3)));
    onView(withId(R.id.text1)).check(isAbove(withId(R.id.text2)));
}
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)

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