package com.lorentzos.flingswipe.internal;

import android.view.View;

import com.google.common.truth.Truth;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

/**
 *
 */
@RunWith(MockitoJUnitRunner.class)
public class ExitTouchEventTest extends TouchEventTest {

	private TouchEvent touchEvent;

	@Before
	public void setUp() throws Exception {
		View mockView = MockViewFactory.createWithAnimate();
		PointF middlishTouch = new PointF(120f, 120f);

		touchEvent = new TouchEvent(15f, mockView, middlishTouch);
	}

	@Test
	public void topLeftOutside() throws Exception {
		// Given
		PointF topLeftTouch = new PointF(10f, 10f);

		// When
		float progress = touchEvent.resultView(topLeftTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyNegativeEndingProgress(progress);
	}

	@Test
	public void bottomLeftOutside() throws Exception {
		// Given
		PointF bottomLeftTouch = new PointF(10f, 200f);

		// When
		float progress = touchEvent.resultView(bottomLeftTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyNegativeEndingProgress(progress);
	}

	@Test
	public void topRightOutside() throws Exception {
		// Given
		PointF topRightTouch = new PointF(330f, 10f);

		// When
		float progress = touchEvent.resultView(topRightTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyPositiveEndingProgress(progress);
	}

	@Test
	public void bottomRightOutside() throws Exception {
		// Given
		PointF bottomRightTouch = new PointF(330f, 330f);

		// When
		float progress = touchEvent.resultView(bottomRightTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyPositiveEndingProgress(progress);
	}

	@Test
	public void topLeftInside() throws Exception {
		// Given
		PointF topLeftTouch = new PointF(110f, 10f);

		// When
		float progress = touchEvent.resultView(topLeftTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyNegativeProgress(progress);
	}

	@Test
	public void bottomLeftInside() throws Exception {
		// Given
		PointF bottomLeftTouch = new PointF(110f, 200f);

		// When
		float progress = touchEvent.resultView(bottomLeftTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyNegativeProgress(progress);
	}

	@Test
	public void topRightInside() throws Exception {
		// Given
		PointF topRightTouch = new PointF(290f, 10f);

		// When
		float progress = touchEvent.resultView(topRightTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyPositiveProgress(progress);
	}

	@Test
	public void bottomRightInside() throws Exception {
		// Given
		PointF bottomRightTouch = new PointF(290f, 160f);

		// When
		float progress = touchEvent.resultView(bottomRightTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		verifyPositiveProgress(progress);
	}

	@Test
	public void onlyVerticalMove() throws Exception {
		// Given
		PointF verticalTouch = new PointF(120f, 160f);

		// When
		float progress = touchEvent.resultView(verticalTouch, new OnCardResult() {
			@Override
			public void onExit(@EndType int exit, @Direction int direction) {

			}
		});

		// Then
		Truth.assertThat(progress).isWithin(0);
	}

}
@@ -827,51 +827,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -1168,51 +1168,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -1503,51 +1503,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -1848,51 +1848,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -2179,51 +2179,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -2514,51 +2514,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -2842,51 +2842,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -3180,51 +3180,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A
@@ -3511,51 +3511,31 @@
 xit(
-@EndType int exit, @Direction int direction
+FrameResult frameResult
 ) %7B%0A

Fix unit tests in ExitTouchEventTest