Search in sources :

Example 46 with FlakyTest

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

the class FlexboxAndroidTest method testAlignItems_flexStart_flexDirection_column.

@Test
@FlakyTest
public void testAlignItems_flexStart_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.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_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)));
    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)));
    // There should be 2 flex lines in the layout with the given layout.
    int flexLineSize = flexboxLayout.getWidth() / 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(textView3.getLeft(), isEqualAllowingError(flexLineSize));
}
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 47 with FlakyTest

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

the class FlexboxAndroidTest method testOrderAttribute_removeViewInMiddle.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.removeViewAt(2);
        }
    });
    assertNotNull(flexboxLayout);
    assertThat(flexboxLayout.getChildCount(), is(3));
    // order: -1, index 1
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(0)).getText().toString(), is(String.valueOf(2)));
    // order: 0, index 3
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(1)).getText().toString(), is(String.valueOf(4)));
    // order: 2, index 0
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(2)).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 48 with FlakyTest

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

the class FlexboxAndroidTest method testView_visibility_gone.

@Test
@FlakyTest
public void testView_visibility_gone() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_views_visibility_gone);
    // The text1 and text2's visibility are gone, so the visible view starts from text3
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW));
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text4)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text4)).check(isRightOf(withId(R.id.text3)));
    onView(withId(R.id.text5)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text5)).check(isBelow(withId(R.id.text3)));
    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);
    TextView textView5 = (TextView) activity.findViewById(R.id.text5);
    assertThat(textView1.getVisibility(), is(View.GONE));
    assertThat(textView2.getVisibility(), is(View.GONE));
    assertThat(textView4.getLeft(), is(textView3.getRight()));
    assertThat(textView5.getTop(), is(textView3.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)

Example 49 with FlakyTest

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

the class FlexboxAndroidTest method testJustifyContent_spaceAround_including_gone_views_direction_column.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
            flexboxLayout.setJustifyContent(FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND);
        }
    });
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND));
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int space = flexboxLayout.getHeight() - textView1.getHeight() - textView3.getHeight();
    // Divide by the number of visible children * 2
    space = space / 4;
    assertThat(textView1.getTop(), isEqualAllowingError(space));
    int spaceInMiddle = space * 2;
    assertThat(textView3.getTop() - textView1.getBottom(), isEqualAllowingError(spaceInMiddle));
    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 50 with FlakyTest

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

the class FlexboxAndroidTest method testMinHeight_initial_height_less_than_minHeight.

@Test
@FlakyTest
public void testMinHeight_initial_height_less_than_minHeight() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    // This test case verifies if the minHeight attribute works as a minimum constraint
    // If the initial view height is less than the value of minHeight.
    // The textView1's layout_height is set to wrap_content and its text is "1" apparently
    // the initial measured height is less than the value of layout_minHeight (100dp)
    FlexboxLayout flexboxLayout = createFlexboxLayout(R.layout.activity_minheight_test);
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    int minHeight = ((FlexboxLayout.LayoutParams) textView1.getLayoutParams()).minHeight;
    onView(withId(R.id.text1)).check(hasHeight(minHeight));
    onView(withId(R.id.text2)).check(hasHeight(flexboxLayout.getHeight() - minHeight));
}
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