Skip to content

Commit

Permalink
Add back tests
Browse files Browse the repository at this point in the history
  • Loading branch information
linsang21 committed Oct 31, 2024
1 parent 5d9b81c commit 279bf0e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 29 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
distribution: 'corretto'
java-version: '11'

# Execute unit tests
- name: Unit Test with Android Emulator Runner
Expand All @@ -99,4 +99,8 @@ jobs:

# Upload code coverage report to codecov to process data
- name: Upload coverage to Codecov
uses: codecov/[email protected]
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package com.amazonaws.services.chime.sdk.meetings.audiovideo

import android.util.Log
import com.amazonaws.services.chime.sdk.meetings.audiovideo.audio.AudioDeviceCapabilities
import com.amazonaws.services.chime.sdk.meetings.audiovideo.audio.AudioMode
import com.amazonaws.services.chime.sdk.meetings.audiovideo.audio.AudioRecordingPresetOverride
Expand All @@ -19,7 +18,6 @@ import com.amazonaws.services.chime.sdk.meetings.audiovideo.video.VideoSubscript
import com.amazonaws.services.chime.sdk.meetings.internal.audio.AudioClientController
import com.amazonaws.services.chime.sdk.meetings.internal.audio.AudioClientObserver
import com.amazonaws.services.chime.sdk.meetings.internal.metric.ClientMetricsCollector
import com.amazonaws.services.chime.sdk.meetings.internal.utils.AppInfoUtil
import com.amazonaws.services.chime.sdk.meetings.internal.video.VideoClientController
import com.amazonaws.services.chime.sdk.meetings.internal.video.VideoClientObserver
import com.amazonaws.services.chime.sdk.meetings.session.MeetingFeatures
Expand All @@ -31,14 +29,11 @@ import com.amazonaws.services.chime.sdk.meetings.session.MeetingSessionURLs
import com.amazonaws.services.chime.sdk.meetings.session.defaultUrlRewriter
import com.amazonaws.services.chime.sdk.meetings.utils.logger.ConsoleLogger
import com.amazonaws.services.chime.sdk.meetings.utils.logger.LogLevel
import com.xodee.client.video.VideoClient
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.just
import io.mockk.mockkConstructor
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.runs
import io.mockk.slot
import io.mockk.verify
Expand Down Expand Up @@ -113,15 +108,9 @@ class DefaultAudioVideoControllerTest {
@MockK
private lateinit var mockPrimaryMeetingPromotionObserver: PrimaryMeetingPromotionObserver

@MockK
private lateinit var mockTimer: Timer

@MockK
private lateinit var mockVideoSource: VideoSource

@MockK
private lateinit var mockVideoClient: VideoClient

private lateinit var audioVideoController: DefaultAudioVideoController
private lateinit var audioVideoControllerNone: DefaultAudioVideoController
private lateinit var audioVideoControllerHigh: DefaultAudioVideoController
Expand All @@ -132,12 +121,6 @@ class DefaultAudioVideoControllerTest {
@ExperimentalCoroutinesApi
@Before
fun setup() {
mockkStatic(System::class, Log::class, VideoClient::class)
every { Log.d(any(), any()) } returns 0
every { System.loadLibrary(any()) } just runs
every { VideoClient.javaInitializeGlobals(any()) } returns true
mockkObject(AppInfoUtil)
every { AppInfoUtil.initializeVideoClientAppDetailedInfo(any()) } just runs
Dispatchers.setMain(testDispatcher)
MockKAnnotations.init(this, relaxUnitFun = true)
val logger = ConsoleLogger(LogLevel.INFO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.media.AudioDeviceInfo
import android.media.AudioManager
import android.media.AudioRecord
import android.media.AudioTrack
import android.util.Log
import com.amazonaws.services.chime.sdk.meetings.TestConstant
import com.amazonaws.services.chime.sdk.meetings.analytics.EventAnalyticsController
import com.amazonaws.services.chime.sdk.meetings.analytics.EventAttributeName
Expand Down Expand Up @@ -89,12 +88,6 @@ class DefaultAudioClientControllerTest {

@Before
fun setup() {
// It appears that mocking Log.d needs to happen before MockKAnnotations.init, or else
// test will complain that Log.d is not mocked
mockkStatic(System::class, Log::class)
every { Log.d(any(), any()) } returns 0
every { System.loadLibrary(any()) } just runs

MockKAnnotations.init(this, relaxUnitFun = true)

setupAudioManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package com.amazonaws.services.chime.sdk.meetings.internal.utils

import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.verify
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
Expand Down Expand Up @@ -35,7 +34,6 @@ class ObserverUtilsTest {

@Before
fun setUp() {
mockkStatic(System::class)
Dispatchers.setMain(testDispatcher)
mockObserver = mockk(relaxed = true)
mockObservers.add(mockObserver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import io.mockk.just
import io.mockk.mockkStatic
import io.mockk.runs
import io.mockk.slot
import io.mockk.unmockkAll
import io.mockk.verify
import java.nio.ByteBuffer
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -153,6 +154,7 @@ class DefaultVideoClientObserverTest {

@After
fun tearDown() {
unmockkAll()
Dispatchers.resetMain()
testDispatcher.cleanupTestCoroutines()
}
Expand Down

0 comments on commit 279bf0e

Please sign in to comment.