summaryrefslogtreecommitdiffstats
path: root/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-02-11 22:29:02 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-10 17:40:54 +0100
commitc885a3c127a9ab64fad5535b6c1f9e42e4689f7b (patch)
tree52ce77898112155c41b179837fc3d6627bf53d54 /Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab
parent3c228228209bb186ab6881eb9b9bae10c1d5c893 (diff)
downloadcoursera-c885a3c127a9ab64fad5535b6c1f9e42e4689f7b.zip
coursera-c885a3c127a9ab64fad5535b6c1f9e42e4689f7b.tar.gz
Android : 03-Permissions: add
Diffstat (limited to 'Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab')
-rw-r--r--Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestBookmarks.java66
-rw-r--r--Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestDangerousApp.java63
2 files changed, 129 insertions, 0 deletions
diff --git a/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestBookmarks.java b/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestBookmarks.java
new file mode 100644
index 0000000..b06d383
--- /dev/null
+++ b/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestBookmarks.java
@@ -0,0 +1,66 @@
+package course.labs.permissionslab.test;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+import com.robotium.solo.Solo;
+
+import course.labs.permissionslab.ActivityLoaderActivity;
+
+public class TestBookmarks extends
+ActivityInstrumentationTestCase2<ActivityLoaderActivity> {
+ private Solo solo;
+
+ public TestBookmarks() {
+ super(ActivityLoaderActivity.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ }
+
+ public void testRun() {
+
+ int timeout = 5;
+
+ // Wait for activity:
+ // 'course.labs.permissionslab.ActivityLoaderActivity'
+ assertTrue(
+ "course.labs.permissionslab.ActivityLoaderActivity is not found!",
+ solo.waitForActivity(course.labs.permissionslab.ActivityLoaderActivity.class));
+
+ // Click on Bookmarks Activity
+ solo.clickOnView(solo
+ .getView(course.labs.permissionslab.R.id.start_bookmarks_button));
+
+ // Wait for activity: 'course.labs.permissionslab.BookmarksActivity'
+ assertTrue(
+ "course.labs.permissionslab.BookmarksActivity is not found!",
+ solo.waitForActivity(course.labs.permissionslab.BookmarksActivity.class));
+
+ // Click on Get Bookmarks
+ solo.clickOnView(solo
+ .getView(course.labs.permissionslab.R.id.get_bookmarks_button));
+
+ // Check for at least one bookmark
+ assertTrue("'www.google.com' is not displayed!",
+ solo.waitForText("http"));
+
+ // Assert Log message created - 'Entered startBookMarksActivity()'
+ assertTrue("'Entered startBookMarksActivity()' Log message not found.",
+ solo.waitForLogMessage("Entered startBookMarksActivity()",timeout));
+
+ // Assert Log message created - 'Entered loadBookmarks()'
+ assertTrue("'Entered loadBookmarks()' Log message not found.",
+ solo.waitForLogMessage("Entered loadBookmarks()",timeout));
+
+ // Assert Log message created - 'Bookmarks loaded'
+ assertTrue("'Bookmarks loaded' Log message not found.",
+ solo.waitForLogMessage("Bookmarks loaded",timeout));
+ }
+}
diff --git a/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestDangerousApp.java b/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestDangerousApp.java
new file mode 100644
index 0000000..1379006
--- /dev/null
+++ b/Android/03-Permissions/PermissionsLab/tests/src/course/labs/permissionslab/TestDangerousApp.java
@@ -0,0 +1,63 @@
+package course.labs.permissionslab.test;
+
+import course.labs.permissionslab.ActivityLoaderActivity;
+import com.robotium.solo.*;
+import android.test.ActivityInstrumentationTestCase2;
+
+
+public class TestDangerousApp extends ActivityInstrumentationTestCase2<ActivityLoaderActivity> {
+ private Solo solo;
+
+ public TestDangerousApp() {
+ super(ActivityLoaderActivity.class);
+ }
+
+ public void setUp() throws Exception {
+ solo = new Solo(getInstrumentation());
+ getActivity();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ }
+
+ public void testRun() {
+
+ int timeout = 5;
+
+ // Wait for activity: 'course.labs.permissionslab.ActivityLoaderActivity'
+ assertTrue("course.labs.permissionslab.ActivityLoaderActivity is not found!", solo.waitForActivity(course.labs.permissionslab.ActivityLoaderActivity.class));
+
+ // Click on Bookmarks Activity
+ solo.clickOnView(solo.getView(course.labs.permissionslab.R.id.start_bookmarks_button));
+
+ // Wait for activity: 'course.labs.permissionslab.BookmarksActivity'
+ assertTrue("course.labs.permissionslab.BookmarksActivity is not found!", solo.waitForActivity(course.labs.permissionslab.BookmarksActivity.class));
+
+ // Click on Go To DangerousActivity
+ solo.clickOnView(solo.getView(course.labs.permissionslab.R.id.go_to_dangerous_activity_button));
+
+
+ // Wait for activity: 'course.labs.permissionslab.GoToDangerousActivity'
+ assertTrue("course.labs.permissionslab.GoToDangerousActivity is not found!", solo.waitForActivity(course.labs.permissionslab.GoToDangerousActivity.class));
+
+ // Assert that: 'This button will load a Dangerous Level activity' is shown
+ assertTrue("'This button will load a Dangerous Level activity' is not shown!", solo.waitForText(java.util.regex.Pattern.quote("This button will load a Dangerous Level activity")));
+
+ // Click on Start Dangerous Activity
+ solo.clickOnView(solo.getView(course.labs.permissionslab.R.id.start_dangerous_activity_button));
+
+ // Assert Log message created - 'Entered startBookMarksActivity()'
+ assertTrue("'Entered startBookMarksActivity()' Log message not found.",
+ solo.waitForLogMessage("Entered startBookMarksActivity()",timeout));
+
+ // Assert Log message created - 'Entered startGoToDangerousActivity()'
+ assertTrue("'Entered startGoToDangerousActivity()' Log message not found.",
+ solo.waitForLogMessage("Entered startGoToDangerousActivity()",timeout));
+
+ // Assert Log message created - 'Entered startDangerousActivity()'
+ assertTrue("'Entered startDangerousActivity()' Log message not found.",
+ solo.waitForLogMessage("Entered startDangerousActivity()",timeout));
+ }
+}