use of com.google.android.apps.flexbox.MainActivity 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));
}
use of com.google.android.apps.flexbox.MainActivity 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));
}
use of com.google.android.apps.flexbox.MainActivity 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()));
}
use of com.google.android.apps.flexbox.MainActivity 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));
}
use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.
the class MainActivityTest method testFlexWrapSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testFlexWrapSpinner() {
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_wrap));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int wrapReversePosition = spinnerAdapter.getPosition(activity.getString(R.string.wrap_reverse));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(wrapReversePosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE));
final int noWrapPosition = spinnerAdapter.getPosition(activity.getString(R.string.nowrap));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(noWrapPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_NOWRAP));
}
Aggregations