Search in sources :

Example 41 with FlakyTest

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

the class FlexboxAndroidTest method testOrderAttribute_removeLastView.

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

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

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

the class FlexboxAndroidTest method testAlignContent_spaceAround.

@Test
@FlakyTest
public void testAlignContent_spaceAround() 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_SPACE_AROUND);
        }
    });
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_SPACE_AROUND));
    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)));
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int spaceAround = flexboxLayout.getHeight() - textView1.getHeight() - textView3.getHeight();
    // Divide by the number of flex lines * 2
    spaceAround /= 4;
    assertThat(textView1.getTop(), isEqualAllowingError(spaceAround));
    int spaceInMiddle = textView1.getBottom() + spaceAround * 2;
    assertThat(textView3.getTop(), isEqualAllowingError(spaceInMiddle));
    assertThat(flexboxLayout.getFlexLines().size(), is(2));
}
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 43 with FlakyTest

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

the class FlexboxAndroidTest method testAlignItems_center_wrapReverse_flexDirection_column.

@Test
@FlakyTest
public void testAlignItems_center_wrapReverse_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.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE);
            flexboxLayout.setAlignItems(FlexboxLayout.ALIGN_ITEMS_CENTER);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_CENTER));
    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE));
    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)));
    // 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);
    // All TextView's widths are the same. No issues should be found if using the first
    // TextView to calculate the space above and below
    int spaceLeftAndRight = (flexLineSize - textView1.getWidth()) / 2;
    assertThat(textView1.getWidth(), not(flexLineSize));
    assertThat(textView2.getWidth(), not(flexLineSize));
    assertThat(textView3.getWidth(), not(flexLineSize));
    assertThat(textView1.getRight(), isEqualAllowingError(flexboxLayout.getWidth() - spaceLeftAndRight));
    assertThat(textView2.getRight(), isEqualAllowingError(flexboxLayout.getWidth() - spaceLeftAndRight));
    assertThat(textView3.getRight(), isEqualAllowingError(flexboxLayout.getWidth() - flexLineSize - spaceLeftAndRight));
}
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 44 with FlakyTest

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

the class FlexboxAndroidTest method testFlexItem_match_parent_flexDirection_column.

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

        @Override
        public void apply(FlexboxLayout flexboxLayout) {
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    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.getHeight(), is(flexboxLayout.getHeight()));
    assertThat(text2.getHeight(), is(flexboxLayout.getHeight()));
    assertThat(text3.getHeight(), is(flexboxLayout.getHeight()));
    assertThat(flexboxLayout.getWidth(), is(text1.getWidth() + text2.getWidth() + text3.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 45 with FlakyTest

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

the class FlexboxAndroidTest method testJustifyContent_spaceAround_flexDirection_column.

@Test
@FlakyTest
public void testJustifyContent_spaceAround_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_SPACE_AROUND);
            flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
        }
    });
    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND));
    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(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    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();
    // Divide by the number of children * 2
    space = space / 6;
    assertThat(textView1.getTop(), isEqualAllowingError(space));
    int spaceInMiddle = space * 2;
    assertThat(textView2.getTop() - textView1.getBottom(), isEqualAllowingError(spaceInMiddle));
    assertThat(textView3.getTop() - textView2.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)

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