-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fc9924
commit 6fdf083
Showing
26 changed files
with
300 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
android/app/src/androidTest/java/projet/license/MyViewAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package projet.license; | ||
|
||
import android.os.SystemClock; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
|
||
import org.hamcrest.Matcher; | ||
|
||
import androidx.test.espresso.UiController; | ||
import androidx.test.espresso.ViewAction; | ||
import androidx.test.espresso.matcher.ViewMatchers; | ||
|
||
public class MyViewAction { | ||
public static ViewAction singleTouchAt(final int x, final int y, final int action) { | ||
return new ViewAction() { | ||
@Override | ||
public void perform(UiController uiController, View view) { | ||
long date = SystemClock.uptimeMillis(); | ||
MotionEvent me = MotionEvent.obtain(date, date, action, x, y, 0); | ||
view.onTouchEvent(me); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "touch "; | ||
} | ||
|
||
@Override | ||
public Matcher<View> getConstraints() { | ||
return ViewMatchers.isAssignableFrom(View.class); | ||
} | ||
}; | ||
} | ||
|
||
|
||
public static ViewAction pamatreziedSingleTouchAt(final float x, final float y, final int action, final long d1, final long d2, final int meta) { | ||
return new ViewAction() { | ||
@Override | ||
public void perform(UiController uiController, View view) { | ||
MotionEvent me = MotionEvent.obtain(d1, d2, action, x, y, meta); | ||
view.onTouchEvent(me); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "touch "; | ||
} | ||
|
||
@Override | ||
public Matcher<View> getConstraints() { | ||
return ViewMatchers.isAssignableFrom(View.class); | ||
} | ||
}; | ||
} | ||
|
||
} |
84 changes: 84 additions & 0 deletions
84
android/app/src/androidTest/java/projet/license/RiddleGame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package projet.license; | ||
|
||
|
||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.ViewParent; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.Matcher; | ||
import org.hamcrest.TypeSafeMatcher; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import androidx.test.espresso.ViewInteraction; | ||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.action.ViewActions.click; | ||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withId; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.core.AllOf.allOf; | ||
|
||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class RiddleGame { | ||
|
||
@Rule | ||
public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class); | ||
|
||
@Test | ||
public void riddleGame() { | ||
ViewInteraction button = onView( | ||
allOf(withId(R.id.loginConfim), withText("confirm"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(android.R.id.content), | ||
0), | ||
3), | ||
isDisplayed())); | ||
button.perform(click()); | ||
|
||
ViewInteraction button2 = onView( | ||
allOf(withId(R.id.Riddle), withText("RIDDLES"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(android.R.id.content), | ||
0), | ||
3), | ||
isDisplayed())); | ||
button2.perform(click()); | ||
|
||
ViewInteraction button3 = onView( | ||
allOf(withId(R.id.start), withText("START"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(android.R.id.content), | ||
0), | ||
2), | ||
isDisplayed())); | ||
button3.perform(click()); | ||
} | ||
|
||
private static Matcher<View> childAtPosition( | ||
final Matcher<View> parentMatcher, final int position) { | ||
|
||
return new TypeSafeMatcher<View>() { | ||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("Child at position " + position + " in parent "); | ||
parentMatcher.describeTo(description); | ||
} | ||
|
||
@Override | ||
public boolean matchesSafely(View view) { | ||
ViewParent parent = view.getParent(); | ||
return parent instanceof ViewGroup && parentMatcher.matches(parent) | ||
&& view.equals(((ViewGroup) parent).getChildAt(position)); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.