diff --git a/app/multidex-instrumentation-config.pro b/app/multidex-instrumentation-config.pro index fb017e9ad..f35052ea5 100644 --- a/app/multidex-instrumentation-config.pro +++ b/app/multidex-instrumentation-config.pro @@ -1,5 +1,5 @@ # Pre android 5.0 test dependencies must be in the primary dex -keep class org.hamcrest.Matchers --keep class org.kiwix.kiwixmobile.tests.** { *; } +-keep class org.kiwix.kiwixmobile.** { *; } -keep class org.mockito.** { *; } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BasicTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/BasicTest.java deleted file mode 100644 index 9f08ca431..000000000 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BasicTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Kiwix Android - * Copyright (C) 2018 Kiwix - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.kiwix.kiwixmobile; - -import android.Manifest; -import androidx.test.filters.LargeTest; -import androidx.test.rule.ActivityTestRule; -import androidx.test.rule.GrantPermissionRule; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.kiwix.kiwixmobile.main.MainActivity; - -//import android.view.Gravity; -//import org.kiwix.kiwixmobile.R; -/* - -import static com.schibsted.spain.barista.assertion.BaristaDrawerAssertions.assertDrawerIsClosed; -import static com.schibsted.spain.barista.assertion.BaristaDrawerAssertions.assertDrawerIsClosedWithGravity; -import static com.schibsted.spain.barista.assertion.BaristaDrawerAssertions.assertDrawerIsOpen; -import static com.schibsted.spain.barista.assertion.BaristaDrawerAssertions.assertDrawerIsOpenWithGravity; -import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed; -import static com.schibsted.spain.barista.interaction.BaristaDrawerInteractions.closeDrawer; -import static com.schibsted.spain.barista.interaction.BaristaDrawerInteractions.closeDrawerWithGravity; -import static com.schibsted.spain.barista.interaction.BaristaDrawerInteractions.openDrawer; -import static com.schibsted.spain.barista.interaction.BaristaDrawerInteractions.openDrawerWithGravity; -*/ - -@LargeTest -@RunWith(AndroidJUnit4.class) -public class BasicTest { - - @Rule - public ActivityTestRule activityTestRule = - new ActivityTestRule<>(MainActivity.class); - @Rule - public GrantPermissionRule readPermissionRule = - GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); - @Rule - public GrantPermissionRule writePermissionRule = - GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); - - @Test - public void basicTest() {/* - todo refactor for new tabs switcher - openDrawer(); - - assertDrawerIsOpen(); - - assertDisplayed(R.id.titleText); - assertDisplayed(R.id.left_drawer_list); - assertDisplayed(R.id.new_tab_button); - - closeDrawer(); - - assertDrawerIsClosed();*/ - } - - @Test - public void testRightDrawer() {/* - todo refactor for new tabs switcher - openDrawerWithGravity(R.id.drawer_layout, Gravity.RIGHT); - assertDrawerIsOpenWithGravity(R.id.drawer_layout, Gravity.RIGHT); - - assertDisplayed(R.string.menu_help); - - closeDrawerWithGravity(R.id.drawer_layout, Gravity.RIGHT); - assertDrawerIsClosedWithGravity(R.id.drawer_layout, Gravity.RIGHT);*/ - } -} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BookDatabaseTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/BookDatabaseTest.java index 7633586cb..326eb04eb 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BookDatabaseTest.java +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/BookDatabaseTest.java @@ -42,188 +42,4 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @RunWith(AndroidJUnit4.class) -public class BookDatabaseTest { - - private Context context; - private @Mock - KiwixDatabase kiwixDatabase; - private BookDao bookDao; - private boolean mockInitialized = false; - private File testDir; - - @Before - public void executeBefore() { - if (!mockInitialized) { - MockitoAnnotations.initMocks(this); - mockInitialized = true; - } - context = InstrumentationRegistry.getTargetContext(); - //kiwixDatabase = new KiwixDatabase(context); - bookDao = new BookDao(kiwixDatabase); - - // Create a temporary directory where all the test files will be saved - testDir = context.getDir("testDir", Context.MODE_PRIVATE); - } - - //TODO : test books are saved after downloading the list of available zim files - - @Test - public void testGetBooks() throws IOException { - // Save the fake data to test - String testId = "6qq5301d-2cr0-ebg5-474h-6db70j52864p"; - String fileName = testDir.getPath() + "/" + testId + "testFile"; - ArrayList booksToAdd = getFakeData(fileName); - - // Set up the mocks - when(kiwixDatabase.deleteWhere(any(), any())).thenReturn(0); - - // Get the filtered book list from the database (using the internal selection logic in BookDao) - ArrayList booksRetrieved = bookDao.filterBookResults(booksToAdd); - - // Test whether the correct books are returned - - // Filename ends with .zim and the file exists in memory - if (!booksRetrieved.contains(booksToAdd.get(0))) assertEquals(0, 1); - verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(0).file.getPath())); - - // Filename ends with .part and the file exists in memory - if (booksRetrieved.contains(booksToAdd.get(1))) assertEquals(0, 1); - verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(1).file.getPath())); - - // Filename ends with .zim, however only the .zim.part file exists in memory - if (booksRetrieved.contains(booksToAdd.get(2))) assertEquals(0, 1); - verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(2).file.getPath())); - - // Filename ends with .zim but neither the .zim, nor the .zim.part file exists in memory - if (booksRetrieved.contains(booksToAdd.get(3))) assertEquals(0, 1); - verify(kiwixDatabase).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(3).file.getPath())); - - // Filename ends with .zim and both the .zim, and the .zim.part files exists in memory - if (!booksRetrieved.contains(booksToAdd.get(4))) assertEquals(0, 1); - verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(4).file.getPath())); - - // If the filename ends with .zimXX - - // FileName.zimXX.part does not exist for any value of "XX" from "aa" till "dr", but FileName.zimXX exists for all "XX" from "aa', till "ds", then it does not exist - // Also, the file inside the BooksToAdd does exist in memory - if (!booksRetrieved.contains(booksToAdd.get(5))) assertEquals(0, 1); - verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(5).file.getPath())); - - // FileName.zimXX.part does not exist for any value of "XX" from "aa" till "dr", but FileName.zimXX exists for all "XX" from "aa', till "ds", then it does not exist - // Also, the file inside the BooksToAdd also not exist in memory - if (booksRetrieved.contains(booksToAdd.get(6))) assertEquals(0, 1); - verify(kiwixDatabase).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(6).file.getPath())); - - // FileName.zimXX.part exists for some "XX" between "aa" till "bl" - // And FileName.zimXX exists for all "XX" from "aa', till "bk", and then it does not exist - // Also, the file inside the BooksToAdd does exist in memory - if (!booksRetrieved.contains(booksToAdd.get(7))) assertEquals(0, 1); - verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(7).file.getPath())); - - // FileName.zimXX.part exists for some "XX" between "aa" till "bl" - // And FileName.zimXX exists for all "XX" from "aa', till "bk", and then it does not exist - // Also, the file inside the BooksToAdd does not exist in memory - if (booksRetrieved.contains(booksToAdd.get(8))) assertEquals(0, 1); - verify(kiwixDatabase).deleteWhere(BookDatabaseEntity.class, - BookDatabaseEntity.URL.eq(booksToAdd.get(8).file.getPath())); - } - - private ArrayList getFakeData(String baseFileName) throws IOException { - ArrayList books = new ArrayList<>(); - for (int i = 0; i < 9; i++) { - Book book = new Book(); - book.bookName = "Test Copy " + i; - book.id = "Test ID " + i; - String fileName = baseFileName + i; - switch (i) { - case 0: - book.file = new File(fileName + ".zim"); - book.file.createNewFile(); - break; - case 1: - book.file = new File(fileName + ".part"); - book.file.createNewFile(); - break; - case 2: - book.file = new File(fileName + ".zim"); - File t2 = new File(fileName + ".zim.part"); - t2.createNewFile(); - break; - case 3: - book.file = new File(fileName + ".zim"); - break; - case 4: - book.file = new File(fileName + ".zim"); - book.file.createNewFile(); - File t4 = new File(fileName + ".zim.part"); - t4.createNewFile(); - break; - case 5: - book.file = new File(fileName + ".zimdg"); - setupCase1(fileName); - break; - case 6: - book.file = new File(fileName + ".zimyr"); - setupCase2(fileName); - break; - case 7: - book.file = new File(fileName + ".zimdg"); - setupCase1(fileName); - break; - case 8: - book.file = new File(fileName + ".zimyr"); - setupCase2(fileName); - break; - } - books.add(book); - } - return books; - } - - private void setupCase1(String fileName) throws IOException { - for (char char1 = 'a'; char1 <= 'z'; char1++) { - for (char char2 = 'a'; char2 <= 'z'; char2++) { - File file = new File(fileName + ".zim" + char1 + char2); - file.createNewFile(); - if (char1 == 'd' && char2 == 'r') { - break; - } - } - if (char1 == 'd') { - break; - } - } - } - - private void setupCase2(String fileName) throws IOException { - for (char char1 = 'a'; char1 <= 'z'; char1++) { - for (char char2 = 'a'; char2 <= 'z'; char2++) { - File file = new File(fileName + ".zim" + char1 + char2); - file.createNewFile(); - if (char1 == 'd' && char2 == 'r') { - break; - } - } - if (char1 == 'd') { - break; - } - } - File t = new File(fileName + ".zimcp.part"); - } - - @After - public void RemoveTestDirectory() { - for (File child : testDir.listFiles()) { - child.delete(); - } - testDir.delete(); - } -} +public class BookDatabaseTest diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/package-info.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/package-info.java deleted file mode 100644 index 2569f2920..000000000 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * These are very simple activity starting and navigation tests. - * Their purpose is to ensure that navigation is possible without causing crashes. - * - * SplashActivity contains various tests of navigating to other activities, along with starting - * itself. - * - * Each test contains: - * - * @Test public void empty() { - * - * } - * - * This forces JUnit to execute the ActivityRule, and then exit immediately (start and stop the - * Activity) - */ - -package org.kiwix.kiwixmobile.activities; diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/BookmarksActivityTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/bookmark/BookmarksActivityTest.java similarity index 88% rename from app/src/androidTest/java/org/kiwix/kiwixmobile/activities/BookmarksActivityTest.java rename to app/src/androidTest/java/org/kiwix/kiwixmobile/bookmark/BookmarksActivityTest.java index 8aec06a0a..8653abc5e 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/BookmarksActivityTest.java +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/bookmark/BookmarksActivityTest.java @@ -1,4 +1,4 @@ -package org.kiwix.kiwixmobile.activities; +package org.kiwix.kiwixmobile.bookmark; import android.Manifest; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -7,7 +7,6 @@ import androidx.test.rule.GrantPermissionRule; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.kiwix.kiwixmobile.bookmark.BookmarksActivity; @RunWith(AndroidJUnit4.class) public class BookmarksActivityTest { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/BookDaoTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/BookDaoTest.java new file mode 100644 index 000000000..56897a773 --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/BookDaoTest.java @@ -0,0 +1,225 @@ +package org.kiwix.kiwixmobile.data.local.dao;/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import android.content.Context; +import androidx.test.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.kiwix.kiwixmobile.data.local.KiwixDatabase; +import org.kiwix.kiwixmobile.data.local.entity.BookDatabaseEntity; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@RunWith(AndroidJUnit4.class) +public class BookDaoTest { + + private Context context; + private @Mock + KiwixDatabase kiwixDatabase; + private BookDao bookDao; + private boolean mockInitialized = false; + private File testDir; + + @Before + public void executeBefore() { + if (!mockInitialized) { + MockitoAnnotations.initMocks(this); + mockInitialized = true; + } + context = InstrumentationRegistry.getTargetContext(); + //kiwixDatabase = new KiwixDatabase(context); + bookDao = new BookDao(kiwixDatabase); + + // Create a temporary directory where all the test files will be saved + testDir = context.getDir("testDir", Context.MODE_PRIVATE); + } + + //TODO : test books are saved after downloading the list of available zim files + + @Test + public void testGetBooks() throws IOException { + // Save the fake data to test + String testId = "6qq5301d-2cr0-ebg5-474h-6db70j52864p"; + String fileName = testDir.getPath() + "/" + testId + "testFile"; + ArrayList booksToAdd = getFakeData(fileName); + + // Set up the mocks + when(kiwixDatabase.deleteWhere(any(), any())).thenReturn(0); + + // Get the filtered book list from the database (using the internal selection logic in BookDao) + ArrayList booksRetrieved = bookDao.filterBookResults(booksToAdd); + + // Test whether the correct books are returned + + // Filename ends with .zim and the file exists in memory + if (!booksRetrieved.contains(booksToAdd.get(0))) assertEquals(0, 1); + verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(0).file.getPath())); + + // Filename ends with .part and the file exists in memory + if (booksRetrieved.contains(booksToAdd.get(1))) assertEquals(0, 1); + verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(1).file.getPath())); + + // Filename ends with .zim, however only the .zim.part file exists in memory + if (booksRetrieved.contains(booksToAdd.get(2))) assertEquals(0, 1); + verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(2).file.getPath())); + + // Filename ends with .zim but neither the .zim, nor the .zim.part file exists in memory + if (booksRetrieved.contains(booksToAdd.get(3))) assertEquals(0, 1); + verify(kiwixDatabase).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(3).file.getPath())); + + // Filename ends with .zim and both the .zim, and the .zim.part files exists in memory + if (!booksRetrieved.contains(booksToAdd.get(4))) assertEquals(0, 1); + verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(4).file.getPath())); + + // If the filename ends with .zimXX + + // FileName.zimXX.part does not exist for any value of "XX" from "aa" till "dr", but FileName.zimXX exists for all "XX" from "aa', till "ds", then it does not exist + // Also, the file inside the BooksToAdd does exist in memory + if (!booksRetrieved.contains(booksToAdd.get(5))) assertEquals(0, 1); + verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(5).file.getPath())); + + // FileName.zimXX.part does not exist for any value of "XX" from "aa" till "dr", but FileName.zimXX exists for all "XX" from "aa', till "ds", then it does not exist + // Also, the file inside the BooksToAdd also not exist in memory + if (booksRetrieved.contains(booksToAdd.get(6))) assertEquals(0, 1); + verify(kiwixDatabase).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(6).file.getPath())); + + // FileName.zimXX.part exists for some "XX" between "aa" till "bl" + // And FileName.zimXX exists for all "XX" from "aa', till "bk", and then it does not exist + // Also, the file inside the BooksToAdd does exist in memory + if (!booksRetrieved.contains(booksToAdd.get(7))) assertEquals(0, 1); + verify(kiwixDatabase, never()).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(7).file.getPath())); + + // FileName.zimXX.part exists for some "XX" between "aa" till "bl" + // And FileName.zimXX exists for all "XX" from "aa', till "bk", and then it does not exist + // Also, the file inside the BooksToAdd does not exist in memory + if (booksRetrieved.contains(booksToAdd.get(8))) assertEquals(0, 1); + verify(kiwixDatabase).deleteWhere(BookDatabaseEntity.class, + BookDatabaseEntity.URL.eq(booksToAdd.get(8).file.getPath())); + } + + private ArrayList getFakeData(String baseFileName) throws IOException { + ArrayList books = new ArrayList<>(); + for (int i = 0; i < 9; i++) { + Book book = new Book(); + book.bookName = "Test Copy " + i; + book.id = "Test ID " + i; + String fileName = baseFileName + i; + switch (i) { + case 0: + book.file = new File(fileName + ".zim"); + book.file.createNewFile(); + break; + case 1: + book.file = new File(fileName + ".part"); + book.file.createNewFile(); + break; + case 2: + book.file = new File(fileName + ".zim"); + File t2 = new File(fileName + ".zim.part"); + t2.createNewFile(); + break; + case 3: + book.file = new File(fileName + ".zim"); + break; + case 4: + book.file = new File(fileName + ".zim"); + book.file.createNewFile(); + File t4 = new File(fileName + ".zim.part"); + t4.createNewFile(); + break; + case 5: + book.file = new File(fileName + ".zimdg"); + setupCase1(fileName); + break; + case 6: + book.file = new File(fileName + ".zimyr"); + setupCase2(fileName); + break; + case 7: + book.file = new File(fileName + ".zimdg"); + setupCase1(fileName); + break; + case 8: + book.file = new File(fileName + ".zimyr"); + setupCase2(fileName); + break; + } + books.add(book); + } + return books; + } + + private void setupCase1(String fileName) throws IOException { + for (char char1 = 'a'; char1 <= 'z'; char1++) { + for (char char2 = 'a'; char2 <= 'z'; char2++) { + File file = new File(fileName + ".zim" + char1 + char2); + file.createNewFile(); + if (char1 == 'd' && char2 == 'r') { + break; + } + } + if (char1 == 'd') { + break; + } + } + } + + private void setupCase2(String fileName) throws IOException { + for (char char1 = 'a'; char1 <= 'z'; char1++) { + for (char char2 = 'a'; char2 <= 'z'; char2++) { + File file = new File(fileName + ".zim" + char1 + char2); + file.createNewFile(); + if (char1 == 'd' && char2 == 'r') { + break; + } + } + if (char1 == 'd') { + break; + } + } + File t = new File(fileName + ".zimcp.part"); + } + + @After + public void RemoveTestDirectory() { + for (File child : testDir.listFiles()) { + child.delete(); + } + testDir.delete(); + } +} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/RecentSearchDatabaseTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/RecentSearchDaoTest.java similarity index 94% rename from app/src/androidTest/java/org/kiwix/kiwixmobile/RecentSearchDatabaseTest.java rename to app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/RecentSearchDaoTest.java index eaaca23f2..5fe347806 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/RecentSearchDatabaseTest.java +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/RecentSearchDaoTest.java @@ -1,4 +1,4 @@ -/* +package org.kiwix.kiwixmobile.data.local.dao;/* * Kiwix Android * Copyright (C) 2018 Kiwix * @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -package org.kiwix.kiwixmobile; - import androidx.test.ext.junit.runners.AndroidJUnit4; import com.yahoo.squidb.data.AbstractModel; import com.yahoo.squidb.data.SquidCursor; @@ -27,7 +25,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.kiwix.kiwixmobile.data.ZimContentProvider; import org.kiwix.kiwixmobile.data.local.KiwixDatabase; -import org.kiwix.kiwixmobile.data.local.dao.RecentSearchDao; import org.kiwix.kiwixmobile.data.local.entity.RecentSearch; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -38,7 +35,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @RunWith(AndroidJUnit4.class) -public class RecentSearchDatabaseTest { +public class RecentSearchDaoTest { @Mock private KiwixDatabase kiwixDatabase; private RecentSearchDao recentSearchDao; diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/SearchActivityTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchActivityTest.java similarity index 89% rename from app/src/androidTest/java/org/kiwix/kiwixmobile/activities/SearchActivityTest.java rename to app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchActivityTest.java index f08f34e6a..0f299af6c 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/activities/SearchActivityTest.java +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchActivityTest.java @@ -1,14 +1,13 @@ -package org.kiwix.kiwixmobile.activities; +package org.kiwix.kiwixmobile.search; import android.Manifest; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; import androidx.test.rule.GrantPermissionRule; -import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.kiwix.kiwixmobile.search.SearchActivity; @LargeTest @RunWith(AndroidJUnit4.class) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/SettingsActivityTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivityTest.java similarity index 78% rename from app/src/androidTest/java/org/kiwix/kiwixmobile/SettingsActivityTest.java rename to app/src/androidTest/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivityTest.java index a7aea9d04..a939e3699 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/SettingsActivityTest.java +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivityTest.java @@ -1,26 +1,38 @@ -package org.kiwix.kiwixmobile; +package org.kiwix.kiwixmobile.settings; +/* + * Kiwix Android + * Copyright (C) 2018 Kiwix + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import android.preference.Preference; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; +import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.main.MainActivity; import static androidx.test.espresso.Espresso.onData; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.matcher.PreferenceMatchers.withKey; -import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.kiwix.kiwixmobile.utils.StandardActions.enterSettings; -@LargeTest -@RunWith(AndroidJUnit4.class) -public class SettingsActivityTest { +public class KiwixSettingsActivityTest{ @Rule public ActivityTestRule activityTestRule = new ActivityTestRule<>(MainActivity.class); @@ -124,3 +136,4 @@ public class SettingsActivityTest { assertDisplayed(R.string.clear_all_history_dialog_title); } } + diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/manage/ZimManageActivityTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivityTest.kt similarity index 94% rename from app/src/androidTest/java/org/kiwix/kiwixmobile/manage/ZimManageActivityTest.kt rename to app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivityTest.kt index 7e0bcaf68..7e465cda8 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/manage/ZimManageActivityTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivityTest.kt @@ -1,4 +1,4 @@ -package org.kiwix.kiwixmobile.manage +package org.kiwix.kiwixmobile.zim_manager import org.junit.Rule import org.junit.Test @@ -8,7 +8,6 @@ import org.kiwix.kiwixmobile.KiwixMockServer import org.kiwix.kiwixmobile.book import org.kiwix.kiwixmobile.libraryNetworkEntity import org.kiwix.kiwixmobile.metaLinkNetworkEntity -import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity class ZimManageActivityTest : BaseActivityTest() { @get:Rule diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/manage/ZimManageRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt similarity index 98% rename from app/src/androidTest/java/org/kiwix/kiwixmobile/manage/ZimManageRobot.kt rename to app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt index 3beff88a7..6d2609160 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/manage/ZimManageRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.kiwix.kiwixmobile.manage +package org.kiwix.kiwixmobile.zim_manager import applyWithViewHierarchyPrinting import org.kiwix.kiwixmobile.BaseRobot