summaryrefslogtreecommitdiffstats
path: root/Android/01-TheActivityClass/ActivityLab/tests/src/course/labs
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-02-02 10:40:01 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-10 17:40:54 +0100
commit69f572ee6d139e9c88e382ad9489d3c5d77a6876 (patch)
tree9d5f537a0bf5b2a5d09bb35910b05b797d5c211a /Android/01-TheActivityClass/ActivityLab/tests/src/course/labs
parente951bbe638b4af5330d68394a1a37e1b118bab28 (diff)
downloadcoursera-69f572ee6d139e9c88e382ad9489d3c5d77a6876.zip
coursera-69f572ee6d139e9c88e382ad9489d3c5d77a6876.tar.gz
Android : 01-TheActivityClass: update tests
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.java87
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test2.java97
-rw-r--r--Android/01-TheActivityClass/ActivityLab/tests/src/course/labs/activitylab/test/Test3.java34
3 files changed, 181 insertions, 37 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
index 6f85ad3..7be4697 100644
--- 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
@@ -5,7 +5,6 @@ import com.robotium.solo.*;
import android.test.ActivityInstrumentationTestCase2;
-
public class Test1 extends ActivityInstrumentationTestCase2<ActivityOne> {
private Solo solo;
@@ -21,32 +20,90 @@ public class Test1 extends ActivityInstrumentationTestCase2<ActivityOne> {
@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));
+ 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"));
+ 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"));
+
+ // Check for log messages
+ assertTrue("Log message for 'onCreate()' was not found in Log",
+ solo.waitForLogMessage("onCreate", 5));
+ assertTrue("Log message for 'onStart()' was not found in Log",
+ solo.waitForLogMessage("onStart", 5));
+ assertTrue("Log message for 'onResume()' was not found in Log",
+ solo.waitForLogMessage("onResume", 5));
+
+ // Clear the log
+ solo.clearLog();
// Rotate the screen
solo.setActivityOrientation(Solo.LANDSCAPE);
+
+ // 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: 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"));
+ 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"));
+
+ // Check for log messages
+ assertTrue("Log message for 'onPause()' was not found in the Log",
+ solo.waitForLogMessage("onPause", 5));
+ assertTrue("Log message for onCreate()' was not found in the Log",
+ solo.waitForLogMessage("onCreate", 5));
+ assertTrue("Log message for onStart()' was not found in the Log",
+ solo.waitForLogMessage("onStart", 5));
+ assertTrue("Log message for onResume()' was not found in the Log",
+ solo.waitForLogMessage("onResume", 5));
+
+ // Clear the log
+ solo.clearLog();
// Rotate the screen
solo.setActivityOrientation(Solo.PORTRAIT);
+
+ // 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: 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"));
+ 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"));
+
+ // Check for log messages
+ assertTrue("Log message for 'onPause()' was not found in the Log",
+ solo.waitForLogMessage("onPause", 5));
+ assertTrue("Log message for 'onCreate()' was not found in the Log",
+ solo.waitForLogMessage("onCreate", 5));
+ assertTrue("Log message for 'onStart()' was not found in the Log",
+ solo.waitForLogMessage("onStart", 5));
+ assertTrue("Log message for 'onResume()' was not found in the Log",
+ solo.waitForLogMessage("onResume", 5));
}
}
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
index 89fd34e..9718fa5 100644
--- 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
@@ -5,7 +5,6 @@ import com.robotium.solo.*;
import android.test.ActivityInstrumentationTestCase2;
-
public class Test2 extends ActivityInstrumentationTestCase2<ActivityOne> {
private Solo solo;
@@ -21,42 +20,98 @@ public class Test2 extends ActivityInstrumentationTestCase2<ActivityOne> {
@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));
+ 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"));
+ 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"));
+
+ assertTrue("Log message for 'onCreate()' was not found in Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for 'onStart()' was not found in Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for 'onResume()' was not found in Log", solo.waitForLogMessage("onResume",5));
+
+ solo.clearLog();
// Click on Start Activity Two
- solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bLaunchActivityTwo));
+ 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));
+ 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"));
+ 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"));
+
+ assertTrue("Log message for 'onPause()' was not found in the Log", solo.waitForLogMessage("onPause",5));
+ assertTrue("Log message for 'onCreate()' was not found in the Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for 'onStart()' was not found in the Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for 'onResume()' was not found in the Log", solo.waitForLogMessage("onResume",5));
+
+ solo.clearLog();
// Rotate the screen
solo.setActivityOrientation(Solo.LANDSCAPE);
+
+ // 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: 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"));
+ 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"));
+
+ assertTrue("Log message for 'onPause()' was not found in the Log", solo.waitForLogMessage("onPause",5));
+ assertTrue("Log message for 'onCreate()' was not found in the Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for 'onStart()' was not found in the Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for 'onResume()' was not found in the Log", solo.waitForLogMessage("onResume",5));
+
+ solo.clearLog();
// Rotate the screen
solo.setActivityOrientation(Solo.PORTRAIT);
+
+ // 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: 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"));
+ 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"));
+
+ assertTrue("Log message for 'onPause()' was not found in the Log", solo.waitForLogMessage("onPause",5));
+ assertTrue("Log message for 'onCreate()' was not found in the Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for 'onStart()' was not found in the Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for 'onResume()' was not found in the Log", solo.waitForLogMessage("onResume",5));
}
}
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
index 5582c13..1046ec4 100644
--- 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
@@ -21,44 +21,76 @@ public class Test3 extends ActivityInstrumentationTestCase2<ActivityOne> {
@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"));
+ assertTrue("Log message for 'onCreate()' was not found in the Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for 'onStart()' was not found in Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for 'onResume()' was not found in Log", solo.waitForLogMessage("onResume",5));
+
+ solo.clearLog();
+
// 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"));
+ assertTrue("Log message for 'onPause()' was not found in the Log", solo.waitForLogMessage("onPause",5));
+ assertTrue("Log message for 'onCreate()' was not found in the Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for onStart()' was not found in the Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for onResume()' was not found in the Log", solo.waitForLogMessage("onResume",5));
+
+ solo.clearLog();
+
// Click on Close Activity
solo.clickOnView(solo.getView(course.labs.activitylab.R.id.bClose));
+
+ // 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: 2"));
assertTrue("onResume() count was off.", solo.searchText("onResume\\(\\) calls: 2"));
assertTrue("onRestart() count was off.", solo.searchText("onRestart\\(\\) calls: 1"));
+ assertTrue("Log message for 'onPause()' was not found in the Log", solo.waitForLogMessage("onPause",5));
+ assertTrue("Log message for onRestart()' was not found in the Log", solo.waitForLogMessage("onRestart",5));
+ assertTrue("Log message for onStart()' was not found in the Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for onResume()' was not found in the Log", solo.waitForLogMessage("onResume",5));
+
+ solo.clearLog();
+
// 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"));
+
+ assertTrue("Log message for 'onPause()' was not found in the Log", solo.waitForLogMessage("onPause",5));
+ assertTrue("Log message for onCreate()' was not found in the Log", solo.waitForLogMessage("onCreate",5));
+ assertTrue("Log message for onStart()' was not found in the Log", solo.waitForLogMessage("onStart",5));
+ assertTrue("Log message for onResume()' was not found in the Log", solo.waitForLogMessage("onResume",5));
}
}