Created
July 9, 2012 12:07
-
-
Save kurthaeusler/3076103 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ActivityOneTest extends | |
android.test.ActivityInstrumentationTestCase2<ActivityOne> { | |
private ActivityOne thisActivity; | |
private Button bStartActivityTwo; | |
public ActivityOneTest() { | |
super("com.rocketeercoders.wotonio.ActivityOne", ActivityOne.class); | |
} | |
@Override | |
protected void setUp() throws Exception { | |
super.setUp(); | |
thisActivity = getActivity(); | |
bStartActivityTwo = (Button) thisActivity | |
.findViewById(com.rocketeercoders.wotonio.R.id.bStartActivityTwo); | |
} | |
@UiThreadTest | |
public void testHaveADrinkButtonPush() { | |
bStartActivityTwo.performClick(); | |
ActivityManager am = (ActivityManager) thisActivity | |
.getSystemService(Service.ACTIVITY_SERVICE); | |
List<ActivityManager.RunningTaskInfo> processes = am.getRunningTasks(1); | |
assertEquals(ActivityTwo.class.getName(), | |
processes.get(0).topActivity.getClassName()); | |
// This works, but leaves Activity2 in the foreground, and prevents the other tests from running. | |
// What I need is something like | |
// ActivityTwo activityTwo = ? | |
// activityTwo.finish(); | |
} | |
@UiThreadTest | |
public void anotherTest() { | |
// If the other test runs first, this test just freezes cos ActivityTwo is in the foreground. | |
// Actual test skipped... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment