@@ -14,7 +14,8 @@ - (MPKitExecStatus *)executeWithIdentifier:(NSString * _Nullable)identifier
1414 embeddedViews : (NSDictionary <NSString *, MPRoktEmbeddedView *> * _Nullable)embeddedViews
1515 config : (MPRoktConfig * _Nullable)mpRoktConfig
1616 callbacks : (MPRoktEventCallback * _Nullable)callbacks
17- filteredUser : (FilteredMParticleUser * _Nonnull)filteredUser ;
17+ filteredUser : (FilteredMParticleUser * _Nonnull)filteredUser
18+ options : (MPRoktPlacementOptions * _Nullable)options ;
1819- (MPKitExecStatus *)setWrapperSdk : (MPWrapperSdk)wrapperSdk version : (nonnull NSString *)wrapperSdkVersion ;
1920
2021- (MPKitExecStatus *)purchaseFinalized : (NSString *)placementId
@@ -164,6 +165,7 @@ - (void)testExecuteWithIdentifier {
164165 }]
165166 placements: OCMOCK_ANY
166167 config: nil
168+ placementOptions: OCMOCK_ANY
167169 onLoad: nil
168170 onUnLoad: nil
169171 onShouldShowLoadingIndicator: nil
@@ -175,7 +177,8 @@ - (void)testExecuteWithIdentifier {
175177 embeddedViews: embeddedViews
176178 config: nil
177179 callbacks: nil
178- filteredUser: user];
180+ filteredUser: user
181+ options: nil ];
179182
180183 // Verify
181184 XCTAssertNotNil (status);
@@ -201,6 +204,7 @@ - (void)testExecuteSandboxDetection {
201204 }]
202205 placements: OCMOCK_ANY
203206 config: nil
207+ placementOptions: OCMOCK_ANY
204208 onLoad: nil
205209 onUnLoad: nil
206210 onShouldShowLoadingIndicator: nil
@@ -212,7 +216,83 @@ - (void)testExecuteSandboxDetection {
212216 embeddedViews: embeddedViews
213217 config: nil
214218 callbacks: nil
215- filteredUser: user];
219+ filteredUser: user
220+ options: nil ];
221+
222+ // Verify
223+ XCTAssertNotNil (status);
224+ XCTAssertEqual (status.returnCode , MPKitReturnCodeSuccess);
225+ OCMVerifyAll (mockRoktSDK);
226+ }
227+
228+ - (void )testExecuteWithIdentifierWithOptions {
229+ id mockRoktSDK = OCMClassMock ([Rokt class ]);
230+
231+ MPRoktEmbeddedView *view = [[MPRoktEmbeddedView alloc ] init ];
232+ NSString *identifier = @" TestView" ;
233+ NSDictionary *embeddedViews = @{@" placement1" : view};
234+ NSDictionary *attributes = @{@" attr1" : @" value1" , @" sandbox" : @" false" };
235+ FilteredMParticleUser *user = [[FilteredMParticleUser alloc ] init ];
236+
237+ // Create placement options with a custom timestamp value
238+ MPRoktPlacementOptions *options = [[MPRoktPlacementOptions alloc ] initWithTimestamp: 42 ];
239+
240+ // Expect Rokt execute call and verify placementOptions carries the jointSdkSelectPlacements value
241+ OCMExpect ([mockRoktSDK executeWithViewName: identifier
242+ attributes: OCMOCK_ANY
243+ placements: OCMOCK_ANY
244+ config: nil
245+ placementOptions: [OCMArg checkWithBlock: ^BOOL (PlacementOptions *opts) {
246+ return opts != nil ;
247+ }]
248+ onLoad: nil
249+ onUnLoad: nil
250+ onShouldShowLoadingIndicator: nil
251+ onShouldHideLoadingIndicator: nil
252+ onEmbeddedSizeChange: nil ]);
253+
254+ MPKitExecStatus *status = [self .kitInstance executeWithIdentifier: identifier
255+ attributes: attributes
256+ embeddedViews: embeddedViews
257+ config: nil
258+ callbacks: nil
259+ filteredUser: user
260+ options: options];
261+
262+ // Verify
263+ XCTAssertNotNil (status);
264+ XCTAssertEqual (status.returnCode , MPKitReturnCodeSuccess);
265+ OCMVerifyAll (mockRoktSDK);
266+ }
267+
268+ - (void )testExecuteWithIdentifierNilOptionsCreatesDefaultPlacementOptions {
269+ id mockRoktSDK = OCMClassMock ([Rokt class ]);
270+
271+ NSString *identifier = @" TestView" ;
272+ NSDictionary *attributes = @{@" attr1" : @" value1" , @" sandbox" : @" false" };
273+ FilteredMParticleUser *user = [[FilteredMParticleUser alloc ] init ];
274+
275+ // When options is nil, a default PlacementOptions with jointSdkSelectPlacements=0 should be created
276+ OCMExpect ([mockRoktSDK executeWithViewName: identifier
277+ attributes: OCMOCK_ANY
278+ placements: OCMOCK_ANY
279+ config: nil
280+ placementOptions: [OCMArg checkWithBlock: ^BOOL (PlacementOptions *opts) {
281+ return opts != nil ;
282+ }]
283+ onLoad: nil
284+ onUnLoad: nil
285+ onShouldShowLoadingIndicator: nil
286+ onShouldHideLoadingIndicator: nil
287+ onEmbeddedSizeChange: nil ]);
288+
289+ MPKitExecStatus *status = [self .kitInstance executeWithIdentifier: identifier
290+ attributes: attributes
291+ embeddedViews: nil
292+ config: nil
293+ callbacks: nil
294+ filteredUser: user
295+ options: nil ];
216296
217297 // Verify
218298 XCTAssertNotNil (status);
@@ -783,6 +863,7 @@ - (void)testExecuteWithIdentifierLogsSelectPlacementEventWithPreparedAttributes
783863 attributes: OCMOCK_ANY
784864 placements: OCMOCK_ANY
785865 config: OCMOCK_ANY
866+ placementOptions: OCMOCK_ANY
786867 onLoad: OCMOCK_ANY
787868 onUnLoad: OCMOCK_ANY
788869 onShouldShowLoadingIndicator: OCMOCK_ANY
@@ -795,7 +876,8 @@ - (void)testExecuteWithIdentifierLogsSelectPlacementEventWithPreparedAttributes
795876 embeddedViews: nil
796877 config: nil
797878 callbacks: nil
798- filteredUser: user];
879+ filteredUser: user
880+ options: nil ];
799881
800882 // Verify that logEvent was called with the correct MPEvent object
801883 OCMVerifyAll (mockMParticleInstance);
0 commit comments