fix tests
This commit is contained in:
parent
2bfe8c272d
commit
d8880b36bf
2 changed files with 11 additions and 1 deletions
|
@ -99,7 +99,7 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
) : CommandQueue {
|
) : CommandQueue {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
internal var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||||
|
|
||||||
private val queue = LinkedList<Command>()
|
private val queue = LinkedList<Command>()
|
||||||
@Volatile private var thread: QueueThread? = null
|
@Volatile private var thread: QueueThread? = null
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.implementation.queue
|
package info.nightscout.implementation.queue
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Handler
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
@ -42,7 +43,9 @@ import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.anyLong
|
import org.mockito.Mockito.anyLong
|
||||||
|
import org.mockito.Mockito.mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.mockito.invocation.InvocationOnMock
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
class CommandQueueImplementationTest : TestBaseWithProfile() {
|
class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
|
@ -162,6 +165,13 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
dateUtil, repository,
|
dateUtil, repository,
|
||||||
fabricPrivacy, config, androidPermission, activityNames
|
fabricPrivacy, config, androidPermission, activityNames
|
||||||
)
|
)
|
||||||
|
val handler = mock(Handler::class.java)
|
||||||
|
`when`(handler.post(anyObject())).thenAnswer { invocation: InvocationOnMock ->
|
||||||
|
(invocation.arguments[0] as Runnable).run()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
commandQueue.handler = handler
|
||||||
|
|
||||||
// start with empty queue
|
// start with empty queue
|
||||||
Assert.assertEquals(0, commandQueue.size())
|
Assert.assertEquals(0, commandQueue.size())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue