Search in sources :

Example 66 with TabHost

use of android.widget.TabHost in project robolectric by robolectric.

the class ShadowTabHostTest method shouldRetrieveTheCurrentViewFromTabContentFactory.

@Test
public void shouldRetrieveTheCurrentViewFromTabContentFactory() {
    TabHost tabHost = new TabHost(context);
    TabHost.TabSpec foo = tabHost.newTabSpec("Foo").setContent(tag -> {
        TextView tv = new TextView(context);
        tv.setText("The Text of " + tag);
        return tv;
    });
    tabHost.addTab(foo);
    tabHost.setCurrentTabByTag("Foo");
    TextView textView = (TextView) tabHost.getCurrentView();
    assertThat(textView.getText().toString()).isEqualTo("The Text of Foo");
}
Also used : TabHost(android.widget.TabHost) TextView(android.widget.TextView) Test(org.junit.Test)

Example 67 with TabHost

use of android.widget.TabHost in project robolectric by robolectric.

the class ShadowTabHostTest method shouldFireTheTabChangeListenerWhenCurrentTabIsSet.

@Test
public void shouldFireTheTabChangeListenerWhenCurrentTabIsSet() {
    TabHost tabHost = new TabHost(context);
    TabHost.TabSpec foo = tabHost.newTabSpec("Foo");
    TabHost.TabSpec bar = tabHost.newTabSpec("Bar");
    TabHost.TabSpec baz = tabHost.newTabSpec("Baz");
    tabHost.addTab(foo);
    tabHost.addTab(bar);
    tabHost.addTab(baz);
    TestOnTabChangeListener listener = new TestOnTabChangeListener();
    tabHost.setOnTabChangedListener(listener);
    tabHost.setCurrentTab(2);
    assertThat(listener.tag).isEqualTo("Baz");
}
Also used : TabHost(android.widget.TabHost) Test(org.junit.Test)

Example 68 with TabHost

use of android.widget.TabHost in project robolectric by robolectric.

the class ShadowTabHostTest method shouldGetTabWidget.

@Test
public void shouldGetTabWidget() {
    TabActivity activity = Robolectric.buildActivity(TabActivity.class).create().get();
    activity.setContentView(R.layout.tab_activity);
    TabHost host = new TabHost(activity);
    assertThat(host.getTabWidget()).isInstanceOf(TabWidget.class);
}
Also used : TabActivity(android.app.TabActivity) TabHost(android.widget.TabHost) Test(org.junit.Test)

Example 69 with TabHost

use of android.widget.TabHost in project robolectric by robolectric.

the class ShadowTabHostTest method canGetCurrentTab.

@Test
public void canGetCurrentTab() {
    TabHost tabHost = new TabHost(context);
    TabHost.TabSpec foo = tabHost.newTabSpec("Foo");
    TabHost.TabSpec bar = tabHost.newTabSpec("Bar");
    TabHost.TabSpec baz = tabHost.newTabSpec("Baz");
    tabHost.addTab(foo);
    tabHost.addTab(bar);
    tabHost.addTab(baz);
    assertThat(shadowOf(tabHost).getCurrentTabSpec()).isEqualTo(foo);
    assertThat(tabHost.getCurrentTab()).isEqualTo(0);
    tabHost.setCurrentTabByTag("Bar");
    assertThat(tabHost.getCurrentTab()).isEqualTo(1);
    assertThat(shadowOf(tabHost).getCurrentTabSpec()).isEqualTo(bar);
    tabHost.setCurrentTabByTag("Foo");
    assertThat(tabHost.getCurrentTab()).isEqualTo(0);
    assertThat(shadowOf(tabHost).getCurrentTabSpec()).isEqualTo(foo);
    tabHost.setCurrentTabByTag("Baz");
    assertThat(tabHost.getCurrentTab()).isEqualTo(2);
    assertThat(shadowOf(tabHost).getCurrentTabSpec()).isEqualTo(baz);
}
Also used : TabHost(android.widget.TabHost) Test(org.junit.Test)

Example 70 with TabHost

use of android.widget.TabHost in project robolectric by robolectric.

the class ShadowTabSpecTest method shouldGetAndSetTheIndicatorLabelAndIcon.

@Test
public void shouldGetAndSetTheIndicatorLabelAndIcon() {
    TabHost.TabSpec spec = new TabHost(context).newTabSpec("foo").setContent(R.layout.main).setIndicator("labelText", icon1);
    assertThat(shadowOf(spec).getIndicatorLabel()).isEqualTo("labelText");
    assertThat(shadowOf(spec).getText()).isEqualTo("labelText");
    assertThat(shadowOf(spec).getIndicatorIcon()).isSameInstanceAs(icon1);
}
Also used : TabHost(android.widget.TabHost) Test(org.junit.Test)

Aggregations

TabHost (android.widget.TabHost)74 View (android.view.View)29 Intent (android.content.Intent)21 ViewGroup (android.view.ViewGroup)19 ListView (android.widget.ListView)18 Test (org.junit.Test)17 TabWidget (android.widget.TabWidget)15 AdapterView (android.widget.AdapterView)13 AbsListView (android.widget.AbsListView)12 ExpandableListView (android.widget.ExpandableListView)12 TextView (android.widget.TextView)12 ActionMenuView (android.widget.ActionMenuView)10 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)10 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)10 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)10 MenuView (com.android.internal.view.menu.MenuView)10 FrameLayout (android.widget.FrameLayout)7 LinearLayout (android.widget.LinearLayout)7 AbsSpinner (android.widget.AbsSpinner)6 QuickContactBadge (android.widget.QuickContactBadge)6