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
|
package course.labs.todomanager.tests;
import course.labs.todomanager.ToDoManagerActivity;
import com.robotium.solo.*;
import android.test.ActivityInstrumentationTestCase2;
public class TestCancel extends
ActivityInstrumentationTestCase2<ToDoManagerActivity> {
private Solo solo;
public TestCancel() {
super(ToDoManagerActivity.class);
}
public void setUp() throws Exception {
solo = new Solo(getInstrumentation());
getActivity();
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
}
public void testRun() {
int timeout = 10;
// Wait for activity: 'course.labs.todomanager.ToDoManagerActivity'
assertTrue(
"'course.labs.todomanager.ToDoManagerActivity' not found",
solo.waitForActivity(
course.labs.todomanager.ToDoManagerActivity.class, 2000));
// Click on action bar item
solo.clickOnActionBarItem(0x1);
// Click on Add New ToDo Item
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.footerView));
// Wait for activity: 'course.labs.todomanager.AddToDoActivity'
assertTrue(
"course.labs.todomanager.AddToDoActivity is not found!",
solo.waitForActivity(course.labs.todomanager.AddToDoActivity.class));
// Hide the soft keyboard
solo.hideSoftKeyboard();
// Enter the text: 't3'
solo.clearEditText((android.widget.EditText) solo.getView(course.labs.todomanager.R.id.title));
solo.enterText((android.widget.EditText) solo.getView(course.labs.todomanager.R.id.title), "t3");
// Hide the soft keyboard
solo.hideSoftKeyboard();
// Click on Done:
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.statusDone));
// Click on High
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.highPriority));
// Click on Cancel
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.cancelButton));
// Click on Add New ToDo Item
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.footerView));
// Hide the soft keyboard
solo.hideSoftKeyboard();
// Enter the text: 't4'
solo.clearEditText((android.widget.EditText) solo.getView(course.labs.todomanager.R.id.title));
solo.enterText((android.widget.EditText) solo.getView(course.labs.todomanager.R.id.title), "t4");
// Hide the soft keyboard
solo.hideSoftKeyboard();
// Click on Done:
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.statusDone));
// Click on Low
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.lowPriority));
// Click on Submit
solo.clickOnView(solo.getView(course.labs.todomanager.R.id.submitButton));
// Wait for activity: 'course.labs.todomanager.ToDoManagerActivity'
assertTrue(
"course.labs.todomanager.ToDoManagerActivity is not found!",
solo.waitForActivity(course.labs.todomanager.ToDoManagerActivity.class));
assertFalse("'A ToDoItem with title, t3', was found", solo.searchText("t3"));
// Click on action bar item to dump items to log
solo.clickOnActionBarItem(0x2);
assertTrue("Menu didn't close", solo.waitForDialogToClose());
// Wait for Log Message 'Title:t4,Priority:LOW,Status:NOT DONE'
assertTrue("Log message 'Title:t4,Priority:LOW,Status:NOT DONE' not found",
solo.waitForLogMessage("Title:t4,Priority:LOW,Status:DONE",timeout));
}
}
|