forked from federicoiosue/Omni-Notes
-
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.
Updated tools, Gradle wrapper, dependencies, TravisCI emulator ABI
- Loading branch information
1 parent
b7f9396
commit 5a49aaa
Showing
6 changed files
with
174 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sun Mar 15 18:24:16 CET 2020 | ||
#Thu Jun 04 17:45:18 CEST 2020 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip |
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
153 changes: 153 additions & 0 deletions
153
omniNotes/src/androidTest/java/it/feio/android/omninotes/MainActivityTest.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,153 @@ | ||
package it.feio.android.omninotes; | ||
|
||
|
||
import androidx.test.espresso.DataInteraction; | ||
import androidx.test.espresso.ViewInteraction; | ||
import androidx.test.filters.LargeTest; | ||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.ViewParent; | ||
|
||
import static androidx.test.InstrumentationRegistry.getInstrumentation; | ||
import static androidx.test.espresso.Espresso.onData; | ||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.Espresso.pressBack; | ||
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; | ||
import static androidx.test.espresso.action.ViewActions.*; | ||
import static androidx.test.espresso.assertion.ViewAssertions.*; | ||
import static androidx.test.espresso.matcher.ViewMatchers.*; | ||
|
||
import it.feio.android.omninotes.R; | ||
|
||
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 org.hamcrest.Matchers.allOf; | ||
import static org.hamcrest.Matchers.anything; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
@LargeTest | ||
@RunWith(AndroidJUnit4.class) | ||
public class MainActivityTest { | ||
|
||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class); | ||
|
||
@Test | ||
public void mainActivityTest() { | ||
// Added a sleep statement to match the app's execution delay. | ||
// The recommended way to handle such scenarios is to use Espresso idling resources: | ||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html | ||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
ViewInteraction viewInteraction = onView( | ||
allOf(withId(R.id.fab_expand_menu_button), | ||
childAtPosition( | ||
allOf(withId(R.id.fab), | ||
childAtPosition( | ||
withClassName(is("android.widget.FrameLayout")), | ||
2)), | ||
3), | ||
isDisplayed())); | ||
viewInteraction.perform(click()); | ||
|
||
ViewInteraction floatingActionButton = onView( | ||
allOf(withId(R.id.fab_note), | ||
childAtPosition( | ||
allOf(withId(R.id.fab), | ||
childAtPosition( | ||
withClassName(is("android.widget.FrameLayout")), | ||
2)), | ||
2), | ||
isDisplayed())); | ||
floatingActionButton.perform(click()); | ||
|
||
// Added a sleep statement to match the app's execution delay. | ||
// The recommended way to handle such scenarios is to use Espresso idling resources: | ||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html | ||
try { | ||
Thread.sleep(7000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
ViewInteraction actionMenuItemView = onView( | ||
allOf(withId(R.id.menu_category), withContentDescription("Category"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(R.id.toolbar), | ||
1), | ||
1), | ||
isDisplayed())); | ||
actionMenuItemView.perform(click()); | ||
|
||
// Added a sleep statement to match the app's execution delay. | ||
// The recommended way to handle such scenarios is to use Espresso idling resources: | ||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html | ||
try { | ||
Thread.sleep(7000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
ViewInteraction mDButton = onView( | ||
allOf(withId(R.id.md_buttonDefaultPositive), withText("Add category"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(android.R.id.content), | ||
0), | ||
4), | ||
isDisplayed())); | ||
mDButton.perform(click()); | ||
|
||
ViewInteraction appCompatEditText = onView( | ||
allOf(withId(R.id.category_title), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(android.R.id.content), | ||
0), | ||
0), | ||
isDisplayed())); | ||
appCompatEditText.perform(replaceText("Asd"), closeSoftKeyboard()); | ||
|
||
ViewInteraction appCompatButton = onView( | ||
allOf(withId(R.id.save), withText("Ok"), | ||
childAtPosition( | ||
childAtPosition( | ||
withClassName(is("android.widget.LinearLayout")), | ||
3), | ||
1), | ||
isDisplayed())); | ||
appCompatButton.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)); | ||
} | ||
}; | ||
} | ||
} |