summaryrefslogtreecommitdiffstats
path: root/Android/04-TheFragmentClass/FragmentsLab/tests/src/course/labs/fragmentslab/TabletTest.java
blob: d3091b272ce3b6f71a2968cf9b977e9dee383cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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()"));
    }
}