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 | 573 |
1 files changed, 231 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 713ce8e982..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 @@ -61,6 +61,9 @@ public class EventReportWindowCalcDelegateTest { private static final String EVENT_REPORT_WINDOWS_2_WINDOWS_NO_START = "{'end_times': [172800000, 432000000]}"; + private static final String EVENT_REPORT_WINDOWS_2_WINDOWS_WITH_START = + "{ 'start_time': 3600000, 'end_times': [86400000, 1728000000]}"; + private static final String EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START = "{'start_time': 86400000, 'end_times': [172800000, 432000000, 604800000, 864000000," + " 1728000000]}"; @@ -71,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); } @@ -85,6 +93,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -104,6 +113,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -121,6 +131,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -141,6 +152,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -159,6 +171,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -177,6 +190,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -195,6 +209,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -212,6 +227,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -231,6 +247,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -250,6 +267,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -267,6 +285,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -278,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) @@ -285,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() @@ -300,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() @@ -349,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() @@ -365,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() @@ -397,7 +399,7 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 3, mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource, false)); + 3, mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource)); } @Test @@ -409,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 @@ -465,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(); @@ -493,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(); @@ -528,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(); @@ -563,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(); @@ -598,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 @@ -625,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 @@ -666,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 @@ -728,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 = @@ -749,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 = @@ -770,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(); @@ -941,6 +806,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -952,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(); @@ -963,6 +828,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -974,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(); @@ -985,6 +850,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -999,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(); @@ -1010,6 +875,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1021,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(); @@ -1097,6 +900,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1108,7 +912,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttAppDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1121,6 +924,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1135,7 +939,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttAppDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1148,6 +951,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1160,7 +964,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttWebDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1173,6 +976,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1185,7 +989,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttWebDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1198,6 +1001,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1210,7 +1014,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSourceWebDestination() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1223,6 +1026,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1234,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(); @@ -1247,6 +1050,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1260,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(); @@ -1273,6 +1076,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1286,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(); @@ -1299,6 +1102,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1310,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(); @@ -1323,6 +1126,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1334,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(); @@ -1347,6 +1150,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1358,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(); @@ -1371,6 +1174,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1383,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(); @@ -1396,6 +1199,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1408,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(); @@ -1421,6 +1224,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1432,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(); @@ -1445,6 +1248,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1457,7 +1261,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerInLastWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1470,6 +1273,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1482,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(); @@ -1495,6 +1298,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1506,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(); @@ -1519,6 +1322,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1713,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 @@ -1863,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() @@ -1871,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)) @@ -1884,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 sourceDefaultNavigation = + 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 navigationSource = SourceFixture.getMinimalValidSourceBuilder() .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1898,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)) @@ -1952,56 +1787,110 @@ 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 + public void fallsWithinWindow_windowNotStarted() { + doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); + long sourceTime = System.currentTimeMillis(); + long triggerTime = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1) - 1; + Source source = + SourceFixture.getMinimalValidSourceBuilder() + .setSourceType(Source.SourceType.EVENT) + .setEventTime(sourceTime) + .setEventReportWindows(EVENT_REPORT_WINDOWS_2_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(25)) + .build(); + assertEquals( + EventReportWindowCalcDelegate.MomentPlacement.BEFORE, + mEventReportWindowCalcDelegate.fallsWithinWindow( + source, triggerTime, EventSurfaceType.APP)); + } + + @Test + public void fallsWithinWindow_windowWithin() { + doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); + long sourceTime = System.currentTimeMillis(); + long triggerTime = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1); + Source source = + SourceFixture.getMinimalValidSourceBuilder() + .setSourceType(Source.SourceType.EVENT) + .setEventTime(sourceTime) + .setEventReportWindows(EVENT_REPORT_WINDOWS_2_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(25)) + .build(); + assertEquals( + EventReportWindowCalcDelegate.MomentPlacement.WITHIN, + mEventReportWindowCalcDelegate.fallsWithinWindow( + source, triggerTime, EventSurfaceType.APP)); + } + + @Test + public void fallsWithinWindow_windowPassed() { + doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); + long sourceTime = System.currentTimeMillis(); + long triggerTime = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(20); + Source source = + SourceFixture.getMinimalValidSourceBuilder() + .setSourceType(Source.SourceType.EVENT) + .setEventTime(sourceTime) + .setEventReportWindows(EVENT_REPORT_WINDOWS_2_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(25)) + .build(); + assertEquals( + EventReportWindowCalcDelegate.MomentPlacement.AFTER, + mEventReportWindowCalcDelegate.fallsWithinWindow( + source, triggerTime, EventSurfaceType.APP)); } } |