@ -137,6 +137,46 @@ class TrackingProtectionPolicyFactoryTest {
expected . assertPolicyEquals ( always , checkPrivacy = false )
}
@Test
fun `GIVEN TCP is enabled by nimbus WHEN applyTCPIfNeeded THEN cookie policy should be TCP` ( ) {
val settings : Settings = mockk ( relaxed = true )
every { settings . enabledTotalCookieProtection } returns true
val policies = arrayOf (
TrackingProtectionPolicy . strict ( ) ,
TrackingProtectionPolicy . recommended ( ) ,
TrackingProtectionPolicy . select ( ) ,
)
for ( policy in policies ) {
val adaptedPolicy = policy . applyTCPIfNeeded ( settings )
assertEquals (
CookiePolicy . ACCEPT _FIRST _PARTY _AND _ISOLATE _OTHERS ,
adaptedPolicy . cookiePolicy ,
)
}
}
fun `GIVEN TCP is NOT enabled by nimbus WHEN applyTCPIfNeeded THEN reuse cookie policy` ( ) {
val settings : Settings = mockk ( relaxed = true )
every { settings . enabledTotalCookieProtection } returns false
val policies = arrayOf (
TrackingProtectionPolicy . strict ( ) ,
TrackingProtectionPolicy . recommended ( ) ,
TrackingProtectionPolicy . select ( ) ,
)
for ( policy in policies ) {
val adaptedPolicy = policy . applyTCPIfNeeded ( settings )
assertEquals (
policy . cookiePolicy ,
adaptedPolicy . cookiePolicy ,
)
}
}
@Test
fun `GIVEN custom policy WHEN cookie policy social THEN tracking policy should have cookie policy allow non-trackers` ( ) {
val expected = TrackingProtectionPolicy . select (
@ -586,6 +626,7 @@ class TrackingProtectionPolicyFactoryTest {
useCustom : Boolean = false ,
useTrackingProtection : Boolean = false ,
) : Settings = mockk {
every { enabledTotalCookieProtection } returns false
every { useStrictTrackingProtection } returns useStrict
every { useCustomTrackingProtection } returns useCustom
every { shouldUseTrackingProtection } returns useTrackingProtection