Ejemplo n.º 1
0
 // Testing to getter functions. These return a member variable so they should
 // always be equal to the value of the member.
 @Test
 public void setLocationTest() {
   Map m = new Map();
   Room room = Mockito.mock(Room.class);
   m.setLocation(room);
   assertSame(room, m.getLocation());
 }
Ejemplo n.º 2
0
 // A test that a move north doesn't do anything if there is not a room.
 @Test
 public void illegalMoveNorthNoRoomTest() {
   Map map = new Map();
   Room loc = Mockito.mock(Room.class);
   Door door = Mockito.mock(Door.class);
   Mockito.when(loc.getNorthRoom()).thenReturn(null);
   Mockito.when(loc.getNorthDoor()).thenReturn(door);
   map.setLocation(loc);
   map.moveNorth(loc);
   assertEquals(loc, map.getLocation());
 }
Ejemplo n.º 3
0
 // A test that a move south doesn't do anything if there is not a door there.
 @Test
 public void illegalMoveSouthNoDoorTest() {
   Map map = new Map();
   Room loc = Mockito.mock(Room.class);
   Room loc2 = Mockito.mock(Room.class);
   Mockito.when(loc.getSouthRoom()).thenReturn(loc2);
   Mockito.when(loc.getSouthDoor()).thenReturn(null);
   map.setLocation(loc);
   map.moveSouth(loc);
   assertEquals(loc, map.getLocation());
 }
Ejemplo n.º 4
0
 // A test if a move south works if there is a door and room to the south.
 @Test
 public void legalMoveSouthTest() {
   Map map = new Map();
   Room loc = Mockito.mock(Room.class);
   Room loc2 = Mockito.mock(Room.class);
   Door door = Mockito.mock(Door.class);
   Mockito.when(loc.getSouthRoom()).thenReturn(loc2);
   Mockito.when(loc.getSouthDoor()).thenReturn(door);
   map.setLocation(loc);
   map.moveSouth(loc);
   assertEquals(loc2, map.getLocation());
 }
Ejemplo n.º 5
0
  protected void onPostExecute(String result) {

    Log.d("debug", "onPostExecute method");
    Log.d("debug", "JSON is: " + result);

    try {

      JSONObject json = new JSONObject(result);
      JSONObject jsonResult = json.getJSONObject("result");
      JSONObject location = jsonResult.getJSONObject("geometry").getJSONObject("location");

      latitude = Double.valueOf(location.getString("lat"));
      longitude = Double.valueOf(location.getString("lng"));

      Log.d("debug", "latitude is: " + latitude + " logitude is: " + longitude);
      gMap.setLocation(latitude, longitude);

    } catch (Exception e) {
      Log.d("debug", e.toString());
    }
  }