use of android.widget.TabHost.TabContentFactory in project robolectric by robolectric.
the class ShadowTabSpecTest method shouldSetTheContentView.
@Test
public void shouldSetTheContentView() throws Exception {
TabHost.TabSpec foo = new TabHost(RuntimeEnvironment.application).newTabSpec("Foo").setContent(new TabContentFactory() {
public View createTabContent(String tag) {
TextView tv = new TextView(RuntimeEnvironment.application);
tv.setText("The Text of " + tag);
return tv;
}
});
ShadowTabHost.ShadowTabSpec shadowFoo = shadowOf(foo);
TextView textView = (TextView) shadowFoo.getContentView();
assertThat(textView.getText().toString()).isEqualTo("The Text of Foo");
}
use of android.widget.TabHost.TabContentFactory in project robolectric by robolectric.
the class ShadowTabHostTest method shouldRetrieveTheCurrentViewFromTabContentFactory.
@Test
public void shouldRetrieveTheCurrentViewFromTabContentFactory() {
TabHost tabHost = new TabHost(RuntimeEnvironment.application);
TabHost.TabSpec foo = tabHost.newTabSpec("Foo").setContent(new TabContentFactory() {
public View createTabContent(String tag) {
TextView tv = new TextView(RuntimeEnvironment.application);
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");
}
Aggregations