-
-
Notifications
You must be signed in to change notification settings - Fork 497
Adapt latest java-libkiwix wrapper #3217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d62d439
64f2620
3e59e97
a1ee8be
161337a
384bacc
e69499f
75fab06
bbd23d1
6e0336e
02a6d0f
e363889
46d4aeb
d188a82
f7517a2
632bb4a
3e40c09
69982e9
adea940
3edfd88
dd1ae68
376776c
ac78a67
f29be04
ed237a4
51ef8af
4f2b54e
609e9e2
f1889ee
ad81bbd
644521c
fff9196
1281c0c
221f84b
ec007e4
9ff91ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,17 +19,20 @@ | |
| package org.kiwix.kiwixmobile.mimetype | ||
|
|
||
| import androidx.core.content.edit | ||
| import androidx.lifecycle.Lifecycle | ||
| import androidx.preference.PreferenceManager | ||
| import androidx.test.core.app.ActivityScenario | ||
| import androidx.test.platform.app.InstrumentationRegistry | ||
| import androidx.test.uiautomator.UiDevice | ||
| import org.junit.Assert | ||
| import org.junit.Before | ||
| import org.junit.Test | ||
| import org.kiwix.kiwixlib.JNIKiwixReader | ||
| import org.kiwix.libzim.Archive | ||
| import org.kiwix.kiwixmobile.BaseActivityTest | ||
| import org.kiwix.kiwixmobile.core.NightModeConfig | ||
| import org.kiwix.kiwixmobile.core.reader.ZimFileReader | ||
| import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil | ||
| import org.kiwix.kiwixmobile.main.KiwixMainActivity | ||
| import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs | ||
| import org.kiwix.kiwixmobile.testutils.TestUtils.isSystemUINotRespondingDialogVisible | ||
| import java.io.File | ||
|
|
@@ -50,6 +53,9 @@ class MimeTypeTest : BaseActivityTest() { | |
| putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) | ||
| putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) | ||
| } | ||
| activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { | ||
| moveToState(Lifecycle.State.RESUMED) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -70,23 +76,32 @@ class MimeTypeTest : BaseActivityTest() { | |
| } | ||
| val zimFileReader = ZimFileReader( | ||
| zimFile, | ||
| JNIKiwixReader(zimFile.canonicalPath), | ||
| Archive(zimFile.canonicalPath), | ||
|
Comment on lines
-73
to
+79
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gouri-panda Here |
||
| NightModeConfig(SharedPreferenceUtil(context), context) | ||
| ) | ||
| zimFileReader.getRandomArticleUrl()?.let { | ||
| val mimeType = zimFileReader.readContentAndMimeType(it) | ||
| if (mimeType.contains("^([^ ]+).*$") || mimeType.contains(";")) { | ||
| val mimeType = zimFileReader.getMimeTypeFromUrl(it) | ||
| if (mimeType?.contains("^([^ ]+).*$") == true || mimeType?.contains(";") == true) { | ||
| Assert.fail( | ||
| "Unable to get mime type from zim file. File = " + | ||
| " $zimFile and url of article = $it" | ||
| ) | ||
| } | ||
| }.also { | ||
| zimFileReader.dispose() | ||
| } ?: kotlin.run { | ||
| Assert.fail("Unable to get article from zim file $zimFile") | ||
| }.also { | ||
| zimFileReader.dispose() | ||
| } | ||
| // test mimetypes for some actual url | ||
| Assert.assertEquals( | ||
| "text/html", | ||
| zimFileReader.getMimeTypeFromUrl("https://kiwix.app/A/index.html") | ||
| ) | ||
| Assert.assertEquals( | ||
| "text/css", | ||
| zimFileReader.getMimeTypeFromUrl("https://kiwix.app/-/assets/style1.css") | ||
| ) | ||
| // test mimetype for invalid url | ||
| Assert.assertEquals(null, zimFileReader.getMimeTypeFromUrl("https://kiwix.app/A/test.html")) | ||
| // dispose the ZimFileReader | ||
| zimFileReader.dispose() | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.