Search in sources :

Example 1 with MainActivity

use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.

the class MainActivityTest method testAddFlexItem.

@Test
@FlakyTest
public void testAddFlexItem() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    int beforeCount = flexboxLayout.getChildCount();
    onView(withId(R.id.add_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 2 with MainActivity

use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.

the class MainActivityTest method testEditFragment_changeFlexBasisPercent.

@Test
@FlakyTest
public void testEditFragment_changeFlexBasisPercent() {
    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_basis_percent)).perform(replaceText("50"), 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() / 2));
}
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 3 with MainActivity

use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.

the class MainActivityTest method testEditFragment_changeFlexGrowFloat.

@Test
@FlakyTest
public void testEditFragment_changeFlexGrowFloat() {
    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.0"), 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 4 with MainActivity

use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.

the class MainActivityTest method testConfigurationChange.

@Test
@FlakyTest
public void testConfigurationChange() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    onView(withId(R.id.add_fab)).perform(click());
    onView(withId(R.id.add_fab)).perform(click());
    int beforeCount = flexboxLayout.getChildCount();
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    // Verify the flex items are restored across the configuration change.
    assertThat(flexboxLayout.getChildCount(), is(beforeCount));
}
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 5 with MainActivity

use of com.google.android.apps.flexbox.MainActivity in project flexbox-layout by google.

the class MainActivityTest method testEditFragment_changeOrder.

@Test
@FlakyTest
public void testEditFragment_changeOrder() {
    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_order)).perform(replaceText("3"), closeSoftKeyboard());
    onView(withId(R.id.button_ok)).perform(click());
    TextView first = (TextView) flexboxLayout.getReorderedChildAt(0);
    TextView second = (TextView) flexboxLayout.getReorderedChildAt(1);
    TextView third = (TextView) flexboxLayout.getReorderedChildAt(2);
    assertThat(first.getText().toString(), is("2"));
    assertThat(second.getText().toString(), is("3"));
    assertThat(third.getText().toString(), is("1"));
}
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)

Aggregations

FlakyTest (android.support.test.filters.FlakyTest)12 MediumTest (android.support.test.filters.MediumTest)12 MainActivity (com.google.android.apps.flexbox.MainActivity)12 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)12 Test (org.junit.Test)12 NavigationView (android.support.design.widget.NavigationView)5 Menu (android.view.Menu)5 ArrayAdapter (android.widget.ArrayAdapter)5 Spinner (android.widget.Spinner)5 TextView (android.widget.TextView)4