mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
#1212 fix test packaging and update multidex proguard rules
This commit is contained in:
parent
6069676ddb
commit
d816380d43
@ -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.** { *; }
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (C) 2018 Kiwix <android.kiwix.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<MainActivity> 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);*/
|
||||
}
|
||||
}
|
@ -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<Book> 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<Book> 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<Book> getFakeData(String baseFileName) throws IOException {
|
||||
ArrayList<Book> 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
|
||||
|
@ -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;
|
@ -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 {
|
@ -0,0 +1,225 @@
|
||||
package org.kiwix.kiwixmobile.data.local.dao;/*
|
||||
* Kiwix Android
|
||||
* Copyright (C) 2018 Kiwix <android.kiwix.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Book> 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<Book> 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<Book> getFakeData(String baseFileName) throws IOException {
|
||||
ArrayList<Book> 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();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
package org.kiwix.kiwixmobile.data.local.dao;/*
|
||||
* Kiwix Android
|
||||
* Copyright (C) 2018 Kiwix <android.kiwix.org>
|
||||
*
|
||||
@ -16,8 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
@ -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)
|
@ -1,26 +1,38 @@
|
||||
package org.kiwix.kiwixmobile;
|
||||
package org.kiwix.kiwixmobile.settings;
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (C) 2018 Kiwix <android.kiwix.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<MainActivity> activityTestRule =
|
||||
new ActivityTestRule<>(MainActivity.class);
|
||||
@ -124,3 +136,4 @@ public class SettingsActivityTest {
|
||||
assertDisplayed(R.string.clear_all_history_dialog_title);
|
||||
}
|
||||
}
|
||||
|
@ -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<ZimManageActivity>() {
|
||||
@get:Rule
|
@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.manage
|
||||
package org.kiwix.kiwixmobile.zim_manager
|
||||
|
||||
import applyWithViewHierarchyPrinting
|
||||
import org.kiwix.kiwixmobile.BaseRobot
|
Loading…
x
Reference in New Issue
Block a user