File tree Expand file tree Collapse file tree
main/java/com/debiandroid/desktop/vnc
test/java/com/debiandroid/desktop Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,7 +110,8 @@ class RfbProtocol(
110110 }
111111 }
112112
113- private fun reverseBits (b : Byte ): Byte {
113+ companion object {
114+ internal fun reverseBits (b : Byte ): Byte {
114115 var x = b.toInt() and 0xFF
115116 x = (x and 0x55 shl 1 ) or (x and 0xAA shr 1 )
116117 x = (x and 0x33 shl 2 ) or (x and 0xCC shr 2 )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import androidx.test.core.app.ApplicationProvider
55import kotlinx.coroutines.flow.first
66import kotlinx.coroutines.runBlocking
77import org.junit.Assert.*
8+ import org.junit.Before
89import org.junit.Test
910import org.junit.runner.RunWith
1011import org.robolectric.RobolectricTestRunner
@@ -13,7 +14,12 @@ import org.robolectric.RobolectricTestRunner
1314class SessionManagerTest {
1415
1516 private val context = ApplicationProvider .getApplicationContext<Context >()
16- private val sessionManager = SessionManager (context)
17+ private lateinit var sessionManager: SessionManager
18+
19+ @Before
20+ fun setUp () {
21+ sessionManager = SessionManager (context)
22+ }
1723
1824 @Test
1925 fun `default setup complete is false` () = runBlocking {
Original file line number Diff line number Diff line change @@ -7,19 +7,11 @@ class RfbProtocolTest {
77
88 @Test
99 fun `reverseBits swaps bit order` () {
10- val protocol = RfbProtocol (
11- java.net.Socket (),
12- " test"
13- )
14-
15- val method = RfbProtocol ::class .java.getDeclaredMethod(" reverseBits" , Byte ::class .java)
16- method.isAccessible = true
17-
18- assertEquals(0x00 .toByte(), method.invoke(protocol, 0x00 .toByte()))
19- assertEquals(0x80 .toByte(), method.invoke(protocol, 0x01 .toByte()))
20- assertEquals(0x01 .toByte(), method.invoke(protocol, 0x80 .toByte()))
21- assertEquals(0xFF .toByte(), method.invoke(protocol, 0xFF .toByte()))
22- assertEquals(0x0F .toByte(), method.invoke(protocol, 0xF0 .toByte()))
10+ assertEquals(0x00 .toByte(), RfbProtocol .reverseBits(0x00 .toByte()))
11+ assertEquals(0x80 .toByte(), RfbProtocol .reverseBits(0x01 .toByte()))
12+ assertEquals(0x01 .toByte(), RfbProtocol .reverseBits(0x80 .toByte()))
13+ assertEquals(0xFF .toByte(), RfbProtocol .reverseBits(0xFF .toByte()))
14+ assertEquals(0x0F .toByte(), RfbProtocol .reverseBits(0xF0 .toByte()))
2315 }
2416
2517 @Test
You can’t perform that action at this time.
0 commit comments