From b8b9c61400165d21865ed579519fd672fbea19ed Mon Sep 17 00:00:00 2001 From: mau Date: Wed, 24 Jul 2024 14:52:35 +0900 Subject: [PATCH] ut --- .../runtime/InAppMessagingSpec.kt | 116 +++++++++--------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/InAppMessagingSpec.kt b/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/InAppMessagingSpec.kt index 2cc9f3fb..5d520831 100644 --- a/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/InAppMessagingSpec.kt +++ b/inappmessaging/src/test/java/com/rakuten/tech/mobile/inappmessaging/runtime/InAppMessagingSpec.kt @@ -678,62 +678,62 @@ class InAppMessagingPrimerTrackerSpec : InAppMessagingSpec() { verify(mockMgr).sendPrimerEvent(eq(1)) } -// @Test -// fun `should call primer manager with denied result`() { -// val inApp = initializeMockInstance(primerManager = mockMgr) -// -// inApp.trackPushPrimer( -// arrayOf(Manifest.permission.POST_NOTIFICATIONS), intArrayOf(PackageManager.PERMISSION_DENIED), -// ) -// -// verify(mockMgr).sendPrimerEvent(eq(0), any()) -// } -// -// @Test -// fun `should not call primer manager other permission`() { -// val inApp = initializeMockInstance(primerManager = mockMgr) -// -// inApp.trackPushPrimer( -// arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), intArrayOf(PackageManager.PERMISSION_DENIED), -// ) -// -// verify(mockMgr, never()).sendPrimerEvent(any(), any()) -// } -// -// @Test -// fun `should not call primer manager other permission and result higher size`() { -// val inApp = initializeMockInstance(primerManager = mockMgr) -// -// inApp.trackPushPrimer( -// arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), -// intArrayOf(PackageManager.PERMISSION_DENIED, PackageManager.PERMISSION_GRANTED), -// ) -// -// verify(mockMgr, never()).sendPrimerEvent(any(), any()) -// } -// -// @Test -// fun `should not call primer manager other permission and permission higher size`() { -// val inApp = initializeMockInstance(primerManager = mockMgr) -// -// inApp.trackPushPrimer( -// arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION), -// intArrayOf(PackageManager.PERMISSION_DENIED), -// ) -// -// verify(mockMgr, never()).sendPrimerEvent(any(), any()) -// } -// -// @Test -// @Config(sdk = [Build.VERSION_CODES.S]) -// fun `should not call primer manager if lower than tiramisu`() { -// val inApp = initializeMockInstance(primerManager = mockMgr) -// -// inApp.trackPushPrimer( -// arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), -// intArrayOf(PackageManager.PERMISSION_DENIED, PackageManager.PERMISSION_GRANTED), -// ) -// -// verify(mockMgr, never()).sendPrimerEvent(any(), any()) -// } + @Test + fun `should call primer manager with denied result`() { + val inApp = initializeMockInstance(primerManager = mockMgr) + + inApp.trackPushPrimer( + arrayOf(Manifest.permission.POST_NOTIFICATIONS), intArrayOf(PackageManager.PERMISSION_DENIED), + ) + + verify(mockMgr).sendPrimerEvent(eq(0)) + } + + @Test + fun `should not call primer manager other permission`() { + val inApp = initializeMockInstance(primerManager = mockMgr) + + inApp.trackPushPrimer( + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), intArrayOf(PackageManager.PERMISSION_DENIED), + ) + + verify(mockMgr, never()).sendPrimerEvent(any()) + } + + @Test + fun `should not call primer manager other permission and result higher size`() { + val inApp = initializeMockInstance(primerManager = mockMgr) + + inApp.trackPushPrimer( + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), + intArrayOf(PackageManager.PERMISSION_DENIED, PackageManager.PERMISSION_GRANTED), + ) + + verify(mockMgr, never()).sendPrimerEvent(any()) + } + + @Test + fun `should not call primer manager other permission and permission higher size`() { + val inApp = initializeMockInstance(primerManager = mockMgr) + + inApp.trackPushPrimer( + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION), + intArrayOf(PackageManager.PERMISSION_DENIED), + ) + + verify(mockMgr, never()).sendPrimerEvent(any()) + } + + @Test + @Config(sdk = [Build.VERSION_CODES.S]) + fun `should not call primer manager if lower than tiramisu`() { + val inApp = initializeMockInstance(primerManager = mockMgr) + + inApp.trackPushPrimer( + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), + intArrayOf(PackageManager.PERMISSION_DENIED, PackageManager.PERMISSION_GRANTED), + ) + + verify(mockMgr, never()).sendPrimerEvent(any()) + } }