summaryrefslogtreecommitdiffstats
path: root/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-02-12 22:33:14 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-10 17:40:54 +0100
commitee3ef2bcf3656e3e7a02d86d43858cc8145508da (patch)
treec428969d47180877913f95201067f4b750f91b2a /Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab
parent339c57d3520c8de6f970b020c87f77ec266f3bf8 (diff)
downloadcoursera-ee3ef2bcf3656e3e7a02d86d43858cc8145508da.zip
coursera-ee3ef2bcf3656e3e7a02d86d43858cc8145508da.tar.gz
Android : 02-Intents: add
Diffstat (limited to 'Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab')
-rw-r--r--Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ExplicitTest.java72
-rw-r--r--Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ImplicitTest.java58
2 files changed, 130 insertions, 0 deletions
diff --git a/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ExplicitTest.java b/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ExplicitTest.java
new file mode 100644
index 0000000..461bb8e
--- /dev/null
+++ b/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ExplicitTest.java
@@ -0,0 +1,72 @@
+package course.labs.intentslab.test;
+
+import course.labs.intentslab.ActivityLoaderActivity;
+import com.robotium.solo.*;
+import android.test.ActivityInstrumentationTestCase2;
+
+public class ExplicitTest extends ActivityInstrumentationTestCase2<ActivityLoaderActivity> {
+ private Solo solo;
+
+ public ExplicitTest() {
+ 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.intentslab.ActivityLoaderActivity'
+ assertTrue(
+ "course.labs.intentslab.ActivityLoaderActivity is not found!",
+ solo.waitForActivity(course.labs.intentslab.ActivityLoaderActivity.class));
+
+ // Click on Explicit Activation
+ solo.clickOnView(solo
+ .getView(course.labs.intentslab.R.id.explicit_activation_button));
+
+ // Wait for activity: 'course.labs.intentslab.ExplicitlyLoadedActivity'
+ assertTrue(
+ "course.labs.intentslab.ExplicitlyLoadedActivity is not found!",
+ solo.waitForActivity(course.labs.intentslab.ExplicitlyLoadedActivity.class));
+ // Hide the soft keyboard
+ solo.hideSoftKeyboard();
+ // Enter the text: 'test'
+ solo.clearEditText((android.widget.EditText) solo
+ .getView(course.labs.intentslab.R.id.editText));
+ solo.enterText((android.widget.EditText) solo
+ .getView(course.labs.intentslab.R.id.editText), "test");
+ // Hide the soft keyboard
+ solo.hideSoftKeyboard();
+ // Click on Enter
+ solo.clickOnView(solo.getView(course.labs.intentslab.R.id.enter_button));
+
+ // Assert that: 'textView1' is shown
+ assertTrue("textView1 is not shown!", solo.waitForView(solo
+ .getView(course.labs.intentslab.R.id.textView1)));
+ // assert that the string 'test' is found on the display
+ assertTrue("'test' is not displayed!", solo.searchText("test"));
+
+ // Assert that: Log Message 'Entered startExplicitActivation() is shown
+ assertTrue(
+ "Log message - 'Entered startExplicitActivation()' is not shown!",
+ solo.waitForLogMessage("Entered startExplicitActivation()",
+ timeout));
+ // Assert that: Log Message 'Entered enterClicked()' is shown
+ assertTrue("Log message - 'Entered enterClicked()' is not shown",
+ solo.waitForLogMessage("Entered enterClicked()", timeout));
+
+ // Assert that: Log Message 'Entered onActivityResult()' is shown
+ assertTrue("Log message - 'Entered onActivityResult()",
+ solo.waitForLogMessage("Entered onActivityResult()", timeout));
+ }
+}
diff --git a/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ImplicitTest.java b/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ImplicitTest.java
new file mode 100644
index 0000000..be7deb7
--- /dev/null
+++ b/Android/02-Intents/IntentsLab/tests/src/course/labs/intentslab/ImplicitTest.java
@@ -0,0 +1,58 @@
+package course.labs.intentslab.test;
+
+import course.labs.intentslab.ActivityLoaderActivity;
+import com.robotium.solo.*;
+import android.test.ActivityInstrumentationTestCase2;
+
+public class ImplicitTest extends ActivityInstrumentationTestCase2<ActivityLoaderActivity> {
+ private Solo solo;
+
+ public ImplicitTest() {
+ 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.intentslab.ActivityLoaderActivity'
+ assertTrue(
+ "course.labs.intentslab.ActivityLoaderActivity is not found!",
+ solo.waitForActivity(course.labs.intentslab.ActivityLoaderActivity.class));
+
+ // Click on Implicit Activation
+ solo.clickOnView(solo
+ .getView(course.labs.intentslab.R.id.implicit_activation_button));
+
+ // Assert that: Log Message 'Entered startImplicitActivation() is shown
+ assertTrue(
+ "Log message - 'Entered startImplicitActivation()' is not shown!",
+ solo.waitForLogMessage("Entered startImplicitActivation()",
+ timeout));
+
+ // Assert that: 'Chooser Intent Action:android.intent.action.CHOOSER' is
+ // shown
+ assertTrue(
+ "Log message - 'Chooser Intent Action:android.intent.action.CHOOSER' is not shown",
+ solo.waitForLogMessage(
+ "Chooser Intent Action:android.intent.action.CHOOSER",
+ timeout));
+
+ // Wait for activity: 'com.android.internal.app.ChooserActivity'
+ assertTrue("ChooserActivity is not found!",
+ solo.waitForActivity("ChooserActivity"));
+
+ // Click on MyBrowser
+ solo.clickInList(2, 0);
+ }
+}