@@ -1141,6 +1141,55 @@ public void testDelayOutcomes() throws Exception {
1141
1141
assertMeasureAtIndex (1 , ONESIGNAL_OUTCOME_NAME );
1142
1142
}
1143
1143
1144
+ @ Test
1145
+ public void testSendOutcomesFailWhenRequiresUserPrivacyConsent () throws Exception {
1146
+ // Enable IAM v2
1147
+ preferences = new MockOSSharedPreferences ();
1148
+ trackerFactory = new OSTrackerFactory (preferences , logger , time );
1149
+ sessionManager = new MockSessionManager (sessionListener , trackerFactory , logger );
1150
+ preferences .saveBool (preferences .getPreferencesName (), preferences .getOutcomesV2KeyName (), true );
1151
+ OneSignal_setSharedPreferences (preferences );
1152
+
1153
+ OneSignalInit ();
1154
+ threadAndTaskWait ();
1155
+ assertRestCalls (2 );
1156
+ OneSignal .setRequiresUserPrivacyConsent (true );
1157
+
1158
+ // Make sure session is UNATTRIBUTED
1159
+ assertNotificationChannelUnattributedInfluence ();
1160
+
1161
+ // Send unique outcome event
1162
+ OneSignal .sendUniqueOutcome (ONESIGNAL_OUTCOME_NAME );
1163
+ threadAndTaskWait ();
1164
+
1165
+ // Check that the task has been queued until consent is given
1166
+ assertRestCalls (2 );
1167
+
1168
+ // Send outcome event
1169
+ OneSignal .sendOutcome (ONESIGNAL_OUTCOME_NAME );
1170
+ threadAndTaskWait ();
1171
+
1172
+ // Ensure still only 2 requests have been made
1173
+ assertRestCalls (2 );
1174
+
1175
+ OneSignal .provideUserConsent (true );
1176
+ threadAndTaskWait ();
1177
+
1178
+ // Send unique outcome event
1179
+ OneSignal .sendUniqueOutcome (ONESIGNAL_OUTCOME_NAME );
1180
+ threadAndTaskWait ();
1181
+
1182
+ // Send outcome event
1183
+ OneSignal .sendOutcome (ONESIGNAL_OUTCOME_NAME );
1184
+ threadAndTaskWait ();
1185
+
1186
+ // Make sure session is UNATTRIBUTED
1187
+ assertNotificationChannelUnattributedInfluence ();
1188
+
1189
+ // Check measure end point was most recent request and contains received notification
1190
+ assertMeasureOnV2AtIndex (3 , ONESIGNAL_OUTCOME_NAME , null , null , null , null );
1191
+ }
1192
+
1144
1193
private void foregroundAppAfterClickingNotification () throws Exception {
1145
1194
OneSignalInit ();
1146
1195
threadAndTaskWait ();
0 commit comments