-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #377 and added both unit test and Espresso test
- Loading branch information
Federico Iosue
committed
Jun 13, 2017
1 parent
6e97710
commit ca3e233
Showing
5 changed files
with
130 additions
and
18 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
90 changes: 90 additions & 0 deletions
90
omniNotes/src/androidTest/java/it/feio/android/omninotes/RemindersLifecycleTest.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,90 @@ | ||
package it.feio.android.omninotes; | ||
|
||
|
||
import android.support.test.espresso.ViewInteraction; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
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.hamcrest.core.IsInstanceOf; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
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.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withParent; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.Matchers.allOf; | ||
import static org.hamcrest.Matchers.startsWith; | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4.class) | ||
public class RemindersLifecycleTest { | ||
|
||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class); | ||
|
||
@Test | ||
public void remindersLifecycle() { | ||
ViewInteraction viewInteraction = onView( | ||
allOf(withId(R.id.fab_expand_menu_button), | ||
withParent(withId(R.id.fab)), | ||
isDisplayed())); | ||
viewInteraction.perform(click()); | ||
|
||
ViewInteraction floatingActionButton = onView( | ||
allOf(withId(R.id.fab_note), | ||
withParent(withId(R.id.fab)), | ||
isDisplayed())); | ||
floatingActionButton.perform(click()); | ||
|
||
ViewInteraction linearLayout = onView( | ||
withId(R.id.reminder_layout)); | ||
linearLayout.perform(scrollTo(), click()); | ||
|
||
ViewInteraction appCompatButton = onView( | ||
allOf(withId(R.id.done), withText("Done"), isDisplayed())); | ||
appCompatButton.perform(click()); | ||
|
||
ViewInteraction appCompatButton2 = onView( | ||
allOf(withId(R.id.done_button), withText("Done"), isDisplayed())); | ||
appCompatButton2.perform(click()); | ||
|
||
ViewInteraction appCompatButton3 = onView( | ||
allOf(withId(R.id.done), withText("Done"), isDisplayed())); | ||
appCompatButton3.perform(click()); | ||
|
||
ViewInteraction textView = onView(withId(R.id.datetime)); | ||
textView.check(matches(withText(startsWith("Reminder set for")))); | ||
} | ||
|
||
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