Skip to content

Commit

Permalink
fix(capture-sdk): Fix tests failing for not initializing the UserAnal…
Browse files Browse the repository at this point in the history
…ytics

PP-450
  • Loading branch information
abolfazlimahdi committed Jun 17, 2024
1 parent e61c1bc commit 09221de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.gini.android.capture.analysis

import android.content.Context
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentFactory
Expand All @@ -19,6 +18,7 @@ import net.gini.android.capture.document.ImageDocument
import net.gini.android.capture.tracking.AnalysisScreenEvent
import net.gini.android.capture.tracking.Event
import net.gini.android.capture.tracking.EventTracker
import net.gini.android.capture.tracking.useranalytics.UserAnalytics
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -38,6 +38,7 @@ class AnalysisFragmentTest {
GiniCapture.newInstance(InstrumentationRegistry.getInstrumentation().context)
.setEventTracker(eventTracker).build()
GiniCapture.getInstance().internal().imageMultiPageDocumentMemoryStore.setMultiPageDocument(mock())
UserAnalytics.initialize(InstrumentationRegistry.getInstrumentation().context)

val bundle = Bundle().apply {
putParcelable("GC_ARGS_DOCUMENT", mock<ImageDocument>().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import androidx.lifecycle.Lifecycle
import androidx.navigation.NavController
import androidx.navigation.Navigation
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.spy
import com.nhaarman.mockitokotlin2.verify
import net.gini.android.capture.GiniCapture
import net.gini.android.capture.tracking.CameraScreenEvent
import net.gini.android.capture.tracking.Event
import net.gini.android.capture.tracking.EventTracker
import net.gini.android.capture.tracking.useranalytics.UserAnalytics
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -31,6 +33,7 @@ class CameraFragmentTest {
// Given
val eventTracker = spy<EventTracker>()
GiniCapture.Builder().setEventTracker(eventTracker).build()
UserAnalytics.initialize(InstrumentationRegistry.getInstrumentation().context)

val navController = mock<NavController>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.fragment.app.testing.FragmentScenario
import androidx.lifecycle.Lifecycle
import androidx.navigation.Navigation
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.google.common.truth.Truth
import com.nhaarman.mockitokotlin2.*
import jersey.repackaged.jsr166e.CompletableFuture
Expand All @@ -17,6 +18,7 @@ import net.gini.android.capture.tracking.Event
import net.gini.android.capture.tracking.EventTracker
import net.gini.android.capture.tracking.ReviewScreenEvent
import net.gini.android.capture.tracking.ReviewScreenEvent.UPLOAD_ERROR_DETAILS_MAP_KEY.*
import net.gini.android.capture.tracking.useranalytics.UserAnalytics
import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -45,6 +47,7 @@ class MultipageReviewFragmentTest {
val eventTracker = spy<EventTracker>()
GiniCapture.Builder().setEventTracker(eventTracker).build()
GiniCapture.getInstance().internal().imageMultiPageDocumentMemoryStore.setMultiPageDocument(mock())
UserAnalytics.initialize(InstrumentationRegistry.getInstrumentation().context)

FragmentScenario.launchInContainer(fragmentClass = MultiPageReviewFragment::class.java).use { scenario ->
scenario.moveToState(Lifecycle.State.STARTED)
Expand Down Expand Up @@ -77,7 +80,7 @@ class MultipageReviewFragmentTest {
val eventTracker = spy<EventTracker>()
GiniCapture.Builder().setEventTracker(eventTracker).build()
GiniCapture.getInstance().internal().imageMultiPageDocumentMemoryStore.setMultiPageDocument(mock())

UserAnalytics.initialize(InstrumentationRegistry.getInstrumentation().context)
FragmentScenario.launchInContainer(fragmentClass = MultiPageReviewFragment::class.java).use { scenario ->
scenario.moveToState(Lifecycle.State.STARTED)

Expand Down

0 comments on commit 09221de

Please sign in to comment.