test: items displaying.
This commit is contained in:
parent
ae81261cb1
commit
8c00aa65da
@ -2,6 +2,7 @@ package bou.amine.apps.readerforselfossv2.android
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.annotation.ArrayRes
|
import androidx.annotation.ArrayRes
|
||||||
|
import androidx.test.espresso.Espresso.onData
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.action.ViewActions.replaceText
|
import androidx.test.espresso.action.ViewActions.replaceText
|
||||||
@ -14,6 +15,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
|
|||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
|
import org.hamcrest.Matchers.hasToString
|
||||||
|
|
||||||
fun performLogin(someUrl: String? = null) {
|
fun performLogin(someUrl: String? = null) {
|
||||||
onView(withId(R.id.urlView)).perform(click()).perform(
|
onView(withId(R.id.urlView)).perform(click()).perform(
|
||||||
@ -86,4 +88,22 @@ fun testPreferencesFromArray(
|
|||||||
openSettingItem()
|
openSettingItem()
|
||||||
onView(withText(res)).check(matches(allOf(isDisplayed(), isChecked())))
|
onView(withText(res)).check(matches(allOf(isDisplayed(), isChecked())))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testAddSourceWithUrl(url: String, sourceName: String) {
|
||||||
|
onView(withId(R.id.fab))
|
||||||
|
.perform(click())
|
||||||
|
onView(withId(R.id.nameInput))
|
||||||
|
.perform(click()).perform(typeTextIntoFocusedView(sourceName))
|
||||||
|
onView(withId(R.id.sourceUri))
|
||||||
|
.perform(click())
|
||||||
|
.perform(typeTextIntoFocusedView(url))
|
||||||
|
onView(withId(R.id.tags))
|
||||||
|
.perform(click()).perform(typeTextIntoFocusedView("tag1,tag2,tag3"))
|
||||||
|
onView(withId(R.id.spoutsSpinner))
|
||||||
|
.perform(click())
|
||||||
|
onData(hasToString("RSS Feed")).perform(click())
|
||||||
|
onView(withId(R.id.saveBtn))
|
||||||
|
.perform(click())
|
||||||
|
onView(withText(sourceName)).check(matches(isDisplayed()))
|
||||||
}
|
}
|
@ -1,9 +1,6 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.test.core.app.ApplicationProvider
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
|
||||||
import androidx.test.espresso.action.ViewActions
|
import androidx.test.espresso.action.ViewActions
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
@ -47,9 +44,7 @@ class HomeActivityTest {
|
|||||||
isClickable()
|
isClickable()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
onView(withText(R.string.readAll)).check(matches(isDisplayed()))
|
onView(withText(R.string.readAll)).check(matches(isDisplayed()))
|
||||||
onView(withText(R.string.menu_home_sources)).check(matches(isDisplayed()))
|
onView(withText(R.string.menu_home_sources)).check(matches(isDisplayed()))
|
||||||
onView(withText(R.string.title_activity_settings)).check(matches(isDisplayed()))
|
onView(withText(R.string.title_activity_settings)).check(matches(isDisplayed()))
|
||||||
@ -78,43 +73,31 @@ class HomeActivityTest {
|
|||||||
).check(matches(isDisplayed()))
|
).check(matches(isDisplayed()))
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
|
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
onView(withText(R.string.readAll)).perform(click())
|
onView(withText(R.string.readAll)).perform(click())
|
||||||
onView(withText(R.string.markall_dialog_message)).check(matches(isDisplayed()))
|
onView(withText(R.string.markall_dialog_message)).check(matches(isDisplayed()))
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
|
|
||||||
onView(withText(R.string.menu_home_sources)).perform(click())
|
onView(withText(R.string.menu_home_sources)).perform(click())
|
||||||
onView(withId(R.id.fab)).check(matches(isDisplayed()))
|
onView(withId(R.id.fab)).check(matches(isDisplayed()))
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
|
|
||||||
onView(withText(R.string.title_activity_settings)).perform(click())
|
onView(withText(R.string.title_activity_settings)).perform(click())
|
||||||
onView(withText(R.string.pref_header_general)).check(matches(isDisplayed()))
|
onView(withText(R.string.pref_header_general)).check(matches(isDisplayed()))
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
|
|
||||||
onView(withText(R.string.menu_home_refresh)).perform(click())
|
onView(withText(R.string.menu_home_refresh)).perform(click())
|
||||||
onView(withText(R.string.refresh_dialog_message)).check(matches(isDisplayed()))
|
onView(withText(R.string.refresh_dialog_message)).check(matches(isDisplayed()))
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
|
|
||||||
/*onView(withText(R.string.issue_tracker_link)).perform(click())
|
/*onView(withText(R.string.issue_tracker_link)).perform(click())
|
||||||
onView(withText(R.string.markall_dialog_message)).check(matches(isDisplayed()))
|
onView(withText(R.string.markall_dialog_message)).check(matches(isDisplayed()))
|
||||||
onView(isRoot()).perform(ViewActions.pressBack())
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()*/
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)*/
|
|
||||||
|
|
||||||
onView(withText(R.string.action_disconnect)).perform(click())
|
onView(withText(R.string.action_disconnect)).perform(click())
|
||||||
onView(withText(R.string.confirm_disconnect_title)).check(matches(isDisplayed()))
|
onView(withText(R.string.confirm_disconnect_title)).check(matches(isDisplayed()))
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.test.core.app.ApplicationProvider
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
@ -33,9 +31,7 @@ class SettingsActivityTest {
|
|||||||
context = activity.window.context
|
context = activity.window.context
|
||||||
}
|
}
|
||||||
loginAndInitHome()
|
loginAndInitHome()
|
||||||
openActionBarOverflowOrOptionsMenu(
|
openMenu()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
onView(withText(R.string.title_activity_settings)).perform(click())
|
onView(withText(R.string.title_activity_settings)).perform(click())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
import android.content.Context
|
import androidx.test.espresso.AmbiguousViewMatcherException
|
||||||
import androidx.test.core.app.ApplicationProvider
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
import androidx.test.espresso.action.ViewActions
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.action.ViewActions.scrollCompletelyTo
|
import androidx.test.espresso.action.ViewActions.swipeDown
|
||||||
import androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView
|
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.LargeTest
|
import androidx.test.filters.LargeTest
|
||||||
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -23,7 +24,6 @@ import java.util.UUID
|
|||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
class SourcesActivityTest {
|
class SourcesActivityTest {
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
|
||||||
|
|
||||||
@ -34,32 +34,50 @@ class SourcesActivityTest {
|
|||||||
sourceName = UUID.randomUUID().toString().substring(0, 15)
|
sourceName = UUID.randomUUID().toString().substring(0, 15)
|
||||||
|
|
||||||
loginAndInitHome()
|
loginAndInitHome()
|
||||||
openActionBarOverflowOrOptionsMenu(
|
goToSources()
|
||||||
ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
)
|
|
||||||
onView(withText(R.string.menu_home_sources))
|
|
||||||
.perform(click())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addSource() {
|
fun addSource() {
|
||||||
onView(withId(R.id.fab))
|
testAddSourceWithUrl(
|
||||||
.perform(click())
|
"https://lorem-rss.herokuapp.com/feed?unit=year&interval=1&length=10",
|
||||||
onView(withId(R.id.nameInput))
|
sourceName
|
||||||
.perform(click()).perform(typeTextIntoFocusedView(sourceName))
|
)
|
||||||
onView(withId(R.id.sourceUri))
|
|
||||||
.perform(click())
|
|
||||||
.perform(typeTextIntoFocusedView("https://lorem-rss.herokuapp.com/feed?unit=year&interval=1&length=10"))
|
|
||||||
onView(withId(R.id.tags))
|
|
||||||
.perform(click()).perform(typeTextIntoFocusedView("tag1,tag2,tag3"))
|
|
||||||
onView(withId(R.id.spoutsSpinner))
|
|
||||||
.perform(click())
|
|
||||||
onView(withText("RSS Feed"))
|
|
||||||
.perform(scrollCompletelyTo())
|
|
||||||
.perform(click())
|
|
||||||
onView(withId(R.id.saveBtn))
|
|
||||||
.perform(click())
|
|
||||||
onView(withText(sourceName)).check(matches(isDisplayed()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun addSourceCheckContent() {
|
||||||
|
testAddSourceWithUrl("https://news.google.com/rss?hl=en-US&gl=US&ceid=US:en", sourceName)
|
||||||
|
onView(isRoot()).perform(ViewActions.pressBack())
|
||||||
|
openMenu()
|
||||||
|
onView(withText(R.string.menu_home_refresh)).perform(click())
|
||||||
|
onView(withText(R.string.refresh_dialog_message)).check(matches(isDisplayed()))
|
||||||
|
onView(
|
||||||
|
withId(android.R.id.button1)
|
||||||
|
).perform(click())
|
||||||
|
Thread.sleep(10000)
|
||||||
|
onView(withId(R.id.swipeRefreshLayout)).perform(swipeDown())
|
||||||
|
Thread.sleep(2000)
|
||||||
|
try {
|
||||||
|
onView(withId(R.id.sourceTitleAndDate)).check(matches(isDisplayed()))
|
||||||
|
} catch (e: AmbiguousViewMatcherException) {
|
||||||
|
assert(true)
|
||||||
|
}
|
||||||
|
goToSources()
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun deleteTheCreatedSource() {
|
||||||
|
onView(withText(sourceName)).check(matches(isDisplayed()))
|
||||||
|
onView(withId(R.id.deleteBtn)).perform(click())
|
||||||
|
onView(withText(sourceName)).check(doesNotExist())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun goToSources() {
|
||||||
|
openMenu()
|
||||||
|
onView(withText(R.string.menu_home_sources))
|
||||||
|
.perform(click())
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android
|
package bou.amine.apps.readerforselfossv2.android
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@ -7,6 +8,8 @@ import android.widget.RelativeLayout
|
|||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||||
import androidx.test.espresso.Root
|
import androidx.test.espresso.Root
|
||||||
import androidx.test.espresso.matcher.RootMatchers.isPlatformPopup
|
import androidx.test.espresso.matcher.RootMatchers.isPlatformPopup
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
||||||
@ -98,4 +101,10 @@ fun withSettingsCheckboxFrame(@StringRes id: Int): Matcher<View>? {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openMenu() {
|
||||||
|
openActionBarOverflowOrOptionsMenu(
|
||||||
|
ApplicationProvider.getApplicationContext<Context>()
|
||||||
|
)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user