Skip to content

Commit

Permalink
Reactivate Session Replay instrumented test for API 21
Browse files Browse the repository at this point in the history
  • Loading branch information
ambushwork committed Oct 24, 2024
1 parent d13c96a commit f0ca96b
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.InsetDrawable
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.RippleDrawable
import android.graphics.drawable.StateListDrawable
import com.datadog.android.api.InternalLogger

/**
Expand All @@ -31,6 +32,7 @@ open class LegacyDrawableToColorMapper : DrawableToColorMapper {
is LayerDrawable -> resolveLayerDrawable(drawable, internalLogger)
is InsetDrawable -> resolveInsetDrawable(drawable, internalLogger)
is GradientDrawable -> resolveGradientDrawable(drawable, internalLogger)
is StateListDrawable -> resolveStateListDrawable(drawable, internalLogger)
else -> {
val drawableType = drawable.javaClass.canonicalName ?: drawable.javaClass.name
internalLogger.log(
Expand All @@ -50,6 +52,13 @@ open class LegacyDrawableToColorMapper : DrawableToColorMapper {
return result
}

protected open fun resolveStateListDrawable(
drawable: StateListDrawable,
internalLogger: InternalLogger
): Int? {
return null
}

/**
* Resolves the color from a [ColorDrawable].
* @param drawable the color drawable
Expand Down Expand Up @@ -121,7 +130,9 @@ open class LegacyDrawableToColorMapper : DrawableToColorMapper {

if (fillPaint == null) return null
val filterColor = try {
mColorField?.get(fillPaint.colorFilter) as? Int ?: fillPaint.color
fillPaint.colorFilter?.let {
mColorField?.get(it) as? Int
} ?: fillPaint.color
} catch (e: IllegalArgumentException) {
internalLogger.log(
InternalLogger.Level.WARN,
Expand Down Expand Up @@ -155,7 +166,7 @@ open class LegacyDrawableToColorMapper : DrawableToColorMapper {
* @return the color to map to or null if not applicable
*/
protected open fun resolveInsetDrawable(drawable: InsetDrawable, internalLogger: InternalLogger): Int? {
return null
return drawable.drawable?.let { mapDrawableToColor(it, internalLogger) }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.rules.SessionReplayTestRule
import org.junit.Rule
Expand All @@ -22,9 +20,7 @@ internal class ConsentGrantedSrTest : BaseSessionReplayTest<SessionReplayPlaygro
keepRequests = true
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.chekboxandradio

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayRadioCheckboxFieldsActivity
Expand All @@ -28,9 +26,7 @@ internal class SrCheckBoxAndRadioFieldsAllowTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.ALLOW)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.chekboxandradio

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayRadioCheckboxFieldsActivity
Expand All @@ -28,9 +26,7 @@ internal class SrCheckBoxAndRadioFieldsMaskTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.chekboxandradio

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayRadioCheckboxFieldsActivity
Expand All @@ -28,9 +26,7 @@ internal class SrCheckBoxAndRadioFieldsMaskUserInputTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK_USER_INPUT)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.imagebuttons

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayImageButtonsActivity
Expand All @@ -28,9 +26,7 @@ internal class SrImageButtonsAllowTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.ALLOW)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.imagebuttons

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayImageButtonsActivity
Expand All @@ -28,9 +26,7 @@ internal class SrImageButtonsMaskTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.imagebuttons

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayImageButtonsActivity
Expand All @@ -28,9 +26,7 @@ internal class SrImageButtonsMaskUserInputTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK_USER_INPUT)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.images

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayImagesActivity
Expand All @@ -28,9 +26,7 @@ internal class SrImagesAllowTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.ALLOW)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.images

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayImagesActivity
Expand All @@ -28,9 +26,7 @@ internal class SrImagesMaskTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.images

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayImagesActivity
Expand All @@ -28,9 +26,7 @@ internal class SrImagesMaskUserInputTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK_USER_INPUT)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.sensitivefields

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplaySensitiveFieldsActivity
Expand All @@ -27,9 +25,7 @@ internal class SrSensitiveFieldsAllowTest : BaseSessionReplayTest<SessionReplayS
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.ALLOW)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.sensitivefields

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplaySensitiveFieldsActivity
Expand All @@ -27,9 +25,7 @@ internal class SrSensitiveFieldsMaskTest : BaseSessionReplayTest<SessionReplaySe
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.sensitivefields

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplaySensitiveFieldsActivity
Expand All @@ -27,9 +25,7 @@ internal class SrSensitiveFieldsMaskUserInputTest : BaseSessionReplayTest<Sessio
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK_USER_INPUT)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ internal class SrTextFieldsAllowTest : BaseSessionReplayTest<SessionReplayTextFi
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.ALLOW)
)

// TODO RUM-6839: Fix test on API 21
// TODO RUM-6839: Fix test on API 21, the test failure is caused by different drawable
// on the text background among API versions. the background wireframes on higher version are
// images, on lower version are shapes.
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.textfields

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayTextFieldsActivity
Expand All @@ -27,9 +25,7 @@ internal class SrTextFieldsMaskTest : BaseSessionReplayTest<SessionReplayTextFie
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.textfields

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayTextFieldsActivity
Expand All @@ -27,9 +25,7 @@ internal class SrTextFieldsMaskUserInputTest : BaseSessionReplayTest<SessionRepl
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK_USER_INPUT)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package com.datadog.android.sdk.integration.sessionreplay.textfields

import android.os.Build
import androidx.test.filters.SdkSuppress
import com.datadog.android.privacy.TrackingConsent
import com.datadog.android.sdk.integration.sessionreplay.BaseSessionReplayTest
import com.datadog.android.sdk.integration.sessionreplay.SessionReplayTextFieldsWithInputActivity
Expand All @@ -28,9 +26,7 @@ internal class SrTextFieldsWithInputMaskUserInputTest :
intentExtras = mapOf(SR_PRIVACY_LEVEL to SessionReplayPrivacy.MASK_USER_INPUT)
)

// TODO RUM-6839: Fix test on API 21
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.P)
fun assessRecordedScreenPayload() {
runInstrumentationScenario()
assessSrPayload(EXPECTED_PAYLOAD_FILE_NAME, rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import fr.xgouchet.elmyr.junit5.ForgeConfiguration
import fr.xgouchet.elmyr.junit5.ForgeExtension
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.Extensions
import org.mockito.Mock
Expand Down Expand Up @@ -65,7 +64,6 @@ class DatadogRumErrorConsumerTest {
}
}

@Test
fun `M send an error event W intercepting an exception`() {
// WHEN
testedConsumer.accept(fakeException)
Expand Down

0 comments on commit f0ca96b

Please sign in to comment.