1a57bc7b8f0568dee07215dd00f933d891a2f718
[JavaForFun] /
1 package name.gumartinm.weather.information.test;
2
3 import android.content.Intent;
4 import android.widget.Button;
5
6 public class WeatherInformationActivityUnitTest extends
7         ActivityUnitTestCase<WeatherInformationActivity> {
8
9     private WeatherInformationActivity activity;
10
11     public WeatherInformationActivityUnitTest() {
12         super(WeatherInformationActivity.class);
13     }
14
15     @Override
16     protected void setUp() throws Exception {
17         super.setUp();
18         final Intent intent = new Intent(this.getInstrumentation().getTargetContext(),
19                 WeatherInformationActivity.class);
20         this.startActivity(intent, null, null);
21         this.activity = this.getActivity();
22     }
23
24     public void testIntentTriggerViaOnClick() {
25         final int buttonweather = name.gumartinm.weather.information.R.id.buttonweather;
26         final Button view = (Button) this.activity.findViewById(buttonweather);
27         assertNotNull("Button Weather not allowed to be null", view);
28
29         view.performClick();
30
31         // TouchUtils cannot be used, only allowed in
32         // InstrumentationTestCase or ActivityInstrumentationTestCase2
33
34         // Check the intent which was started
35         final Intent triggeredIntent = this.getStartedActivityIntent();
36         assertNotNull("Intent was null", triggeredIntent);
37         final String data = triggeredIntent.getDataString();
38
39         assertEquals("Incorrect data passed via the intent",
40                 "http://gumartinm.name", data);
41     }
42 }