[ADD] Location Tests + ID at every XML file
This commit is contained in:
@@ -56,4 +56,7 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
testImplementation 'org.mockito:mockito-core:2.7.22'
|
||||
androidTestImplementation 'com.21buttons:fragment-test-rule:2.0.1'
|
||||
androidTestImplementation 'androidx.test:rules:1.3.0-beta01'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0-alpha02'
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import com.a1.nextlocation.fragments.LocationFragment;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static androidx.test.espresso.Espresso.*;
|
||||
import static androidx.test.espresso.action.ViewActions.*;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.*;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
||||
|
||||
|
||||
public class LocationFragmentTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);
|
||||
|
||||
@Test
|
||||
public void clickBackButton() throws Exception{
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new LocationFragment()).commit();
|
||||
onView(withId(R.id.locationBackButton)).perform(click());
|
||||
onView(withId(R.id.homeFragment)).check(matches(isDisplayed()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clickDetailButton() throws Exception{
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new LocationFragment()).commit();
|
||||
onView(withId(R.id.locationRecyclerView)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
|
||||
onView(withId(R.id.locationDetailFragment)).check(matches(isDisplayed()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/mainActivity"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<FrameLayout
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/couponItem"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/couponFragment"
|
||||
tools:context=".fragments.LocationFragment">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/homeFragment"
|
||||
tools:context=".fragments.HomeFragment">
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/locationFragment"
|
||||
tools:context=".fragments.LocationFragment">
|
||||
|
||||
<TextView
|
||||
@@ -35,5 +36,5 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/routeBackButton" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/locationBackButton" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/locationDetailFragment"
|
||||
tools:context=".fragments.LocationDetailFragment">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/routeFragment"
|
||||
tools:context=".fragments.RouteFragment">
|
||||
|
||||
<ImageButton
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/routeDetailFragment"
|
||||
tools:context=".fragments.RouteDetailFragment">
|
||||
|
||||
<ImageButton
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/settingFragment"
|
||||
tools:context=".fragments.SettingsFragment">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/primaryColour"
|
||||
android:id="@+id/statisticsFragment"
|
||||
tools:context=".fragments.StatisticFragment">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
android:layout_height="50dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/secondaryColour"
|
||||
android:id="@+id/locationItem"
|
||||
android:layout_margin="20dp">
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
android:layout_height="50dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/secondaryColour"
|
||||
android:id="@+id/routeItem"
|
||||
android:layout_margin="20dp">
|
||||
|
||||
<ImageView
|
||||
|
||||
Reference in New Issue
Block a user