use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.
the class MainActivityTest method testJustifyContentSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testJustifyContentSpinner() {
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_justify_content));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int spaceBetweenPosition = spinnerAdapter.getPosition(activity.getString(R.string.space_between));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(spaceBetweenPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_BETWEEN));
final int centerPosition = spinnerAdapter.getPosition(activity.getString(R.string.center));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(centerPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_CENTER));
}
use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.
the class MainActivityTest method testAlignItemsSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testAlignItemsSpinner() {
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_items));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int baselinePosition = spinnerAdapter.getPosition(activity.getString(R.string.baseline));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(baselinePosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_BASELINE));
final int flexEndPosition = spinnerAdapter.getPosition(activity.getString(R.string.flex_end));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(flexEndPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_FLEX_END));
}
Aggregations