Search in sources :

Example 6 with FlakyTest

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

the class MainActivityTest method testFlexDirectionSpinner.

@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testFlexDirectionSpinner() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
    assertNotNull(navigationView);
    Menu menu = navigationView.getMenu();
    final Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.menu_item_flex_direction));
    ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
    final int columnPosition = spinnerAdapter.getPosition(activity.getString(R.string.column));
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            spinner.setSelection(columnPosition);
        }
    });
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
    final int rowReversePosition = spinnerAdapter.getPosition(activity.getString(R.string.row_reverse));
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            spinner.setSelection(rowReversePosition);
        }
    });
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW_REVERSE));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) NavigationView(android.support.design.widget.NavigationView) Spinner(android.widget.Spinner) MainActivity(com.google.android.apps.flexbox.MainActivity) Menu(android.view.Menu) ArrayAdapter(android.widget.ArrayAdapter) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 7 with FlakyTest

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

the class MainActivityTest method testAlignContentSpinner.

@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testAlignContentSpinner() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
    assertNotNull(navigationView);
    Menu menu = navigationView.getMenu();
    final Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.menu_item_align_content));
    ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
    final int spaceAroundPosition = spinnerAdapter.getPosition(activity.getString(R.string.space_around));
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            spinner.setSelection(spaceAroundPosition);
        }
    });
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_SPACE_AROUND));
    final int stretchPosition = spinnerAdapter.getPosition(activity.getString(R.string.stretch));
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            spinner.setSelection(stretchPosition);
        }
    });
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) NavigationView(android.support.design.widget.NavigationView) Spinner(android.widget.Spinner) MainActivity(com.google.android.apps.flexbox.MainActivity) Menu(android.view.Menu) ArrayAdapter(android.widget.ArrayAdapter) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 8 with FlakyTest

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

the class MainActivityTest method testEditFragment_changeFlexGrow.

@Test
@FlakyTest
public void testEditFragment_changeFlexGrow() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    onView(withId(R.id.textview1)).perform(click());
    onView(withId(R.id.edit_text_flex_grow)).perform(replaceText("1"), closeSoftKeyboard());
    onView(withId(R.id.button_ok)).perform(click());
    TextView first = (TextView) activity.findViewById(R.id.textview1);
    TextView second = (TextView) activity.findViewById(R.id.textview2);
    TextView third = (TextView) activity.findViewById(R.id.textview3);
    assertNotNull(first);
    assertNotNull(second);
    assertNotNull(third);
    assertThat(first.getWidth(), is(flexboxLayout.getWidth() - second.getWidth() - third.getWidth()));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) TextView(android.widget.TextView) MainActivity(com.google.android.apps.flexbox.MainActivity) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 9 with FlakyTest

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

the class MainActivityTest method testRemoveFlexItem.

@Test
@FlakyTest
public void testRemoveFlexItem() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    int beforeCount = flexboxLayout.getChildCount();
    onView(withId(R.id.remove_fab)).perform(click());
    assertThat(flexboxLayout.getChildCount(), is(beforeCount - 1));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) MainActivity(com.google.android.apps.flexbox.MainActivity) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 10 with FlakyTest

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

the class FlexboxAndroidTest method testDivider_directionRow_horizontalEnd.

@Test
@FlakyTest
public void testDivider_directionRow_horizontalEnd() 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_END);
            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_END));
    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() + divider.getIntrinsicHeight(), 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)

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