Skip to content

Commit

Permalink
Use hover for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
italankin committed Dec 17, 2023
1 parent 2824ece commit 3cb5d73
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions app/src/androidTest/java/com/italankin/fifteen/SolveGameTest.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
package com.italankin.fifteen;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.italankin.fifteen.util.CustomViewActions.clickXy;

import android.content.SharedPreferences;

import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

import com.italankin.fifteen.game.ClassicGame;
import com.italankin.fifteen.game.Game;
import com.italankin.fifteen.game.SnakeGame;
import com.italankin.fifteen.game.SpiralGame;
import com.italankin.fifteen.util.Util;

import com.italankin.fifteen.util.HoverSolveAction;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -27,6 +18,11 @@
import java.util.Arrays;
import java.util.List;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class SolveGameTest {
Expand Down Expand Up @@ -111,11 +107,7 @@ private void setSavedGame(Game game) {

private void solveAndAssert(List<Integer> solution) {
Game game = GameState.get().game;
for (Integer move : solution) {
float[] coordinates = Util.tileCenterCoordinates(game, move);
onView(withId(R.id.game_view))
.perform(clickXy(coordinates[0], coordinates[1]));
}
onView(withId(R.id.game_view)).perform(new HoverSolveAction(game, solution));
Assert.assertTrue(game.isSolved());
}
}

0 comments on commit 3cb5d73

Please sign in to comment.