diff options
Diffstat (limited to 'adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java')
-rw-r--r-- | adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java | 516 |
1 files changed, 174 insertions, 342 deletions
diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java index 4635b600ce..756c5434cd 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java @@ -74,9 +74,14 @@ public class EventReportWindowCalcDelegateTest { @Before public void setup() { - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS) .when(mFlags).getMeasurementMinEventReportDelayMillis(); + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); + doReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS) + .when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); + doReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS) + .when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); mEventReportWindowCalcDelegate = new EventReportWindowCalcDelegate(mFlags); } @@ -88,6 +93,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -107,6 +113,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -124,6 +131,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -144,6 +152,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -162,6 +171,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -180,6 +190,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -198,6 +209,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -215,6 +227,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -234,6 +247,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -253,6 +267,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -270,6 +285,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -281,6 +297,9 @@ public class EventReportWindowCalcDelegateTest { @Test public void testMaxReportCount() { + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); + Source eventSourceInstallNotAttributed = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) @@ -288,12 +307,7 @@ public class EventReportWindowCalcDelegateTest { .build(); assertEquals( PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallNotAttributed, false)); - assertEquals( - PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallNotAttributed, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(eventSourceInstallNotAttributed)); Source navigationSourceInstallNotAttributed = SourceFixture.getMinimalValidSourceBuilder() @@ -303,46 +317,33 @@ public class EventReportWindowCalcDelegateTest { assertEquals( PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallNotAttributed, false)); - assertEquals( - PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallNotAttributed, false)); + navigationSourceInstallNotAttributed)); Source eventSourceInstallAttributed = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setInstallAttributed(true) + .setInstallCooldownWindow(1L) .build(); assertEquals( PrivacyParams.INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallAttributed, true)); - // Install attribution state does not matter for web destination - assertEquals( - PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallAttributed, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(eventSourceInstallAttributed)); Source navigationSourceInstallAttributed = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setInstallAttributed(true) + .setInstallCooldownWindow(1L) .build(); assertEquals( PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallAttributed, true)); - assertEquals( - PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallAttributed, true)); + navigationSourceInstallAttributed)); } @Test public void getMaxReportCount_configuredConversionsNonInstall_returnsConfiguredCount() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(3).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source nonInstallEventSource = SourceFixture.getMinimalValidSourceBuilder() @@ -352,13 +353,12 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 3, mEventReportWindowCalcDelegate.getMaxReportCount(nonInstallEventSource, false)); + 3, mEventReportWindowCalcDelegate.getMaxReportCount(nonInstallEventSource)); } @Test public void getMaxReportCount_configuredConversionsInstallCase_returnsConfiguredCount() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(2).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source installEventSource = SourceFixture.getMinimalValidSourceBuilder() @@ -368,29 +368,28 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource, true)); + 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource)); } @Test public void getMaxReportCount_configuredConversionsToOneInstallCase_incrementConfiguredCount() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(1).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source installEventSource = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setInstallAttributed(true) + .setInstallCooldownWindow(1L) .build(); // Execution & assertion Assert.assertEquals( - 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource, true)); + 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource)); } @Test public void getMaxReportCount_configuredConversionsToOneInstallCase_noEffectOnCtc() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(2).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source navigationSource = SourceFixture.getMinimalValidSourceBuilder() @@ -400,7 +399,7 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 3, mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource, false)); + 3, mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource)); } @Test @@ -412,48 +411,51 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); // Expected: 1 window at expiry Source eventSource7d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource7d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource7d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource7d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource7d, /* windowIndex= */ 1)); // Expected: 1 window at expiry Source eventSource2d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource2d, /* windowIndex= */ 1)); } @Test @@ -468,21 +470,21 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + minDelayMillis, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + minDelayMillis, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); } @Test public void getReportingTimeForNoising_eventSrcWithConfiguredReportingWindows() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -496,27 +498,27 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 2)); } @Test public void getReportingTimeForNoising_eventSrcInstallAttWithConfiguredReportingWindows() { // Addition another window for install attribution is ignored when configurable windows // are applied. - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -531,28 +533,28 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(expiry) .setEventReportWindow(expiry) .setInstallCooldownWindow(expiry) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 2)); } @Test public void getReportingTimeForNoising_navigationSrcWithConfiguredReportingWindows() { // Addition another window for install attribution is ignored when configurable windows // are applied. - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -566,27 +568,27 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 2)); } @Test public void getReportingTimeForNoising_navigationSrcInstallAttWithConfiguredReportingWindows() { // Addition another window for install attribution is ignored when configurable windows // are applied. - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -601,21 +603,22 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(expiry) .setEventReportWindow(expiry) .setInstallCooldownWindow(expiry) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 2)); } @Test @@ -628,36 +631,38 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.EVENT) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 2)); // Expected: 1 window at 2d(expiry) Source eventSource2d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource2d, /* windowIndex= */ 1)); } @Test @@ -669,56 +674,59 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(20)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(20) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 2)); // Expected: 2 windows at 2d & expiry(7d) Source navigationSource7d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 2)); // Expected: 1 window at 2d(expiry) Source navigationSource2d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource2d, /* windowIndex= */ 1)); } @Test @@ -731,20 +739,21 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.NAVIGATION) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(20)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(20) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 2)); // Expected: 2 windows at 2d & expiry(7d) Source navigationSource7d = @@ -752,20 +761,21 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.NAVIGATION) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 2)); // Expected: 1 window at 2d(expiry) Source navigationSource2d = @@ -773,169 +783,21 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.NAVIGATION) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 1, /* isInstallCase */ false)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcAppDest_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttAppDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - sourceEventTime - + PrivacyParams.INSTALL_ATTR_EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS[0] - + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttAppDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttWebDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.WEB)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttWebDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.WEB)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSourceWebDestination_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.WEB)); - } - - @Test - public void getReportingTime_nullWindowConfigNavigationSourceTriggerInFirstWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(25); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceEventTime - + PrivacyParams.NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS[0] - + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); + navigationSource2d, /* windowIndex= */ 1)); } @Test public void getReportingTime_emptyWindowConfigNavigationSourceTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -944,6 +806,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -955,7 +818,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_emptyWindowConfigEventSrcTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -966,6 +828,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -977,7 +840,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_emptyWindowConfigEventSrcInstallAttTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -988,6 +850,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1002,7 +865,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_emptyWindowConfigNavigationSrcInstallAttTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -1013,6 +875,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1024,70 +887,7 @@ public class EventReportWindowCalcDelegateTest { } @Test - public void getReportingTime_nullWindowConfigNavigationSourceTriggerInSecondWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(25); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceEventTime - + PrivacyParams.NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS[1] - + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigNavigationSecondExpiry() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(2); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceExpiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigNavigationLast_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(1); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(20); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceExpiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test public void getReportingTime_MalformedWindowConfigEventSourceAppDestination_returnsDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1100,6 +900,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1111,7 +912,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttAppDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1124,6 +924,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1138,7 +939,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttAppDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1151,6 +951,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1163,7 +964,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttWebDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1176,6 +976,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1188,7 +989,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttWebDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1201,6 +1001,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1213,7 +1014,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSourceWebDestination() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1226,6 +1026,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1237,7 +1038,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationSourceTriggerInFirstWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1250,6 +1050,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1263,7 +1064,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationSourceTriggerInSecondWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1276,6 +1076,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1289,7 +1090,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationSecondExpiry_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1302,6 +1102,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1313,7 +1114,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationLast_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1326,6 +1126,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1337,7 +1138,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigEventSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1350,6 +1150,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1361,7 +1162,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigEventSourceTriggerIn2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1374,6 +1174,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1386,7 +1187,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigEventSourceTriggerInLastWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1399,6 +1199,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1411,7 +1212,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1424,6 +1224,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1435,7 +1236,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerIn2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1448,6 +1248,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1460,7 +1261,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerInLastWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1473,6 +1273,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1485,7 +1286,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_invalidWindowConfigEventSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(INVALID_1H_1D_2D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1498,6 +1298,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1509,7 +1310,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_invalidWindowConfigNavigationSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1522,6 +1322,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1716,49 +1517,49 @@ public class EventReportWindowCalcDelegateTest { assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - oneWindowNoStart, 0, false)); + oneWindowNoStart, 0)); // InstallCase doesn't affect the report time assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - oneWindowNoStart, 0, true)); + oneWindowNoStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - oneWindowWithStart, 0, false)); + oneWindowWithStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - twoWindowsNoStart, 0, false)); + twoWindowsNoStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(5) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - twoWindowsNoStart, 1, false)); + twoWindowsNoStart, 1)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 0, false)); + fiveWindowsWithStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(5) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 1, false)); + fiveWindowsWithStart, 1)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 2, false)); + fiveWindowsWithStart, 2)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 3, false)); + fiveWindowsWithStart, 3)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(20) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 4, false)); + fiveWindowsWithStart, 4)); } @Test @@ -1866,7 +1667,8 @@ public class EventReportWindowCalcDelegateTest { @Test public void getMaxReportCount_flexLiteApi() { doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); long sourceTime = System.currentTimeMillis(); Source source10Reports = SourceFixture.getMinimalValidSourceBuilder() @@ -1874,10 +1676,20 @@ public class EventReportWindowCalcDelegateTest { .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) .setEventTime(sourceTime) .build(); - assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports, true)); - assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports, false)); + assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports)); + assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports)); - Source sourceDefaultEvent = + Source eventSourceInstallAttributed = + SourceFixture.getMinimalValidSourceBuilder() + .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) + .setEventTime(sourceTime) + .setSourceType(Source.SourceType.EVENT) + .setInstallAttributed(true) + .setInstallCooldownWindow(1L) + .build(); + + Source eventSource = SourceFixture.getMinimalValidSourceBuilder() .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1887,12 +1699,23 @@ public class EventReportWindowCalcDelegateTest { assertEquals( PrivacyParams.INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultEvent, true)); + mEventReportWindowCalcDelegate.getMaxReportCount( + eventSourceInstallAttributed)); assertEquals( PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultEvent, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(eventSource)); + + Source navigationSourceInstallAttributed = + SourceFixture.getMinimalValidSourceBuilder() + .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) + .setEventTime(sourceTime) + .setSourceType(Source.SourceType.NAVIGATION) + .setInstallAttributed(true) + .setInstallCooldownWindow(1L) + .build(); - Source sourceDefaultNavigation = + Source navigationSource = SourceFixture.getMinimalValidSourceBuilder() .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1901,18 +1724,27 @@ public class EventReportWindowCalcDelegateTest { .build(); assertEquals( - PrivacyParams.INSTALL_ATTR_NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultNavigation, true)); + PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, + mEventReportWindowCalcDelegate.getMaxReportCount( + navigationSourceInstallAttributed)); assertEquals( PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultNavigation, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource)); } @Test public void getReportingWindowCountForNoising_flexLiteApi() { doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); long sourceTime = System.currentTimeMillis(); + Source defaultSourceEventInstallAttributed = + SourceFixture.getMinimalValidSourceBuilder() + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) + .setEventTime(sourceTime) + .setSourceType(Source.SourceType.EVENT) + .setInstallAttributed(true) + .setInstallCooldownWindow(1L) + .build(); + Source defaultSourceEvent = SourceFixture.getMinimalValidSourceBuilder() .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1955,57 +1787,57 @@ public class EventReportWindowCalcDelegateTest { assertEquals( 2, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceEvent, true)); + defaultSourceEventInstallAttributed)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceEvent, false)); + defaultSourceEvent)); assertEquals( 3, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceNavigation, true)); + defaultSourceNavigation)); assertEquals( 3, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceNavigation, false)); + defaultSourceNavigation)); // InstallCase doesn't affect the report count assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowNoStart, true)); + oneWindowNoStart)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowNoStart, false)); + oneWindowNoStart)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowWithStart, true)); + oneWindowWithStart)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowWithStart, false)); + oneWindowWithStart)); assertEquals( 2, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - twoWindowsNoStart, true)); + twoWindowsNoStart)); assertEquals( 2, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - twoWindowsNoStart, false)); + twoWindowsNoStart)); assertEquals( 5, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - fiveWindowsWithStart, true)); + fiveWindowsWithStart)); assertEquals( 5, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - fiveWindowsWithStart, false)); + fiveWindowsWithStart)); } @Test |