summaryrefslogtreecommitdiffstats
path: root/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs
diff options
context:
space:
mode:
Diffstat (limited to 'Android/01-TheActivityClass/ActivityLab/tests/src/course/labs')
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java52
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java62
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java64
3 files changed, 178 insertions, 0 deletions
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java
new file mode 100644
index 0000000..6f85ad3
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test1.java
@@ -0,0 +1,52 @@
+package course.labs.activitylab.test;
+
+import course.labs.activitylab.ActivityOne;
+import com.robotium.solo.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class Test1 extends ActivityInstrumentationTestCase2<ActivityOne> {
+ private Solo solo;
+
+ public Test1() {
+ super(ActivityOne.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ assertTrue("Activity stack not empty.", solo.waitForEmptyActivityStack(5000));
+ }
+
+ public void testRun() {
+ // Wait for activity: 'course.labs.activitylab.ActivityOne'
+ assertTrue("course.labs.activitylab.ActivityOne is not found!", solo.waitForActivity(course.labs.activitylab.ActivityOne.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.LANDSCAPE);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 2"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 2"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.PORTRAIT);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 3"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 3"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 3"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java
new file mode 100644
index 0000000..89fd34e
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java
@@ -0,0 +1,62 @@
+package course.labs.activitylab.test;
+
+import course.labs.activitylab.ActivityOne;
+import com.robotium.solo.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class Test2 extends ActivityInstrumentationTestCase2<ActivityOne> {
+ private Solo solo;
+
+ public Test2() {
+ super(ActivityOne.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ assertTrue("Activity stack not empty.", solo.waitForEmptyActivityStack(5000));
+ }
+
+ public void testRun() {
+ // Wait for activity: 'course.labs.activitylab.ActivityOne'
+ assertTrue("course.labs.activitylab.ActivityOne is not found!", solo.waitForActivity(course.labs.activitylab.ActivityOne.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Click on Start Activity Two
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ // Wait for activity: 'course.labs.activitylab.ActivityTwo'
+ assertTrue("course.labs.activitylab.ActivityTwo is not found!", solo.waitForActivity(course.labs.activitylab.ActivityTwo.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.LANDSCAPE);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 2"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 2"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Rotate the screen
+ solo.setActivityOrientation(Solo.PORTRAIT);
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 3"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 3"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 3"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+ }
+}
diff --git a/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java
new file mode 100644
index 0000000..5582c13
--- /dev/null
+++ b/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java
@@ -0,0 +1,64 @@
+package course.labs.activitylab.test;
+
+import course.labs.activitylab.ActivityOne;
+import com.robotium.solo.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class Test3 extends ActivityInstrumentationTestCase2<ActivityOne> {
+ private Solo solo;
+
+ public Test3() {
+ super(ActivityOne.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ assertTrue("Activity stack not empty.", solo.waitForEmptyActivityStack(5000));
+ }
+
+ public void testRun() {
+ // Wait for activity: 'course.labs.activitylab.ActivityOne'
+ assertTrue("course.labs.activitylab.ActivityOne is not found!", solo.waitForActivity(course.labs.activitylab.ActivityOne.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Click on Start Activity Two
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ // Wait for activity: 'course.labs.activitylab.ActivityTwo'
+ assertTrue("course.labs.activitylab.ActivityTwo is not found!", solo.waitForActivity(course.labs.activitylab.ActivityTwo.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+
+ // Click on Close Activity
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bClose));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 2"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 1"));
+
+ // Click on Start Activity Two
+ solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ // Wait for activity: 'course.labs.activitylab.ActivityTwo'
+ assertTrue("course.labs.activitylab.ActivityTwo is not found!", solo.waitForActivity(course.labs.activitylab.ActivityTwo.class));
+ // Check for proper counts
+ assertTrue("onCreate() count was off.", solo.searchText("onCreate\\(\\) calls: 1"));
+ assertTrue("onStart() count was off.", solo.searchText("onStart\\(\\) calls: 1"));
+ assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 1"));
+ assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 0"));
+ }
+}