use of android.support.test.annotation.UiThreadTest in project material-components-android by material-components.
the class BottomNavigationViewTest method testItemChecking.
@UiThreadTest
@Test
@SmallTest
public void testItemChecking() throws Throwable {
final Menu menu = mBottomNavigation.getMenu();
assertTrue(menu.getItem(0).isChecked());
checkAndVerifyExclusiveItem(menu, R.id.destination_home);
checkAndVerifyExclusiveItem(menu, R.id.destination_profile);
checkAndVerifyExclusiveItem(menu, R.id.destination_people);
}
use of android.support.test.annotation.UiThreadTest in project material-components-android by material-components.
the class TabLayoutPoolingTest method testUsingTabsFromOtherInstance.
@UiThreadTest
@SmallTest
@Test
public void testUsingTabsFromOtherInstance() {
final Activity activity = activityTestRule.getActivity();
// TabLayout1 has items added via the layout, so we'll just check they're
// there first
final TabLayout tabLayout1 = (TabLayout) activity.findViewById(R.id.tabs_1);
assertTrue(tabLayout1.getTabCount() > 0);
// Now remove all tabs. TabLayout will pool the Tab instances...
tabLayout1.removeAllTabs();
// Now add some tabs to the second TabLayout and make sure that we don't crash
final TabLayout tabLayout2 = (TabLayout) activity.findViewById(R.id.tabs_2);
tabLayout2.addTab(tabLayout2.newTab());
tabLayout2.addTab(tabLayout2.newTab());
tabLayout2.addTab(tabLayout2.newTab());
}
use of android.support.test.annotation.UiThreadTest in project material-components-android by material-components.
the class TabLayoutTest method testTabWithCustomLayoutSelection2.
@Test
@UiThreadTest
public void testTabWithCustomLayoutSelection2() {
final TabLayout.OnTabSelectedListener mockListener = mock(TabLayout.OnTabSelectedListener.class);
final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
final TabLayout tabLayout = (TabLayout) inflater.inflate(R.layout.design_tabs, null);
tabLayout.addOnTabSelectedListener(mockListener);
final TabLayout.Tab tab = tabLayout.newTab();
tabLayout.addTab(tab);
verify(mockListener, times(1)).onTabSelected(eq(tab));
verify(mockListener, times(0)).onTabUnselected(any(TabLayout.Tab.class));
tab.setCustomView(R.layout.design_tab_item_custom);
assertNotNull("Tab has custom view", tab.getCustomView());
assertEquals("First tab is selected", 0, tabLayout.getSelectedTabPosition());
assertTabCustomViewSelected(tabLayout);
}
use of android.support.test.annotation.UiThreadTest in project material-components-android by material-components.
the class TabLayoutTest method testInflateTabLayoutWithNonTabItem.
@Test
@UiThreadTest
public void testInflateTabLayoutWithNonTabItem() throws Throwable {
try {
final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
inflater.inflate(R.layout.design_tabs_with_non_tabitems, null);
} catch (Throwable throwable) {
assertTrue(throwable instanceof InflateException || throwable instanceof IllegalArgumentException);
}
}
use of android.support.test.annotation.UiThreadTest in project material-components-android by material-components.
the class TabLayoutTest method testMultipleTabsWithCustomLayoutSelection2.
@Test
@UiThreadTest
public void testMultipleTabsWithCustomLayoutSelection2() {
final TabLayout.OnTabSelectedListener mockListener = mock(TabLayout.OnTabSelectedListener.class);
final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
final TabLayout tabs = (TabLayout) inflater.inflate(R.layout.design_tabs, null);
tabs.addOnTabSelectedListener(mockListener);
final TabLayout.Tab tab1 = tabs.newTab();
tabs.addTab(tab1);
verify(mockListener, times(1)).onTabSelected(eq(tab1));
verify(mockListener, times(0)).onTabUnselected(any(TabLayout.Tab.class));
final TabLayout.Tab tab2 = tabs.newTab();
tabs.addTab(tab2, true);
verify(mockListener, times(1)).onTabSelected(eq(tab2));
verify(mockListener, times(1)).onTabUnselected(eq(tab1));
final TabLayout.Tab tab3 = tabs.newTab();
tabs.addTab(tab3);
verifyNoMoreInteractions(mockListener);
tabs.getTabAt(0).setCustomView(R.layout.design_tab_item_custom);
tabs.getTabAt(1).setCustomView(R.layout.design_tab_item_custom);
tabs.getTabAt(2).setCustomView(R.layout.design_tab_item_custom);
assertEquals("Second tab is selected", 1, tabs.getSelectedTabPosition());
assertTabCustomViewSelected(tabs);
}
Aggregations