forked from criteo/ios-publisher-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCR_HeaderBiddingTests.m
481 lines (392 loc) · 20.6 KB
/
CR_HeaderBiddingTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
//
// CR_HeaderBiddingTests.m
// CriteoPublisherSdkTests
//
// Copyright © 2018-2020 Criteo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "XCTestCase+Criteo.h"
#import "DFPRequestClasses.h"
#import "CR_CacheAdUnit.h"
#import "CR_CdbBidBuilder.h"
#import "CR_CdbBid.h"
#import "CR_HeaderBidding.h"
#import "CR_Logging.h"
#import "CR_DeviceInfoMock.h"
#import "NSString+CriteoUrl.h"
#import "CR_DisplaySizeInjector.h"
#import "CR_IntegrationRegistry.h"
#import "CR_DependencyProvider+Testing.h"
static NSString *const kCpmKey = @"crt_cpm";
static NSString *const kDictionaryDisplayUrlKey = @"crt_displayUrl";
static NSString *const kDfpDisplayUrlKey = @"crt_displayurl";
static NSString *const kSizeKey = @"crt_size";
/** Represent the type of the device for getting more readable tests. */
typedef NS_ENUM(NSInteger, CR_DeviceType) {
CR_DeviceTypeIphone,
CR_DeviceTypeIpad,
CR_DeviceTypeOther,
};
/** Represent the orientation of the device for getting more readable tests. */
typedef NS_ENUM(NSInteger, CR_DeviceOrientation) {
CR_DeviceOrientationLandscape,
CR_DeviceOrientationPortrait,
};
#define CR_AssertInterstitialCrtSize(_crtSize, _type, _orientation, _size) \
do { \
[self recordFailureForInterstitialCrtSize:_crtSize \
withDeviceType:_type \
orientation:_orientation \
screenSize:_size \
atLine:__LINE__]; \
} while (0);
#define CR_AssertEqualDfpString(notDfpStr, dfpStr) \
XCTAssertEqualObjects([NSString cr_dfpCompatibleString:notDfpStr], dfpStr);
@interface CR_HeaderBidding (Testing)
- (BOOL)isDfpRequest:(id)request;
@end
@interface MyGADRequest : GADRequest
@end
@implementation MyGADRequest
@end
@interface MyGAMRequest : GAMRequest
@end
@implementation MyGAMRequest
@end
@interface CR_HeaderBiddingTests : XCTestCase
@property(strong, nonatomic) CR_DeviceInfoMock *device;
@property(strong, nonatomic) CR_DisplaySizeInjector *displaySizeInjector;
@property(strong, nonatomic) CR_IntegrationRegistry *integrationRegistry;
@property(strong, nonatomic) CR_HeaderBidding *headerBidding;
@property(nonatomic, strong) CR_CacheAdUnit *interstitialAdUnit;
@property(nonatomic, strong) CR_CacheAdUnit *adUnit1;
@property(nonatomic, strong) CR_CdbBid *bid1;
@property(nonatomic, strong) CR_CacheAdUnit *adUnit2;
@property(nonatomic, strong) CR_CdbBid *bid2;
@property(nonatomic, strong) NSMutableDictionary *mutableJsonDict;
@property(nonatomic, strong) GAMRequest *request;
@property(nonatomic, strong) id loggingMock;
@end
@implementation CR_HeaderBiddingTests
- (void)setUp {
self.device = [[CR_DeviceInfoMock alloc] init];
self.displaySizeInjector = OCMClassMock([CR_DisplaySizeInjector class]);
CR_DependencyProvider *dependencyProvider =
CR_DependencyProvider.new.withIsolatedIntegrationRegistry;
dependencyProvider.deviceInfo = self.device;
dependencyProvider.displaySizeInjector = self.displaySizeInjector;
self.headerBidding = dependencyProvider.headerBidding;
self.integrationRegistry = dependencyProvider.integrationRegistry;
self.adUnit1 = [[CR_CacheAdUnit alloc] initWithAdUnitId:@"adUnit1" width:300 height:250];
self.bid1 = CR_CdbBidBuilder.new.adUnit(self.adUnit1).build;
self.adUnit2 = [[CR_CacheAdUnit alloc] initWithAdUnitId:@"adUnit2" width:200 height:100];
self.bid2 =
CR_CdbBidBuilder.new.adUnit(self.adUnit2).cpm(@"0.5").displayUrl(@"bid2.displayUrl").build;
self.interstitialAdUnit = [CR_CacheAdUnit.alloc initWithAdUnitId:@"interstitial"
size:CGSizeMake(1, 2)
adUnitType:CRAdUnitTypeInterstitial];
self.request = [[GAMRequest alloc] init];
self.request.customTargeting = @{@"key_1" : @"object 1", @"key_2" : @"object_2"};
self.mutableJsonDict = [self loadSlotDictionary];
self.loggingMock = OCMPartialMock(CR_Logging.sharedInstance);
}
- (void)tearDown {
[self.loggingMock stopMocking];
}
#pragma mark - Empty Bid
- (void)testEmptyBidWithDictionary {
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[self.headerBidding detectIntegration:dictionary];
[self.headerBidding enrichRequest:dictionary withBid:[CR_CdbBid emptyBid] adUnit:self.adUnit1];
OCMVerify([self.loggingMock logMessage:[OCMArg checkWithBlock:^BOOL(CR_LogMessage *logMessage) {
return [logMessage.tag isEqualToString:@"AppBidding"] &&
[logMessage.message containsString:@"No bid found"];
}]]);
XCTAssertEqual(dictionary.count, 0);
OCMVerify([self.integrationRegistry declare:CR_IntegrationCustomAppBidding]);
}
- (void)testEmptyBidWithGadRequest {
GADRequest *request = [[GADRequest alloc] init];
[self.headerBidding detectIntegration:request];
[self.headerBidding enrichRequest:request withBid:[CR_CdbBid emptyBid] adUnit:self.adUnit1];
OCMVerify([self.loggingMock logMessage:[OCMArg checkWithBlock:^BOOL(CR_LogMessage *logMessage) {
return [logMessage.tag isEqualToString:@"AppBidding"] &&
[logMessage.message containsString:@"No bid found"];
}]]);
XCTAssertEqual(request.customTargeting.count, 0);
OCMVerify([self.integrationRegistry declare:CR_IntegrationGamAppBidding]);
}
#pragma mark - Dictionary
- (void)testMutableDictionary {
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
NSDictionary *expected = @{
kDictionaryDisplayUrlKey : self.bid1.displayUrl,
kCpmKey : self.bid1.cpm,
kSizeKey : @"300x250"
};
[self.headerBidding detectIntegration:dictionary];
[self.headerBidding enrichRequest:dictionary withBid:self.bid1 adUnit:self.adUnit1];
OCMVerify([self.loggingMock logMessage:[OCMArg checkWithBlock:^BOOL(CR_LogMessage *logMessage) {
return [logMessage.tag isEqualToString:@"AppBidding"] &&
[logMessage.message containsString:@"Custom"] &&
[logMessage.message containsString:expected.description];
}]]);
XCTAssertEqualObjects(dictionary, expected);
OCMVerify([self.integrationRegistry declare:CR_IntegrationCustomAppBidding]);
}
- (void)testMutableDictionaryWithInterstitial {
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
NSDictionary *expected = @{
kDictionaryDisplayUrlKey : self.bid1.displayUrl,
kCpmKey : self.bid1.cpm,
kSizeKey : @"1x2"
};
[self.headerBidding detectIntegration:dictionary];
[self.headerBidding enrichRequest:dictionary withBid:self.bid1 adUnit:self.interstitialAdUnit];
XCTAssertEqualObjects(dictionary, expected);
OCMVerify([self.integrationRegistry declare:CR_IntegrationCustomAppBidding]);
}
#pragma mark - Unsupported
- (void)testUnsupportedAdRequest {
NSArray *array = [[NSArray alloc] init];
[self.headerBidding detectIntegration:array];
[self.headerBidding enrichRequest:array withBid:self.bid1 adUnit:self.adUnit1];
OCMVerify([self.loggingMock logMessage:[OCMArg checkWithBlock:^BOOL(CR_LogMessage *logMessage) {
return logMessage.severity == CR_LogSeverityError &&
[logMessage.tag isEqualToString:@"AppBidding"] &&
[logMessage.message containsString:@"unsupported"];
}]]);
}
#pragma mark - Google Ad
- (void)testIsDFPRequest_GivenGADRequest_ReturnTrue {
id request = GADRequest.new;
BOOL isDfpRequest = [self.headerBidding isDfpRequest:request];
XCTAssertTrue(isDfpRequest);
}
- (void)testIsDFPRequest_GivenSubClassOfGADRequest_ReturnTrue {
id request = MyGADRequest.new;
BOOL isDfpRequest = [self.headerBidding isDfpRequest:request];
XCTAssertTrue(isDfpRequest);
}
- (void)testIsDFPRequest_GivenGAMRequest_ReturnTrue {
id request = GAMRequest.new;
BOOL isDfpRequest = [self.headerBidding isDfpRequest:request];
XCTAssertTrue(isDfpRequest);
}
- (void)testIsDFPRequest_GivenSubClassOfGAMRequest_ReturnTrue {
id request = MyGAMRequest.new;
BOOL isDfpRequest = [self.headerBidding isDfpRequest:request];
XCTAssertTrue(isDfpRequest);
}
- (void)testIsDFPRequest_GivenUnrelatedObject_ReturnFalse {
id request = NSObject.new;
BOOL isDfpRequest = [self.headerBidding isDfpRequest:request];
XCTAssertFalse(isDfpRequest);
}
- (void)testGADRequest {
GADRequest *request = [[GADRequest alloc] init];
self.device.mock_screenSize = (CGSize){300, 250};
[self.headerBidding detectIntegration:request];
[self.headerBidding enrichRequest:request withBid:self.bid1 adUnit:self.adUnit1];
NSDictionary *targeting = request.customTargeting;
NSString *expectedDfpDisplayUrl = [NSString cr_dfpCompatibleString:self.bid1.displayUrl];
XCTAssertEqual(targeting.count, 3);
XCTAssertEqualObjects(targeting[kDfpDisplayUrlKey], expectedDfpDisplayUrl);
XCTAssertEqualObjects(targeting[kCpmKey], self.bid1.cpm);
XCTAssertEqualObjects(targeting[kSizeKey], @"300x250");
OCMVerify([self.integrationRegistry declare:CR_IntegrationGamAppBidding]);
}
- (void)testGamRequest {
GAMRequest *request = [[GAMRequest alloc] init];
self.device.mock_screenSize = (CGSize){300, 250};
[self.headerBidding detectIntegration:request];
[self.headerBidding enrichRequest:request withBid:self.bid1 adUnit:self.adUnit1];
OCMVerify([self.loggingMock
logMessage:[OCMArg checkWithBlock:^BOOL(CR_LogMessage *logMessage) {
return [logMessage.tag isEqualToString:@"AppBidding"] &&
[logMessage.message containsString:@"DFP"] &&
[logMessage.message containsString:@"\"crt_cpm\" = \"2.0\""] &&
[logMessage.message containsString:@"\"crt_displayurl\" = \"aHR0cHM6"] &&
[logMessage.message containsString:@"\"crt_size\" = 300x250"];
}]]);
NSDictionary *targeting = request.customTargeting;
NSString *expectedDfpDisplayUrl = [NSString cr_dfpCompatibleString:self.bid1.displayUrl];
XCTAssertEqual(targeting.count, 3);
XCTAssertEqualObjects(targeting[kDfpDisplayUrlKey], expectedDfpDisplayUrl);
XCTAssertEqualObjects(targeting[kCpmKey], self.bid1.cpm);
XCTAssertEqualObjects(targeting[kSizeKey], @"300x250");
OCMVerify([self.integrationRegistry declare:CR_IntegrationGamAppBidding]);
}
- (void)testDfpRequestWithInterstitialHasItsDisplayUrlInjected {
GAMRequest *request = [[GAMRequest alloc] init];
self.device.mock_screenSize = (CGSize){42, 1337};
OCMStub([self.displaySizeInjector injectFullScreenSizeInDisplayUrl:self.bid1.displayUrl])
.andReturn(@"display.url");
[self.headerBidding detectIntegration:request];
[self.headerBidding enrichRequest:request withBid:self.bid1 adUnit:self.interstitialAdUnit];
NSDictionary *targeting = request.customTargeting;
NSString *expectedDfpDisplayUrl = [NSString cr_dfpCompatibleString:@"display.url"];
XCTAssertEqual(targeting.count, 3);
XCTAssertEqualObjects(targeting[kDfpDisplayUrlKey], expectedDfpDisplayUrl);
XCTAssertEqualObjects(targeting[kCpmKey], self.bid1.cpm);
XCTAssertEqualObjects(targeting[kSizeKey], @"320x480");
}
- (void)testDfpRequestWithNativeBid {
CR_CacheAdUnit *adUnit = [[CR_CacheAdUnit alloc] initWithAdUnitId:@"/140800857/Endeavour_Native"
size:CGSizeMake(2, 2)
adUnitType:CRAdUnitTypeNative];
CR_CdbBid *nativeBid = [[CR_CdbBid alloc] initWithDict:self.mutableJsonDict
receivedAt:[NSDate date]];
[self.headerBidding detectIntegration:self.request];
[self.headerBidding enrichRequest:self.request withBid:nativeBid adUnit:adUnit];
CR_NativeAssets *nativeAssets = nativeBid.nativeAssets;
NSDictionary *dfpTargeting = self.request.customTargeting;
XCTAssertTrue(dfpTargeting.count > 2);
XCTAssertNil(dfpTargeting[kDfpDisplayUrlKey]);
XCTAssertEqual(nativeBid.cpm, dfpTargeting[kCpmKey]);
[self checkMandatoryNativeAssets:self.request nativeBid:nativeBid];
CR_AssertEqualDfpString(nativeAssets.advertiser.description, dfpTargeting[@"crtn_advname"]);
CR_AssertEqualDfpString(nativeAssets.advertiser.domain, dfpTargeting[@"crtn_advdomain"]);
CR_AssertEqualDfpString(nativeAssets.advertiser.logoImage.url, dfpTargeting[@"crtn_advlogourl"]);
CR_AssertEqualDfpString(nativeAssets.advertiser.logoClickUrl, dfpTargeting[@"crtn_advurl"]);
CR_AssertEqualDfpString(nativeAssets.privacy.longLegalText, dfpTargeting[@"crtn_prtext"]);
OCMVerify([self.integrationRegistry declare:CR_IntegrationGamAppBidding]);
}
- (void)testAddCriteoToDfpRequestForInCompleteNativeBid {
CR_CacheAdUnit *adUnit = [[CR_CacheAdUnit alloc] initWithAdUnitId:@"/140800857/Endeavour_Native"
size:CGSizeMake(2, 2)
adUnitType:CRAdUnitTypeNative];
self.mutableJsonDict[@"native"][@"advertiser"][@"description"] = @"";
self.mutableJsonDict[@"native"][@"advertiser"][@"domain"] = @"";
self.mutableJsonDict[@"native"][@"advertiser"][@"logo"][@"url"] = nil;
self.mutableJsonDict[@"native"][@"advertiser"][@"logoClickUrl"] = @"";
self.mutableJsonDict[@"native"][@"privacy"][@"longLegalText"] = nil;
CR_CdbBid *nativeBid = [[CR_CdbBid alloc] initWithDict:self.mutableJsonDict
receivedAt:[NSDate date]];
[self.headerBidding detectIntegration:self.request];
[self.headerBidding enrichRequest:self.request withBid:nativeBid adUnit:adUnit];
NSDictionary *dfpTargeting = self.request.customTargeting;
XCTAssertGreaterThan(dfpTargeting.count, 2);
XCTAssertNil(dfpTargeting[kDfpDisplayUrlKey]);
XCTAssertNil(dfpTargeting[@"crtn_advname"]);
XCTAssertNil(dfpTargeting[@"crtn_advdomain"]);
XCTAssertNil(dfpTargeting[@"crtn_advlogourl"]);
XCTAssertNil(dfpTargeting[@"crtn_advurl"]);
XCTAssertNil(dfpTargeting[@"crtn_prtext"]);
XCTAssertEqual(nativeBid.cpm, dfpTargeting[kCpmKey]);
[self checkMandatoryNativeAssets:self.request nativeBid:nativeBid];
}
#pragma mark - Sizes
#pragma mark DFP
- (void)testInterstitialSizeOniPhoneInLandscape {
// Size of recent devices
// https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html
// iPhone SE => 320 x 568
CR_AssertInterstitialCrtSize(@"320x480", CR_DeviceTypeIphone, CR_DeviceOrientationPortrait,
((CGSize){320.f, 568.f}));
CR_AssertInterstitialCrtSize(@"480x320", CR_DeviceTypeIphone, CR_DeviceOrientationLandscape,
((CGSize){568.f, 320.f}));
// iPhone 7 Plus => 414 x 736
CR_AssertInterstitialCrtSize(@"320x480", CR_DeviceTypeIphone, CR_DeviceOrientationPortrait,
((CGSize){414.f, 736.f}));
CR_AssertInterstitialCrtSize(@"480x320", CR_DeviceTypeIphone, CR_DeviceOrientationLandscape,
((CGSize){736.f, 414.f}));
// iPad Air 2 => 768 x 1024
CR_AssertInterstitialCrtSize(@"768x1024", CR_DeviceTypeIpad, CR_DeviceOrientationPortrait,
((CGSize){768.f, 1024.f}));
CR_AssertInterstitialCrtSize(@"1024x768", CR_DeviceTypeIpad, CR_DeviceOrientationLandscape,
((CGSize){1024.f, 768.f}));
// iPad Pro (12.9-inch) => 1024 x 1366
CR_AssertInterstitialCrtSize(@"768x1024", CR_DeviceTypeIpad, CR_DeviceOrientationPortrait,
((CGSize){1024.f, 1366.f}));
CR_AssertInterstitialCrtSize(@"1024x768", CR_DeviceTypeIpad, CR_DeviceOrientationLandscape,
((CGSize){1024.f, 1024.f}));
// Fictive iPad with small size (so considered as a Phone)
CR_AssertInterstitialCrtSize(@"320x480", CR_DeviceTypeIpad, CR_DeviceOrientationPortrait,
((CGSize){640.f, 1024.f}));
CR_AssertInterstitialCrtSize(@"480x320", CR_DeviceTypeIpad, CR_DeviceOrientationLandscape,
((CGSize){1024.f, 640.f}));
// Fictive TV
CR_AssertInterstitialCrtSize(@"768x1024", CR_DeviceTypeOther, CR_DeviceOrientationPortrait,
((CGSize){1024.f, 2048.f}));
CR_AssertInterstitialCrtSize(@"1024x768", CR_DeviceTypeOther, CR_DeviceOrientationLandscape,
((CGSize){2048.f, 1024.f}));
}
#pragma mark - Private
- (void)recordFailureForInterstitialCrtSize:(NSString *)crtSize
withDeviceType:(CR_DeviceType)deviceType
orientation:(CR_DeviceOrientation)orientation
screenSize:(CGSize)screenSize
atLine:(NSUInteger)lineNumber {
// Clean up because this method can be reused in the same test
[self tearDown];
[self setUp];
CR_CacheAdUnit *adUnit = [CR_CacheAdUnit cacheAdUnitForInterstialWithAdUnitId:@"interstitial"
size:(CGSize){400, 400}];
CR_CdbBid *bid = CR_CdbBidBuilder.new.adUnit(adUnit).build;
self.device.mock_isPhone = deviceType == CR_DeviceTypeIphone;
self.device.mock_isInPortrait = orientation == CR_DeviceOrientationPortrait;
self.device.mock_screenSize = screenSize;
[self.headerBidding detectIntegration:self.request];
[self.headerBidding enrichRequest:self.request withBid:bid adUnit:adUnit];
NSDictionary *target = self.request.customTargeting;
if (![crtSize isEqual:target[kSizeKey]]) {
NSString *desc =
[[NSString alloc] initWithFormat:@"The customTargeting doesn't contain \"%@ \": %@:%@",
kSizeKey, crtSize, target];
NSString *file = [[NSString alloc] initWithCString:__FILE__ encoding:NSUTF8StringEncoding];
[self cr_recordFailureWithDescription:desc inFile:file atLine:lineNumber expected:YES];
}
}
- (void)checkMandatoryNativeAssets:(GAMRequest *)request nativeBid:(CR_CdbBid *)nativeBid {
CR_NativeAssets *nativeAssets = nativeBid.nativeAssets;
CR_NativeProduct *firstProduct = nativeAssets.products[0];
NSDictionary *dfpTargeting = request.customTargeting;
XCTAssert(nativeBid.nativeAssets.products.count > 0);
CR_AssertEqualDfpString(firstProduct.title, dfpTargeting[@"crtn_title"]);
CR_AssertEqualDfpString(firstProduct.description, dfpTargeting[@"crtn_desc"]);
CR_AssertEqualDfpString(firstProduct.price, dfpTargeting[@"crtn_price"]);
CR_AssertEqualDfpString(firstProduct.clickUrl, dfpTargeting[@"crtn_clickurl"]);
CR_AssertEqualDfpString(firstProduct.callToAction, dfpTargeting[@"crtn_cta"]);
CR_AssertEqualDfpString(firstProduct.image.url, dfpTargeting[@"crtn_imageurl"]);
CR_AssertEqualDfpString(nativeAssets.privacy.optoutClickUrl, dfpTargeting[@"crtn_prurl"]);
CR_AssertEqualDfpString(nativeAssets.privacy.optoutImageUrl, dfpTargeting[@"crtn_primageurl"]);
XCTAssertEqual(nativeAssets.impressionPixels.count,
[dfpTargeting[@"crtn_pixcount"] integerValue]);
for (int i = 0; i < nativeBid.nativeAssets.impressionPixels.count; i++) {
NSString *key = [NSString stringWithFormat:@"%@%d", @"crtn_pixurl_", i];
CR_AssertEqualDfpString(nativeBid.nativeAssets.impressionPixels[i], dfpTargeting[key]);
}
}
- (NSMutableDictionary *)loadSlotDictionary {
NSMutableDictionary *responseDict = [self loadSampleBidJson][@"slots"][0];
XCTAssert(responseDict);
return responseDict;
}
- (NSMutableDictionary *)loadSampleBidJson {
NSError *e = NULL;
NSURL *jsonURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"SampleBid"
withExtension:@"json"];
NSData *jsonData = [NSData dataWithContentsOfURL:jsonURL options:0 error:&e];
XCTAssert(e == nil);
NSMutableDictionary *responseDict =
[NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers
error:&e];
XCTAssert(e == nil);
return responseDict;
}
@end