This repository has been archived by the owner on Apr 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed crash when selecting target for standard round * Refactored MultiSelector and SingleSelector to share a common base class and respect LSP. * Added UI test * Fixed round delete bug * Added additional info on settings crash
- Loading branch information
Showing
32 changed files
with
528 additions
and
171 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
118 changes: 118 additions & 0 deletions
118
...va/de/dreier/mytargets/features/training/standardround/EditStandardRoundActivityTest.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,118 @@ | ||
/* | ||
* Copyright (C) 2017 Florian Dreier | ||
* | ||
* This file is part of MyTargets. | ||
* | ||
* MyTargets is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 | ||
* as published by the Free Software Foundation. | ||
* | ||
* MyTargets is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
package de.dreier.mytargets.features.training.standardround; | ||
|
||
|
||
import android.content.Intent; | ||
import android.support.test.espresso.intent.rule.IntentsTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import de.dreier.mytargets.R; | ||
import de.dreier.mytargets.features.settings.SettingsManager; | ||
import de.dreier.mytargets.features.training.edit.EditTrainingActivity; | ||
import de.dreier.mytargets.shared.models.Dimension; | ||
import de.dreier.mytargets.shared.models.Target; | ||
import de.dreier.mytargets.shared.targets.models.WAFull; | ||
import de.dreier.mytargets.test.base.UITestBase; | ||
|
||
import static android.Manifest.permission.ACCESS_FINE_LOCATION; | ||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.action.ViewActions.scrollTo; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItem; | ||
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant; | ||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static de.dreier.mytargets.features.training.edit.EditTrainingFragment.CREATE_TRAINING_WITH_STANDARD_ROUND_ACTION; | ||
import static de.dreier.mytargets.shared.models.Dimension.Unit.CENTIMETER; | ||
import static de.dreier.mytargets.shared.models.Dimension.Unit.METER; | ||
import static de.dreier.mytargets.test.utils.PermissionGranter.allowPermissionsIfNeeded; | ||
import static de.dreier.mytargets.test.utils.matchers.MatcherUtils.withRecyclerView; | ||
import static de.dreier.mytargets.test.utils.matchers.ParentViewMatcher.isNestedChildOfView; | ||
import static org.hamcrest.Matchers.allOf; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.startsWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class EditStandardRoundActivityTest extends UITestBase { | ||
|
||
@Rule | ||
public IntentsTestRule<EditTrainingActivity> activityTestRule = new IntentsTestRule<>( | ||
EditTrainingActivity.class, true, false); | ||
|
||
@Before | ||
public void setUp() { | ||
SettingsManager.setTarget(new Target(WAFull.ID, 0, new Dimension(122, CENTIMETER))); | ||
SettingsManager.setDistance(new Dimension(50, METER)); | ||
SettingsManager.setTimerEnabled(false); | ||
SettingsManager.setShotsPerEnd(3); | ||
SettingsManager.setEndCount(10); | ||
SettingsManager.setDistance(new Dimension(10, METER)); | ||
} | ||
|
||
@Test | ||
public void editStandardRoundActivity() { | ||
Intent intent = new Intent(); | ||
intent.setAction(CREATE_TRAINING_WITH_STANDARD_ROUND_ACTION); | ||
activityTestRule.launchActivity(intent); | ||
|
||
allowPermissionsIfNeeded(activityTestRule.getActivity(), ACCESS_FINE_LOCATION); | ||
|
||
onView(withId(R.id.standardRound)).perform(scrollTo(), click()); | ||
|
||
onView(withId(R.id.fab)).perform(click()); | ||
|
||
onView(withId(R.id.distance)).perform(nestedScrollTo(), click()); | ||
onView(allOf(withId(R.id.recyclerView), isDisplayed())) | ||
.perform(actionOnItem(hasDescendant(withText("20m")), click())); | ||
|
||
onView(withId(R.id.target)).perform(nestedScrollTo(), click()); | ||
onView(withId(R.id.recyclerView)) | ||
.perform(actionOnItem(hasDescendant(withText(R.string.wa_danage_6_spot)), click())); | ||
navigateUp(); | ||
|
||
onView(withId(R.id.addButton)).perform(nestedScrollTo(), click()); | ||
|
||
onView(withRecyclerView(R.id.rounds).atPositionOnView(1, R.id.distance)) | ||
.perform(nestedScrollTo(), click()); | ||
onView(allOf(withId(R.id.recyclerView), isDisplayed())) | ||
.perform(actionOnItem(hasDescendant(withText("15m")), click())); | ||
|
||
onView(allOf(withId(R.id.number_increment), isNestedChildOfView(withId(R.id.shotCount)), | ||
isNestedChildOfView(withRecyclerView(R.id.rounds).atPosition(1)))) | ||
.perform(nestedScrollTo(), click(), click(), click()); | ||
|
||
onView(allOf(withId(R.id.number_decrement), isNestedChildOfView(withId(R.id.endCount)), | ||
isNestedChildOfView(withRecyclerView(R.id.rounds).atPosition(1)))) | ||
.perform(nestedScrollTo(), click(), click(), click(), click(), click()); | ||
|
||
clickActionBarItem(R.id.action_save, R.string.save); | ||
|
||
onView(withId(R.id.standardRound)) | ||
.check(matches(hasDescendant(withText(R.string.custom_round)))); | ||
|
||
onView(withId(R.id.standardRound)) | ||
.check(matches(hasDescendant(withText( | ||
allOf(startsWith("20m: 10 × 3"), containsString("15m: 5 × 6")))))); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...rc/androidTest/java/de/dreier/mytargets/test/utils/assertions/RecyclerViewAssertions.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,37 @@ | ||
/* | ||
* Copyright (C) 2017 Florian Dreier | ||
* | ||
* This file is part of MyTargets. | ||
* | ||
* MyTargets is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 | ||
* as published by the Free Software Foundation. | ||
* | ||
* MyTargets is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
package de.dreier.mytargets.test.utils.assertions; | ||
|
||
import android.support.test.espresso.ViewAssertion; | ||
import android.support.v7.widget.RecyclerView; | ||
|
||
import org.hamcrest.Matcher; | ||
|
||
import static android.support.test.espresso.matcher.ViewMatchers.assertThat; | ||
|
||
public class RecyclerViewAssertions { | ||
public static ViewAssertion itemCount(Matcher<Integer> matcher) { | ||
return (view, noViewFoundException) -> { | ||
if (noViewFoundException != null) { | ||
throw noViewFoundException; | ||
} | ||
|
||
RecyclerView recyclerView = (RecyclerView) view; | ||
RecyclerView.Adapter adapter = recyclerView.getAdapter(); | ||
assertThat(adapter.getItemCount(), matcher); | ||
}; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
app/src/androidTest/java/de/dreier/mytargets/test/utils/matchers/ParentViewMatcher.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,37 @@ | ||
/* | ||
* Copyright (C) 2017 Florian Dreier | ||
* | ||
* This file is part of MyTargets. | ||
* | ||
* MyTargets is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 | ||
* as published by the Free Software Foundation. | ||
* | ||
* MyTargets is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
package de.dreier.mytargets.test.utils.matchers; | ||
|
||
import android.view.View; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.Matcher; | ||
import org.hamcrest.TypeSafeMatcher; | ||
|
||
public class ParentViewMatcher { | ||
public static Matcher<View> isNestedChildOfView(Matcher<View> parentViewMatcher) { | ||
return new TypeSafeMatcher<View>() { | ||
public void describeTo(Description description) { | ||
description.appendText("is nested child of view "); | ||
parentViewMatcher.describeTo(description); | ||
} | ||
|
||
public boolean matchesSafely(View view) { | ||
return MatcherUtils.getMatchingParent(view, parentViewMatcher) != null; | ||
} | ||
}; | ||
} | ||
} |
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.