ShadowTabSpec.java revision 89e9d844e025ab9de8ec19eaf4cb4c6022012254
1package com.xtremelabs.robolectric.shadows;
2
3import android.content.Intent;
4import android.graphics.drawable.Drawable;
5import android.view.View;
6import android.widget.TabHost;
7import android.widget.TabHost.TabContentFactory;
8
9import com.xtremelabs.robolectric.internal.Implementation;
10import com.xtremelabs.robolectric.internal.Implements;
11import com.xtremelabs.robolectric.internal.RealObject;
12
13@SuppressWarnings({"UnusedDeclaration"})
14@Implements(TabHost.TabSpec.class)
15public class ShadowTabSpec {
16
17    @RealObject
18    TabHost.TabSpec realObject;
19    private String tag;
20    private View indicatorView;
21    private Intent intent;
22	private int viewId;
23	private View contentView;
24	private CharSequence label;
25	private Drawable icon;
26
27    /**
28     * Non-Android accessor, sets the tag on the TabSpec
29     */
30    public void setTag(String tag) {
31        this.tag = tag;
32    }
33
34    @Implementation
35    public java.lang.String getTag() {
36        return tag;
37    }
38
39    /**
40     * Non-Android accessor
41     *
42     * @return the view object set in a call to {@code TabSpec#setIndicator(View)}
43     */
44    public View getIndicatorAsView() {
45        return this.indicatorView;
46    }
47
48    public String getIndicatorLabel() {
49        return this.label.toString();
50    }
51
52    public Drawable getIndicatorIcon() {
53        return this.icon;
54    }
55
56	/**
57	 * Same as GetIndicatorLabel()
58	 * @return
59	 */
60	public String getText() {
61		return label.toString();
62	}
63    @Implementation
64    public TabHost.TabSpec setIndicator(View view) {
65        this.indicatorView = view;
66        return realObject;
67    }
68
69    @Implementation
70    public TabHost.TabSpec setIndicator(CharSequence label) {
71    	this.label = label;
72        return realObject;
73    }
74
75    @Implementation
76    public TabHost.TabSpec setIndicator(CharSequence label, Drawable icon) {
77    	this.label = label;
78    	this.icon = icon;
79        return realObject;
80    }
81
82    /**
83     * Non-Android accessor
84     *
85     * @return the intent object set in a call to {@code TabSpec#setContent(Intent)}
86     */
87    public Intent getContentAsIntent() {
88        return intent;
89    }
90
91    @Implementation
92    public android.widget.TabHost.TabSpec setContent(Intent intent) {
93        this.intent = intent;
94        return realObject;
95    }
96
97    @Implementation
98    public android.widget.TabHost.TabSpec setContent(TabContentFactory factory) {
99    	contentView = factory.createTabContent(this.tag);
100        return realObject;
101    }
102
103
104    @Implementation
105    public android.widget.TabHost.TabSpec setContent(int viewId) {
106    	this.viewId = viewId;
107        return realObject;
108    }
109
110    public int getContentViewId() {
111    	return viewId;
112    }
113
114    public View getContentView() {
115    	return contentView;
116    }
117
118}
119