swipe tests that try all the horizontal swipe motions
This commit is contained in:
parent
55cb729a2d
commit
35d11512c1
|
@ -8,10 +8,9 @@ import androidx.test.espresso.action.ViewActions.swipeRight
|
|||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
@ -20,8 +19,8 @@ import org.junit.runner.RunWith
|
|||
@RunWith(AndroidJUnit4::class)
|
||||
class SwipeTest {
|
||||
@get:Rule
|
||||
var activityRule: ActivityScenarioRule<MainActivity>
|
||||
= ActivityScenarioRule(MainActivity::class.java)
|
||||
var activityRule: ActivityTestRule<MainActivity>
|
||||
= ActivityTestRule(MainActivity::class.java)
|
||||
@Before
|
||||
fun before(){
|
||||
val preferences = getInstrumentation()
|
||||
|
@ -31,30 +30,29 @@ class SwipeTest {
|
|||
ActivityScenario.launch(MainActivity::class.java)
|
||||
}
|
||||
|
||||
fun swipingLeftOnSearchShowsCameraFragment() {
|
||||
onView(withId(R.id.main_activity_main_linear_layout))
|
||||
.perform(swipeLeft()) // go to search
|
||||
.perform(swipeLeft())
|
||||
onView(withId(R.id.camera_fragment_main_linear_layout)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun swipingRightOnNotificationsShowsCameraFragment() {
|
||||
fun swipingLeftStopsAtProfile() {
|
||||
onView(withId(R.id.main_activity_main_linear_layout))
|
||||
.perform(swipeLeft())
|
||||
.perform(swipeLeft())
|
||||
.perform(swipeLeft()) // go to notifications
|
||||
.perform(swipeRight())
|
||||
onView(withId(R.id.camera_fragment_main_linear_layout)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun swipingLeftShowsProfileFragment() {
|
||||
onView(withId(R.id.view_pager))
|
||||
.perform(swipeLeft())
|
||||
.perform(swipeLeft())
|
||||
.perform(swipeLeft())
|
||||
.perform(swipeLeft())
|
||||
.perform(swipeLeft()) // search
|
||||
.perform(swipeLeft()) // camera
|
||||
.perform(swipeLeft()) // notifications
|
||||
.perform(swipeLeft()) // profile
|
||||
.perform(swipeLeft()) // should stop at profile
|
||||
onView(withId(R.id.nbFollowersTextView)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun swipingRightStopsAtHomepage() {
|
||||
onView(withId(R.id.main_activity_main_linear_layout))
|
||||
.perform(swipeLeft()) // search
|
||||
.perform(swipeLeft()) // camera
|
||||
.perform(swipeLeft()) // notifications
|
||||
.perform(swipeLeft()) // profile
|
||||
.perform(swipeRight()) // notifications
|
||||
.perform(swipeRight()) // camera
|
||||
.perform(swipeRight()) // search
|
||||
.perform(swipeRight()) // homepage
|
||||
.perform(swipeRight()) // should stop at homepage
|
||||
onView(withId(R.id.feedList)).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import android.content.Intent
|
|||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
|
@ -21,7 +20,6 @@ import com.h.pixeldroid.fragments.HomeFragment
|
|||
import com.h.pixeldroid.fragments.MyProfileFragment
|
||||
import com.h.pixeldroid.fragments.NotificationsFragment
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
private lateinit var drawerLayout: DrawerLayout
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in New Issue