mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
* Switch to JCEF This is a full implementation, but it does not yet include downloading CEF as KCEF did * Download CEF automatically * Handle and propagate CEF init errors * Lint * Simplify jcef version extract * CEF: Download async * Copy StartupAsync to support handling errors Startup failures are simply swallowed, since they are recorded in the future, but there is no way to get that exception * CEF: Search for release file recursively On Mac, the file is buried a bit deeper than first level, like on Win and Linux * KcefWebViewProvider: Suppress deprecation We need to send those events, even if they are deprecated * Update readme * Optimize imports * Suggestion Co-authored-by: Mitchell Syer <syer10@users.noreply.github.com> * Refactor: stick to `Path` instead of `File` Also extracts the downloading of CEF to a separate method * Lint * Support disabling CEF Co-authored-by: Kolby Moroz Liebl <31669092+kolbyml@users.noreply.github.com> * Move JBR version to build constants Allows embedding into Manifest so docker can later extract the proper version * Create test to verify JCEF dependency matches downloaded JBR * Update server/src/main/kotlin/suwayomi/tachidesk/server/util/CEFManager.kt Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com> * Fix compile, apply Path suggestions * Download progress * Lint * Fix exception on non-posix * Delete recursively Others can be non-empty * Support disabling CEF at will Not really functional, but nice * Fix test * Exclude masstest unless explicitly requested * PR-CI: Run tests * Add Changelog entry --------- Co-authored-by: Mitchell Syer <syer10@users.noreply.github.com> Co-authored-by: Kolby Moroz Liebl <31669092+kolbyml@users.noreply.github.com>
87 lines
2.2 KiB
Kotlin
87 lines
2.2 KiB
Kotlin
package suwayomi.tachidesk
|
|
|
|
import android.os.Handler
|
|
import android.os.Looper
|
|
import android.os.Message
|
|
import java.util.concurrent.CountDownLatch
|
|
import java.util.concurrent.TimeUnit
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertEquals
|
|
import kotlin.test.assertNotEquals
|
|
import kotlin.test.assertTrue
|
|
import kotlin.text.StringBuilder
|
|
|
|
class LooperThread : Thread() {
|
|
var mHandler: Handler? = null
|
|
val latch = CountDownLatch(1)
|
|
|
|
override fun run() {
|
|
Looper.prepare()
|
|
mHandler = Handler(Looper.myLooper()!!)
|
|
latch.countDown()
|
|
Looper.loop()
|
|
}
|
|
}
|
|
|
|
class LooperTest {
|
|
@Test
|
|
fun multiplePostWork() {
|
|
val thread = LooperThread()
|
|
thread.start()
|
|
val sb = StringBuilder()
|
|
val latch = CountDownLatch(1)
|
|
assertTrue(thread.latch.await(5, TimeUnit.SECONDS))
|
|
|
|
thread.mHandler!!.post {
|
|
Thread.sleep(100)
|
|
sb.append("a_b_c")
|
|
}
|
|
thread.mHandler!!.post {
|
|
Thread.sleep(100)
|
|
sb.append("_d_e_f")
|
|
}
|
|
thread.mHandler!!.post {
|
|
Thread.sleep(100)
|
|
sb.append("_g_h_i")
|
|
latch.countDown()
|
|
}
|
|
|
|
assertNotEquals("a_b_c_d_e_f_g_h_i", sb.toString())
|
|
assertTrue(latch.await(5, TimeUnit.SECONDS))
|
|
|
|
assertEquals("a_b_c_d_e_f_g_h_i", sb.toString())
|
|
thread.mHandler!!.looper.quit()
|
|
// thread.join()
|
|
}
|
|
|
|
@Test
|
|
fun loopTest() {
|
|
val thread = LooperThread()
|
|
thread.start()
|
|
val sb = StringBuilder()
|
|
val expected = StringBuilder()
|
|
val latch = CountDownLatch(1)
|
|
assertTrue(thread.latch.await(5, TimeUnit.SECONDS))
|
|
val n = 100
|
|
|
|
for (i in 0 until n) {
|
|
thread.mHandler!!.post {
|
|
Thread.sleep(10)
|
|
sb.append("$i")
|
|
}
|
|
expected.append("$i")
|
|
}
|
|
|
|
thread.mHandler!!.post {
|
|
latch.countDown()
|
|
}
|
|
|
|
assertNotEquals(expected.toString(), sb.toString())
|
|
assertTrue(latch.await(5, TimeUnit.SECONDS), "only got to $sb")
|
|
|
|
assertEquals(expected.toString(), sb.toString())
|
|
thread.mHandler!!.looper.quit()
|
|
// thread.join()
|
|
}
|
|
}
|