blob: df30d07b9026d29b85c63a0daf73ee77b23962b4 [file] [log] [blame]
package com.android.tests.dependencies;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.widget.TextView;
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
private TextView mTextView;
/**
* Creates an {@link ActivityInstrumentationTestCase2} that tests the {@link MainActivity} activity.
*/
public MainActivityTest() {
super(MainActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
final MainActivity a = getActivity();
// ensure a valid handle to the activity has been returned
assertNotNull(a);
mTextView = (TextView) a.findViewById(R.id.text);
}
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@SmallTest
public void testPreconditions() {
assertNotNull(mTextView);
}
@SmallTest
public void testPackageOnly() {
assertEquals("Foo-helper", mTextView.getText());
}
public void testProvided() {
boolean exception = false;
try {
getActivity().getString2("foo");
} catch (Throwable t) {
exception = true;
}
assertTrue(exception);
}
}