package com.adjl.firstpersoncamera;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.adjl.firstpersoncamera.Camera.Mouse;

import org.junit.Before;
import org.junit.Test;

import processing.core.PApplet;

/**
 * Tests {@link Mouse}.
 *
 * @author adjl
 */
public class MouseTest {

    private PApplet mSketch;
    private Mouse mMouse;

    @Before
    public void setUp() {
        mSketch = new PApplet();
        mMouse = new Mouse(mSketch, 2);
    }

    @Test
    public void testGetX_ZeroAtStart() {
        assertEquals(0, mMouse.getX());
    }

    @Test
    public void testGetX_ChangedAtRun() {
        mSketch.mouseX = 1;
        assertEquals(1, mMouse.getX());
    }

    @Test
    public void testGetY_HalfHeighAtStart() {
        mSketch.height = 200;
        assertEquals(100, mMouse.getY());
    }

    @Test
    public void testGetY_HalfHeightMinusChangeAtRun() {
        mSketch.height = 200;
        mSketch.mouseY = 50;
        assertEquals(50, mMouse.getY());
    }

    @Test
    public void testIsCentred_NotCentredAtStart() {
        assertFalse(mMouse.isCentred());
    }

    @Test
    public void testIsCentred_NotCentredIfNotEnoughAttempts() {
        mMouse.centre();
        assertFalse(mMouse.isCentred());
    }

    @Test
    public void testIsCentred_CentredIfEnoughAttempts() {
        mMouse.centre();
        mMouse.centre();
        assertTrue(mMouse.isCentred());
    }

    @Test
    public void testCentre() {
        mMouse.centre();
        assertEquals(1, mMouse.getAttempts());
    }

    @Test
    public void testMove_NotWrappedIfNotAtEdges() {
        mSketch.width = 200;
        mSketch.mouseX = 1;

        mMouse.setWrapped(true);
        mMouse.move();
        assertFalse(mMouse.isWrapped());

        mMouse.setWrapped(false);
        mMouse.move();
        assertFalse(mMouse.isWrapped());
    }

    @Test
    public void testMove_WrappedIfAtEdges() {
        mSketch.width = 200;
        mSketch.mouseX = 0;

        mMouse.setWrapped(false);
        mMouse.move();
        assertTrue(mMouse.isWrapped());

        mMouse.setWrapped(true);
        mMouse.move();
        assertTrue(mMouse.isWrapped());
    }
}

@@ -538,16 +538,75 @@
 ch, 2);%0A
+        mSketch.width = 800;%0A        mSketch.height = 600;%0A
     %7D%0A%0A 
@@ -889,38 +889,8 @@
 ) %7B%0A
-        mSketch.height = 200;%0A
     
@@ -906,17 +906,17 @@
 tEquals(
-1
+3
 00, mMou
@@ -1004,38 +1004,8 @@
 ) %7B%0A
-        mSketch.height = 200;%0A
     
@@ -1025,16 +1025,17 @@
 ouseY = 
+1
 50;%0A    
@@ -1051,16 +1051,17 @@
 tEquals(
+1
 50, mMou
@@ -1505,128 +1505,8 @@
  %7D%0A%0A
-    @Test%0A    public void testCentre() %7B%0A        mMouse.centre();%0A        assertEquals(1, mMouse.getAttempts());%0A    %7D%0A%0A
     
@@ -1548,16 +1548,26 @@
 rappedIf
+WrappedAnd
 NotAtEdg
@@ -1577,37 +1577,8 @@
 ) %7B%0A
-        mSketch.width = 200;%0A
     
@@ -1601,17 +1601,16 @@
 eX = 1;%0A
-%0A
         
@@ -1690,32 +1690,148 @@
 e.isWrapped());%0A
+    %7D%0A%0A    @Test%0A    public void testMove_NotWrappedIfStillNotWrappedAndAtNotAtEdges() %7B%0A        mSketch.mouseX = 1;
 %0A        mMouse.
@@ -1968,77 +1968,32 @@
 edIf
-AtEdges() %7B%0A        mSketch.width = 200;%0A        mSketch.mouseX = 0;%0A
+NotWrappedAndAtEdges() %7B
 %0A   
@@ -2086,16 +2086,93 @@
 ped());%0A
+    %7D%0A%0A    @Test%0A    public void testMove_WrappedIfStillWrappedAndAtEdges() %7B
 %0A       

Declare sizes, split test cases and remove unneeded test