Switch to LegacyMessageQueue (#2054)

This commit is contained in:
Constantin Piber
2026-05-19 23:05:02 +02:00
committed by GitHub
parent c0618fcc5c
commit cc75ad328d
2 changed files with 961 additions and 1388 deletions

View File

@@ -53,4 +53,34 @@ class LooperTest {
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()
}
}