Skip to content

Commit

Permalink
Update unit tests for viewmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongpm committed Feb 17, 2019
1 parent 46d49c4 commit 49cab7a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ class VideoPlayerViewModel @Inject constructor() : BaseViewModel() {
}

fun pressPrev() {

}

fun pressPauseOrPlay() {}
fun pressPauseOrPlay() {
}

fun pressNext() {}
fun pressNext() {
}

fun getVolume(): Float {
val amount = if (isVolumeOn) 100 else 0
Expand Down
15 changes: 15 additions & 0 deletions app/src/test/java/com/youtubedl/ui/main/home/MainViewModelTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package com.youtubedl.ui.main.home

import org.junit.Before
import org.junit.Test

/**
* Created by cuongpm on 1/14/19.
*/

class MainViewModelTest {

private lateinit var mainViewModel: MainViewModel

@Before
fun setup() {
mainViewModel = MainViewModel()
}

@Test
fun `test MainViewModel here`() {
mainViewModel.start()
mainViewModel.stop()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
package com.youtubedl.ui.main.player

import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test

/**
* Created by cuongpm on 1/29/19.
*/
class VideoPlayerViewModelTest
class VideoPlayerViewModelTest {

private lateinit var videoPlayerViewModel: VideoPlayerViewModel

@Before
fun setup() {
videoPlayerViewModel = VideoPlayerViewModel()
}

@Test
fun `test video volume on`() {
assertEquals(1.0f, videoPlayerViewModel.getVolume())
}

@Test
fun `test video volume off`() {
videoPlayerViewModel.isVolumeOn = false
assertEquals(0.0f, videoPlayerViewModel.getVolume())
}
}

0 comments on commit 49cab7a

Please sign in to comment.