Copy test from branch Issue#19

zim files has been changed but I don't know why.
Change came from commits 3cd8ed98 and 8bff08ca but it is not explain
what are the changes. @MohitMaliFtechiz ?
This commit is contained in:
Matthieu Gautier 2022-12-20 11:53:08 +01:00
parent a0d95cb9c6
commit 3e02f1733f
7 changed files with 189 additions and 140 deletions

View File

@ -0,0 +1,39 @@
cmake_minimum_required (VERSION 3.16)
project (buildkiwix)
add_library(buildkiwix
SHARED
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/base64.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/book.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/filter.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/kiwixicu.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/kiwixreader.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/kiwixsearcher.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/kiwixserver.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/library.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/manager.cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/utils.h
)
find_package(JNI)
if (JNI_FOUND)
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()
include_directories(
/opt/hostedtoolcache/jdk/11.0.17/x64/include
/opt/hostedtoolcache/jdk/11.0.17/x64/include/linux
${CMAKE_SOURCE_DIR}/../../../../../main/cpp
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/include/libkiwix
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/include/libzim
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/include/javah_generated
${CMAKE_SOURCE_DIR}/../../../../../main/cpp/include/utils
)
target_link_libraries(buildkiwix
LINK_PUBLIC
${CMAKE_SOURCE_DIR}/../../../../../../build/libkiwix.so
${CMAKE_SOURCE_DIR}/../../../../../../build/libzim.so
)

View File

@ -9,6 +9,14 @@ die()
exit 1
}
# This is for building wrapper so file
cmake .
make
# Copy generated .so file to build directory to run test cases
cd ../../../../../../../
./gradlew copyBuildKiwixSoFile
cd app/src/androidTests/java/org/kiwix/kiwixlib/
KIWIX_LIB_JAR=$1
if [ -z $KIWIX_LIB_JAR ]
@ -32,6 +40,10 @@ javac -g -d . -s . -cp "junit-4.13.jar:$KIWIX_LIB_JAR" test.java \
|| die "Compilation failed"
java -Djava.library.path="$KIWIX_LIB_DIR" \
-cp "junit-4.13.jar:hamcrest-core-1.3.jar:$KIWIX_LIB_JAR:." \
-javaagent:jacoco-0.8.7/lib/jacocoagent.jar -cp "junit-4.13.jar:hamcrest-core-1.3.jar:$KIWIX_LIB_JAR:." \
org.junit.runner.JUnitCore test \
|| die "Unit test failed"
java -jar jacoco-0.8.7/lib/jacococli.jar report jacoco.exec \
--classfiles org/kiwix/kiwixlib/ \
--html ../../../../../../../build/coverage-report --xml coverage.xml

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,3 @@
import java.io.*;
import java.util.*;
import org.junit.Test;
@ -8,6 +7,8 @@ import org.kiwix.kiwixlib.*;
public class test {
static {
System.loadLibrary("kiwix");
System.loadLibrary("zim");
System.loadLibrary("buildkiwix");
}
private static byte[] getFileContent(String path)
@ -47,7 +48,7 @@ throws JNIKiwixException, IOException
{
JNIKiwixReader reader = new JNIKiwixReader("small.zim");
assertEquals("Test ZIM file", reader.getTitle());
assertEquals(45, reader.getFileSize()); // The file size is in KiB
assertEquals(3, reader.getFileSize()); // The file size is in KiB
assertEquals("A/main.html", reader.getMainPage());
String s = getTextFileContent("small_zimfile_data/main.html");
byte[] c = reader.getContent(new JNIKiwixString("A/main.html"),
@ -77,7 +78,7 @@ throws JNIKiwixException, IOException
FileInputStream fis = new FileInputStream("small.zim");
JNIKiwixReader reader = new JNIKiwixReader(fis.getFD());
assertEquals("Test ZIM file", reader.getTitle());
assertEquals(45, reader.getFileSize()); // The file size is in KiB
assertEquals(3, reader.getFileSize()); // The file size is in KiB
assertEquals("A/main.html", reader.getMainPage());
String s = getTextFileContent("small_zimfile_data/main.html");
byte[] c = reader.getContent(new JNIKiwixString("A/main.html"),
@ -108,7 +109,7 @@ throws JNIKiwixException, IOException
FileInputStream fis = new FileInputStream("small.zim.embedded");
JNIKiwixReader reader = new JNIKiwixReader(fis.getFD(), 8, plainArchive.length());
assertEquals("Test ZIM file", reader.getTitle());
assertEquals(45, reader.getFileSize()); // The file size is in KiB
assertEquals(3, reader.getFileSize()); // The file size is in KiB
assertEquals("A/main.html", reader.getMainPage());
String s = getTextFileContent("small_zimfile_data/main.html");
byte[] c = reader.getContent(new JNIKiwixString("A/main.html"),
@ -154,7 +155,4 @@ public void main(String[] args) {
Library lib = new Library();
lib.getBookCount(true, true);
}
}