Merge remote-tracking branch 'origin/Tests' into Tests
This commit is contained in:
@@ -28,7 +28,6 @@ public class LocationFragmentTest {
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new LocationFragment()).commit();
|
||||
onView(withId(R.id.location_back_button)).perform(click());
|
||||
onView(withId(R.id.homeFragment)).check(matches(isDisplayed()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import androidx.test.espresso.action.ViewActions;
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions;
|
||||
import androidx.test.espresso.matcher.RootMatchers;
|
||||
import androidx.test.espresso.matcher.ViewMatchers;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import com.a1.nextlocation.fragments.LocationFragment;
|
||||
import com.a1.nextlocation.fragments.RouteDetailFragment;
|
||||
import com.a1.nextlocation.fragments.SettingsFragment;
|
||||
import com.a1.nextlocation.fragments.StatisticFragment;
|
||||
|
||||
import org.hamcrest.core.AllOf;
|
||||
import org.hamcrest.core.Is;
|
||||
import org.hamcrest.core.IsInstanceOf;
|
||||
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.RootMatchers.isPlatformPopup;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class RouteDetailFragmentTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);
|
||||
|
||||
@Test
|
||||
public void clickBackButton() throws Exception{
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new RouteDetailFragment()).commit();
|
||||
onView(withId(R.id.routeDetailBackButton)).perform(click());
|
||||
onView(withId(R.id.homeFragment)).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import androidx.test.espresso.action.ViewActions;
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions;
|
||||
import androidx.test.espresso.matcher.RootMatchers;
|
||||
import androidx.test.espresso.matcher.ViewMatchers;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import com.a1.nextlocation.fragments.LocationFragment;
|
||||
import com.a1.nextlocation.fragments.SettingsFragment;
|
||||
import com.a1.nextlocation.fragments.StatisticFragment;
|
||||
|
||||
import org.hamcrest.core.AllOf;
|
||||
import org.hamcrest.core.Is;
|
||||
import org.hamcrest.core.IsInstanceOf;
|
||||
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.RootMatchers.isPlatformPopup;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class SettingsFragmentTest {
|
||||
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);
|
||||
|
||||
//Tests if the back button sends you back home
|
||||
@Test
|
||||
public void clickBackButton() throws Exception{
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new SettingsFragment()).commit();
|
||||
onView(withId(R.id.settings_back_button)).perform(click());
|
||||
onView(withId(R.id.homeFragment)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
//Checks if the dropdown is clickable, and checks if it has children
|
||||
@Test
|
||||
public void dropdownTest(){
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new SettingsFragment()).commit();
|
||||
onView(withId(R.id.dropdown_menu_Settings)).check(matches(isClickable()));
|
||||
onView(withId(R.id.dropdown_menu_Settings)).check(matches(hasMinimumChildCount(1)));
|
||||
}
|
||||
|
||||
//Tests if all buttons are clickable, and if they get checked after being clicked.
|
||||
@Test
|
||||
public void buttonTest(){
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new SettingsFragment()).commit();
|
||||
onView(withId(R.id.settingsImperialButton)).check(matches(isClickable()));
|
||||
onView(withId(R.id.settingsOldButton)).check(matches(isClickable()));
|
||||
onView(withId(R.id.settingsEyesButton)).check(matches(isClickable()));
|
||||
|
||||
onView(withId(R.id.settingsImperialButton)).perform(click());
|
||||
onView(withId(R.id.settingsImperialButton)).check(matches(isChecked()));
|
||||
|
||||
onView(withId(R.id.settingsOldButton)).perform(click());
|
||||
onView(withId(R.id.settingsOldButton)).check(matches(isChecked()));
|
||||
|
||||
onView(withId(R.id.settingsEyesButton)).perform(click());
|
||||
onView(withId(R.id.settingsEyesButton)).check(matches(isChecked()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.a1.nextlocation;
|
||||
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import com.a1.nextlocation.fragments.LocationFragment;
|
||||
import com.a1.nextlocation.fragments.StatisticFragment;
|
||||
|
||||
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 StatisticFragmentTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);
|
||||
|
||||
//Tests to see if all boxes get created
|
||||
@Test
|
||||
public void checkText() throws Exception{
|
||||
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new StatisticFragment()).commit();
|
||||
onView(withId(R.id.textView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.name_box)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.Box2)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.Box3)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.Box4)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -115,6 +115,7 @@
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/settingsImperialButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -159,6 +160,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/settingsOldButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -205,6 +207,7 @@
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/settingsEyesButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
Reference in New Issue
Block a user