diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-02-13 22:15:10 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-10 17:40:55 +0100 |
commit | aa33f187990a0858de0252c96a695d984ba9b924 (patch) | |
tree | 91af28db188e57b41e7e8df19df95d6a0fe82392 /Android/04-TheFragmentClass/FragmentsLab/tests/src | |
parent | f14e5dbbdf84a5bc068e3a1cfd104e876dd6da61 (diff) | |
download | coursera-aa33f187990a0858de0252c96a695d984ba9b924.zip coursera-aa33f187990a0858de0252c96a695d984ba9b924.tar.gz |
Android : 04-TheFragmentClass: add
Diffstat (limited to 'Android/04-TheFragmentClass/FragmentsLab/tests/src')
2 files changed, 226 insertions, 0 deletions
diff --git a/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/PhoneTest.java b/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/PhoneTest.java new file mode 100644 index 0000000..e48118f --- /dev/null +++ b/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/PhoneTest.java @@ -0,0 +1,118 @@ +package course.labs.fragmentslab.test; + +import course.labs.fragmentslab.MainActivity; +import com.robotium.solo.*; +import android.test.ActivityInstrumentationTestCase2; + +public class PhoneTest extends ActivityInstrumentationTestCase2<MainActivity> { + private Solo solo; + + public PhoneTest() { + super(MainActivity.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.fragmentslab.MainActivity' + assertTrue("MainActivity not found", solo.waitForActivity( + course.labs.fragmentslab.MainActivity.class, 2000)); + + // Wait for view: 'android.R.id.text1' + assertTrue("text1 not found", solo.waitForView(android.R.id.text1)); + + // Click on ladygaga + solo.clickOnView(solo.getView(android.R.id.text1)); + + assertTrue("feed_view not found", solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Assert that: 'the audience cheering!' is shown + assertTrue("'the audience cheering!' is not shown!", + solo.searchText("the audience cheering!")); + + // Wait for onActivityCreated() Log Message: + assertTrue("onActivityCreated() Log Message not found", + solo.waitForLogMessage("Entered onActivityCreated()",timeout)); + + // Wait for onItemSelected(0) Log Message: + assertTrue("onItemSelected(0) Log Message not found", + solo.waitForLogMessage("Entered onItemSelected(0)",timeout)); + + // Wait for updateFeedDisplay() Log Message: + assertTrue("updateFeedDisplay() Log Message not found", + solo.waitForLogMessage("Entered updateFeedDisplay()",timeout)); + + // Clear log + solo.clearLog(); + + // Press menu back key + solo.goBack(); + + // Wait for view: 'android.R.id.text1' + assertTrue("text1 not found", solo.waitForView(android.R.id.text1)); + + // Click on msrebeccablack + solo.clickOnView(solo.getView(android.R.id.text1, 1)); + + // Assert that: feed_view is shown + assertTrue("feed_view! is not shown!", solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Assert that: 'save me from school' is shown + assertTrue("'save me from school' is not shown!", + solo.searchText("save me from school")); + + // Wait for onActivityCreated() Log Message: + assertTrue("onActivityCreated() Log Message not found", + solo.waitForLogMessage("Entered onActivityCreated()",timeout)); + + // Wait for Log Message: + assertTrue("onItemSelected(1) Log Message not found", + solo.waitForLogMessage("Entered onItemSelected(1)",timeout)); + + // Wait for updateFeedDisplay() Log Message: + assertTrue("updateFeedDisplay() Log Message not found", + solo.waitForLogMessage("Entered updateFeedDisplay()",timeout)); + + // Clear log + solo.clearLog(); + + // Press menu back key + solo.goBack(); + + // Click on taylorswift13 + solo.clickOnView(solo.getView(android.R.id.text1, 2)); + + // Assert that: feed_view shown + assertTrue("feed_view not shown", solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Assert that: 'I love you guys so much' is shown + assertTrue("'I love you guys so much' is not shown!", + solo.searchText("I love you guys so much")); + + // Wait for onActivityCreated() Log Message: + assertTrue("onActivityCreated() Log Message not found", + solo.waitForLogMessage("Entered onActivityCreated()",timeout)); + + // Wait for onItemSelected(2) Log Message: + assertTrue("onItemSelected(2) Log Message not found", + solo.waitForLogMessage("Entered onItemSelected(2)",timeout)); + + // Wait for updateFeedDisplay() Log Message: + assertTrue("updateFeedDisplay() Log Message not found", + solo.waitForLogMessage("Entered updateFeedDisplay()",timeout)); + } +} diff --git a/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/TabletTest.java b/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/TabletTest.java new file mode 100644 index 0000000..d3091b2 --- /dev/null +++ b/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/TabletTest.java @@ -0,0 +1,108 @@ +package course.labs.fragmentslab.test; + +import course.labs.fragmentslab.MainActivity; +import com.robotium.solo.*; +import android.test.ActivityInstrumentationTestCase2; + +public class TabletTest extends ActivityInstrumentationTestCase2<MainActivity> { + private Solo solo; + + public TabletTest() { + super(MainActivity.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.fragmentslab.MainActivity' + solo.waitForActivity(course.labs.fragmentslab.MainActivity.class, 2000); + + // Wait for view: 'android.R.id.text1' + assertTrue("text1 not found", solo.waitForView(android.R.id.text1)); + + // Assert that: feed_view is shown + assertTrue("'feed_view' was not found!", solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Wait for onActivityCreated()Log Message: + assertTrue("onActivityCreated() Log Message not found", + solo.waitForLogMessage("Entered onActivityCreated()", timeout)); + + // Click on ladygaga + solo.clickOnView(solo.getView(android.R.id.text1)); + + // Assert that: feed_view is shown + assertTrue("'Select a feed to view!' is not shown!", + solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Assert that: 'the audience cheering!' is shown + assertTrue("'the audience cheering!' is not shown!", + solo.searchText("the audience cheering!")); + + // Wait for onItemSelected(0) Log Message: + assertTrue("onItemSelected(0) Log Message not found", + solo.waitForLogMessage("Entered onItemSelected(0)", timeout)); + + // Wait for updateFeedDisplay() Log Message: + assertTrue("updateFeedDisplay() Log Message not found", + solo.waitForLogMessage("Entered updateFeedDisplay()", timeout)); + + // Clear log + solo.clearLog(); + + // Click on msrebeccablack + solo.clickOnView(solo.getView(android.R.id.text1, 1)); + + // Assert that: feed_view is shown + assertTrue("'Select a feed to view!' is not shown!", + solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Assert that: 'save me from school' is shown + assertTrue("'save me from school' is not shown!", + solo.searchText("save me from school")); + + // Wait for onItemSelected(1) Log Message: + assertTrue("onItemSelected(1) Log Message not found", + solo.waitForLogMessage("Entered onItemSelected(1)", timeout)); + + // Wait for updateFeedDisplay() Log Message: + assertTrue("updateFeedDisplay() Log Message not found", + solo.waitForLogMessage("Entered updateFeedDisplay()", timeout)); + + // Clear log + solo.clearLog(); + + // Click on taylorswift13 + solo.clickOnView(solo.getView(android.R.id.text1, 2)); + + // Assert that: feed_view is shown + assertTrue("'Select a feed to view!' is not shown!", + solo.waitForView(solo + .getView(course.labs.fragmentslab.R.id.feed_view))); + + // Assert that: 'I love you guys so much' is shown + assertTrue("'I love you guys so much' is not shown!", + solo.searchText("I love you guys so much")); + + // Wait for onItemSelected(2) Log Message: + assertTrue("onItemSelected(2) Log Message not found", + solo.waitForLogMessage("Entered onItemSelected(2)")); + + // Wait for updateFeedDisplay() Log Message: + assertTrue("updateFeedDisplay() Log Message not found", + solo.waitForLogMessage("Entered updateFeedDisplay()")); + } +} |