diff --git a/build.gradle b/build.gradle index c706f54e6..4db7626f4 100644 --- a/build.gradle +++ b/build.gradle @@ -135,6 +135,18 @@ dependencies { implementation 'com.github.dmytrodanylyk.android-process-button:library:1.0.4' implementation 'com.l4digital.fastscroll:fastscroll:2.0.1' +// Espresso Testing Framework Implementations + def ESPRESSO_LIBRARY_VERSION = "3.2.0" + androidTestImplementation ("androidx.test.espresso:espresso-core:${ESPRESSO_LIBRARY_VERSION}") { + exclude group: "javax.inject" + } + androidTestImplementation ("androidx.test.espresso:espresso-web:${ESPRESSO_LIBRARY_VERSION}") { + exclude group: "javax.inject" + } + androidTestImplementation ("androidx.test.espresso:espresso-intents:${ESPRESSO_LIBRARY_VERSION}") { + exclude group: "javax.inject" + } + // Otto and Retrofit implementation 'com.squareup:otto:1.3.8' implementation 'com.github.apl-devs:appintro:v4.2.3' diff --git a/src/androidTest/java/org/amahi/anywhere/activity/IntroductionActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/IntroductionActivityTest.java new file mode 100644 index 000000000..bda7cbcf7 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/IntroductionActivityTest.java @@ -0,0 +1,74 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class IntroductionActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(IntroductionActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.intro_phone_1)).check(matches(isDisplayed())); + onView(withText(R.string.intro_desc_phone_1)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withText(R.string.intro_title_2)); + onView(withText(R.string.intro_desc_2)); + } + + @Test + public void test3() { + onView(withText(R.string.intro_title_3)); + onView(withText(R.string.intro_desc_phone_3)); + } + + @Test + public void test4() { + onView(withText(R.string.intro_title_4)); + onView(withText(R.string.intro_desc_phone_4)); + } + + @Test + public void test5() { + onView(withText(R.string.intro_title_5)); + onView(withText(R.string.intro_desc_phone_5)); + } + + @Test + public void test6() { + onView(withText(R.string.intro_title_6)); + onView(withText(R.string.intro_desc_6)); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/NativeVideoActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/NativeVideoActivityTest.java new file mode 100644 index 000000000..a5acba208 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/NativeVideoActivityTest.java @@ -0,0 +1,74 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class NativeVideoActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(IntroductionActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.intro_phone_1)).check(matches(isDisplayed())); + onView(withText(R.string.intro_desc_phone_1)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withText(R.string.intro_title_2)); + onView(withText(R.string.intro_desc_2)); + } + + @Test + public void test3() { + onView(withText(R.string.intro_title_3)); + onView(withText(R.string.intro_desc_phone_3)); + } + + @Test + public void test4() { + onView(withText(R.string.intro_title_4)); + onView(withText(R.string.intro_desc_phone_4)); + } + + @Test + public void test5() { + onView(withText(R.string.intro_title_5)); + onView(withText(R.string.intro_desc_phone_5)); + } + + @Test + public void test6() { + onView(withText(R.string.intro_title_6)); + onView(withText(R.string.intro_desc_6)); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/NavigationActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/NavigationActivityTest.java new file mode 100644 index 000000000..4e3565146 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/NavigationActivityTest.java @@ -0,0 +1,87 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class NavigationActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(NavigationActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withId(R.id.view_stub_tv_loading)); + } + + @Test + public void test2() { + onView(withId(R.id.tv_loading)); + } + + @Test + public void test3() { + onView(withId(R.id.container_content)); + } + + @Test + public void test4() { + onView(withId(R.id.container_navigation)); + } + + @Test + public void test5() { + onView(withId(R.id.toolbar)); + } + + @Test + public void test6() { + onView(withText(R.string.title_shares)); + } + + @Test + public void test7() { + onView(withText(R.string.menu_navigation_open)); + } + + @Test + public void test8() { + onView(withId(R.id.drawer_content)); + } + + @Test + public void test9() { + onView(withText(R.string.application_name)); + } + + @Test + public void test10() { + onView(withText(R.string.title_apps)); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/RecentFilesActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/RecentFilesActivityTest.java new file mode 100644 index 000000000..0503a3ad5 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/RecentFilesActivityTest.java @@ -0,0 +1,76 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.not; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class RecentFilesActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(RecentFilesActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.title_recent_files)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(R.id.recent_list)).check(matches(not(isDisplayed()))); + } + + @Test + public void test3() { + onView(withId(android.R.id.empty)).check(matches(isDisplayed())); + } + + @Test + public void test4() { + onView(withId(R.id.layout_refresh)).check(matches(isDisplayed())); + } + + @Test + public void test5() { + onView(withText(R.string.message_delete_file_error)).check(doesNotExist()); + } + + @Test + public void test6() { + onView(withText(R.string.message_offline_file_deleted)).check(doesNotExist()); + } + + @Test + public void test7() { + onView(withId(R.id.media_route_menu_item)).check(doesNotExist()); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/ServerAppActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/ServerAppActivityTest.java new file mode 100644 index 000000000..1c5b46eca --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/ServerAppActivityTest.java @@ -0,0 +1,55 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class ServerAppActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(OfflineFilesActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.title_offline_files)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(R.id.container_files)).check(matches(isDisplayed())); + } + + @Test + public void test3() { + onView(withText(R.string.message_progress_file_downloading)); + } + + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/ServerFileAudioActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/ServerFileAudioActivityTest.java new file mode 100644 index 000000000..1b14f02cc --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/ServerFileAudioActivityTest.java @@ -0,0 +1,91 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.not; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class ServerFileAudioActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(RecentFilesActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.title_recent_files)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(R.id.recent_list)).check(matches(not(isDisplayed()))); + } + + @Test + public void test3() { + onView(withId(android.R.id.empty)).check(matches(isDisplayed())); + } + + @Test + public void test4() { + onView(withId(R.id.layout_refresh)).check(matches(isDisplayed())); + } + + @Test + public void test5() { + onView(withText(R.string.message_delete_file_error)).check(doesNotExist()); + } + + @Test + public void test6() { + onView(withText(R.string.message_offline_file_deleted)).check(doesNotExist()); + } + + @Test + public void test7() { + onView(withId(R.id.media_route_menu_item)).check(doesNotExist()); + } + + @Test + public void test8() { + onView(withId(R.id.media_route_menu_item)); + } + + @Test + public void test9() { + onView(withId(R.id.menu_audio_list)); + } + + @Test + public void test10() { + onView(withId(R.id.audio_list_container)); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/ServerFileImageActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/ServerFileImageActivityTest.java new file mode 100644 index 000000000..8034bd826 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/ServerFileImageActivityTest.java @@ -0,0 +1,50 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.not; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class ServerFileImageActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(RecentFilesActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.title_recent_files)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(R.id.recent_list)).check(matches(not(isDisplayed()))); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/ServerFileVideoActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/ServerFileVideoActivityTest.java new file mode 100644 index 000000000..aa8825c48 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/ServerFileVideoActivityTest.java @@ -0,0 +1,81 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.not; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class ServerFileVideoActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(RecentFilesActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.title_recent_files)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(R.id.recent_list)).check(matches(not(isDisplayed()))); + } + + @Test + public void test3() { + onView(withId(android.R.id.empty)).check(matches(isDisplayed())); + } + + @Test + public void test4() { + onView(withId(R.id.layout_refresh)).check(matches(isDisplayed())); + } + + @Test + public void test5() { + onView(withText(R.string.message_delete_file_error)).check(doesNotExist()); + } + + @Test + public void test6() { + onView(withText(R.string.message_offline_file_deleted)).check(doesNotExist()); + } + + @Test + public void test7() { + onView(withId(R.id.media_route_menu_item)).check(doesNotExist()); + } + + @Test + public void test8() { + onView(withText(R.string.title_recent_files)).check(matches(isDisplayed())); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/ServerFilesActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/ServerFilesActivityTest.java new file mode 100644 index 000000000..3c1cad476 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/ServerFilesActivityTest.java @@ -0,0 +1,69 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class ServerFilesActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(OfflineFilesActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withText(R.string.title_offline_files)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(R.id.container_files)).check(matches(isDisplayed())); + } + + @Test + public void test3() { + onView(withText(R.string.message_progress_file_downloading)); + } + + @Test + public void test4() { + onView(withText(R.string.title_offline_files)).check(matches(isDisplayed())); + } + + @Test + public void test5() { + onView(withId(R.id.container_files)).check(matches(isDisplayed())); + } + + @Test + public void test6() { + onView(withText(R.string.message_progress_file_downloading)); + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/src/androidTest/java/org/amahi/anywhere/activity/SettingsActivityTest.java b/src/androidTest/java/org/amahi/anywhere/activity/SettingsActivityTest.java new file mode 100644 index 000000000..e702e1748 --- /dev/null +++ b/src/androidTest/java/org/amahi/anywhere/activity/SettingsActivityTest.java @@ -0,0 +1,48 @@ +package org.amahi.anywhere.activity; + +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + +import org.amahi.anywhere.R; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; + +@RunWith(AndroidJUnit4.class) +@LargeTest +@FixMethodOrder(MethodSorters.DEFAULT) + +public class SettingsActivityTest { + + @Rule + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(SettingsActivity.class); + + @Before + public void setUp() throws Exception { + } + + @Test + public void test1() { + onView(withId(R.id.settings_container)).check(matches(isDisplayed())); + } + + @Test + public void test2() { + onView(withId(android.R.id.home)); + } + + @After + public void tearDown() throws Exception { + } +}