forked from hrabalik/fmo-android
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from sverbach/dev
Dev to master Sprint 2
- Loading branch information
Showing
115 changed files
with
4,069 additions
and
964 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
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
104 changes: 104 additions & 0 deletions
104
app/src/androidTest/java/ch/m3ts/TutorialActivityTest.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,104 @@ | ||
package ch.m3ts; | ||
|
||
import android.Manifest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import androidx.test.filters.LargeTest; | ||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.rule.GrantPermissionRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
import cz.fmo.R; | ||
import helper.GrantPermission; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.Espresso.pressBack; | ||
import static androidx.test.espresso.action.ViewActions.click; | ||
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 androidx.test.espresso.matcher.ViewMatchers.withText; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class TutorialActivityTest { | ||
private static final int STEPS_TRACKER_TUTORIAL = 3; | ||
private static final int STEPS_DISPLAY_TUTORIAL = 5; | ||
private static final int STEPS_SERVE_TUTORIAL = 1; | ||
|
||
@Rule | ||
public GrantPermissionRule grantPermissionRuleCamera = GrantPermissionRule.grant(Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE); | ||
|
||
@Rule | ||
public ActivityTestRule<MainActivity> pmsMainActivityRule = new ActivityTestRule<>(MainActivity.class); | ||
|
||
@Before | ||
public void grantAllPermissions() { | ||
GrantPermission.grantAllPermissions(); | ||
} | ||
|
||
@Test | ||
public void checkTutorialActivity() { | ||
int[] tutorials = { | ||
R.string.tutorialTrackerBtnLabel, | ||
R.string.tutorialDisplayBtnLabel, | ||
R.string.tutorialPlayBtnLabel | ||
}; | ||
onView(withId(R.id.mainHowToPlay)).perform(click()); | ||
for (int tutorialButtonLabel : tutorials) { | ||
onView(withText(tutorialButtonLabel)).check(matches(isDisplayed())); | ||
} | ||
onView(withText(tutorials[0])).perform(click()); | ||
|
||
// should be in fragment now, confirm with display matches | ||
onView(withId(R.id.tutorialImg)).check(matches(isDisplayed())); | ||
onView(withId(R.id.tutorialDescriptionTxt)).check(matches(isDisplayed())); | ||
onView(withId(R.id.tutorialTitleTxt)).check(matches(isDisplayed())); | ||
|
||
// click revert Button a couple of times, nothing should happen | ||
for (int i = 0; i < 10; i++) { | ||
onView(withId(R.id.tutorialGoBackBtn)).perform(click()); | ||
} | ||
|
||
onView(withId(R.id.tutorialContinueBtn)).perform(click()); | ||
onView(withId(R.id.tutorialGoBackBtn)).perform(click()); | ||
|
||
// do all tutorials... | ||
testTrackerTutorial(); | ||
onView(withText(tutorials[1])).perform(click()); | ||
testDisplayTutorial(); | ||
onView(withText(tutorials[2])).perform(click()); | ||
testServeTutorial(); | ||
|
||
// now we should be in mainActivity again | ||
pressBack(); | ||
onView(withId(R.id.mainHowToPlay)).check(matches(isDisplayed())); | ||
} | ||
|
||
private void testTrackerTutorial() { | ||
// press continue until we finished tutorial | ||
for (int i = 0; i < STEPS_TRACKER_TUTORIAL; i++) { | ||
onView(withId(R.id.tutorialContinueBtn)).perform(click()); | ||
} | ||
onView(withId(R.id.mainHowToPlay)).perform(click()); | ||
} | ||
|
||
private void testDisplayTutorial() { | ||
// press continue until we finished tutorial | ||
for (int i = 0; i < STEPS_DISPLAY_TUTORIAL; i++) { | ||
onView(withId(R.id.tutorialContinueBtn)).perform(click()); | ||
} | ||
onView(withId(R.id.mainHowToPlay)).perform(click()); | ||
} | ||
|
||
private void testServeTutorial() { | ||
// press continue until we finished tutorial | ||
for (int i = 0; i < STEPS_SERVE_TUTORIAL; i++) { | ||
onView(withId(R.id.tutorialContinueBtn)).perform(click()); | ||
} | ||
onView(withId(R.id.mainHowToPlay)).perform(click()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE properties SYSTEM | ||
"http://java.sun.com/dtd/properties.dtd"> | ||
<properties> | ||
<comment>table location (2 corners)</comment> | ||
<entry key="c1_x">26</entry> | ||
<entry key="c1_y">496</entry> | ||
<entry key="c2_x">1257</entry> | ||
<entry key="c2_y">474</entry> | ||
<entry key="n1_x">624</entry> | ||
<entry key="n1_y">485</entry> | ||
</properties> |
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE properties SYSTEM | ||
"http://java.sun.com/dtd/properties.dtd"> | ||
<properties> | ||
<comment>table location (2 corners)</comment> | ||
<entry key="c1_x">6</entry> | ||
<entry key="c1_y">387</entry> | ||
<entry key="c2_x">1271</entry> | ||
<entry key="c2_y">389</entry> | ||
<entry key="n1_x">640</entry> | ||
<entry key="n1_y">383</entry> | ||
</properties> |
Oops, something went wrong.