-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDungeonEscapeScreenTest
More file actions
153 lines (125 loc) · 13 KB
/
DungeonEscapeScreenTest
File metadata and controls
153 lines (125 loc) · 13 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.cs2114.dungeonescape;
import sofia.graphics.Color;
import android.widget.Button;
import android.widget.TextView;
import sofia.graphics.ShapeView;
// -------------------------------------------------------------------------
/**
* This is the test class for the MazeSolverScreen
*
* @author Yash Pant (yash1)
* @version 2013.10.23
*/
public class DungeonEscapeScreenTest
extends student.AndroidTestCase<DungeonEscapeScreen>
{
// ~ Fields ................................................................
private ShapeView shapeView;
private Button next;
private Button previous;
private Button resartLevel;
private Button replaySolution;
private int cellSize;
// ~ Constructors ..........................................................
// ----------------------------------------------------------
/**
* Test cases that extend AndroidTestCase must have a parameterless
* constructor that calls super() and passes it the screen/activity class
* being tested.
*/
public DungeonEscapeScreenTest()
{
super(DungeonEscapeScreen.class);
}
// ~ Public methods ........................................................
// ----------------------------------------------------------
/**
* Initializes the text fixtures.
*/
public void setUp()
{
float viewSize = Math.min(shapeView.getWidth(), shapeView.getHeight());
cellSize = (int)(viewSize / 20);
}
public void testDungeon2Failed() {
}
/**
* Tests the solution to dungeon 5
*/
public void testDungeon5Solved()
{
//move to the right dungeon
click(previous);
//move #1
swipeDown();
//move #2
swipeLeft();
//move #3
swipeDown();
//move #4
swipeRight();
//move #5
swipeDown();
//move #6
swipeRight();
//move #7
swipeDown();
//move #8
swipeRight();
//move #9
swipeDown();
//move #10
swipeLeft();
//move #11
swipeDown();
//assert game won
//assertEquals();
}
// ~ Private methods .......................................................
private void swipeLeft() {
touchDownCell(9, 6);
touchMoveCell(4, 6);
touchUp();
}
private void swipeRight() {
touchDownCell(1, 11);
touchMoveCell(4,11);
touchUp();
}
private void swipeUp() {
touchDownCell(5, 5);
touchMoveCell(5, 2);
touchUp();
}
private void swipeDown() {
touchDownCell(9, 1);
touchMoveCell(9, 4);
touchUp();
}
// ----------------------------------------------------------
/**
* Simulates touching down on the middle of the specified cell in the maze.
*/
private void touchDownCell(int x, int y)
{
touchDown(shapeView, (x + 0.5f) * cellSize, (y + 0.5f) * cellSize);
}
// ----------------------------------------------------------
/**
* Simulates moving the finger instantaneously to the middle of the
* specified cell in the maze.
*/
private void touchMoveCell(int x, int y)
{
touchMove((x + 0.5f) * cellSize, (y + 0.5f) * cellSize);
}
/**
* Simulates clicking the middle of the specified cell in the maze. This is
* equivalent to calling: touchDownCell(x, y); touchUp();
*/
private void clickCell(int x, int y)
{
touchDownCell(x, y);
touchUp();
}
}