summaryrefslogtreecommitdiffstats
path: root/Android/01-TheActivityClass/ActivityLab/tests/src/course
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-01-31 16:28:09 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-10 17:40:54 +0100
commite951bbe638b4af5330d68394a1a37e1b118bab28 (patch)
tree5268102bc54d3adc81ae112000c8b6b926f730f7 /Android/01-TheActivityClass/ActivityLab/tests/src/course
parent12a106bba4cf6ac9a8e9aa62c5f4fc4e6ba65b38 (diff)
downloadcoursera-e951bbe638b4af5330d68394a1a37e1b118bab28.zip
coursera-e951bbe638b4af5330d68394a1a37e1b118bab28.tar.gz
Android : 01-TheActivityClass: add
Diffstat (limited to 'Android/01-TheActivityClass/ActivityLab/tests/src/course')
-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"));
+ }
+}