|
| 1 | +// |
| 2 | +// BNCDisableAdNetworkCalloutsTests.m |
| 3 | +// Branch-SDK-Tests |
| 4 | +// |
| 5 | +// Created by Ernest Cho on 3/2/20. |
| 6 | +// Copyright © 2020 Branch, Inc. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import <XCTest/XCTest.h> |
| 10 | +#import "BNCPreferenceHelper.h" |
| 11 | +#import "BNCDeviceInfo.h" |
| 12 | +#import "BNCServerInterface.h" |
| 13 | + |
| 14 | +@interface BNCServerInterface() |
| 15 | +- (void)updateDeviceInfoToMutableDictionary:(NSMutableDictionary *)dict; |
| 16 | +@end |
| 17 | + |
| 18 | +@interface BNCDisableAdNetworkCalloutsTests : XCTestCase |
| 19 | + |
| 20 | +@end |
| 21 | + |
| 22 | +// These tests are not parallelizable and therefore disabled by default |
| 23 | +// This is due to the tight coupling between BNCPreferenceHelper and BNCDeviceInfo |
| 24 | +@implementation BNCDisableAdNetworkCalloutsTests |
| 25 | + |
| 26 | +- (void)setUp { |
| 27 | + [BNCPreferenceHelper preferenceHelper].disableAdNetworkCallouts = YES; |
| 28 | +} |
| 29 | + |
| 30 | +- (void)tearDown { |
| 31 | + [BNCPreferenceHelper preferenceHelper].disableAdNetworkCallouts = NO; |
| 32 | +} |
| 33 | + |
| 34 | +// check on the V2 dictionary |
| 35 | +- (void)testV2Dictionary { |
| 36 | + NSDictionary *dict = [[BNCDeviceInfo getInstance] v2dictionary]; |
| 37 | + XCTAssertNotNil(dict); |
| 38 | + XCTAssertNotNil(dict[@"brand"]); |
| 39 | + XCTAssertNotNil(dict[@"os"]); |
| 40 | + XCTAssertNotNil(dict[@"sdk"]); |
| 41 | + XCTAssertNotNil(dict[@"sdk_version"]); |
| 42 | + |
| 43 | + XCTAssertTrue(dict[@"disable_ad_network_callouts"]); |
| 44 | +} |
| 45 | + |
| 46 | +// check on V1 payload |
| 47 | +- (void)testV1Payload { |
| 48 | + BNCServerInterface *interface = [BNCServerInterface new]; |
| 49 | + interface.preferenceHelper = [BNCPreferenceHelper preferenceHelper]; |
| 50 | + |
| 51 | + NSMutableDictionary *tmp = [NSMutableDictionary new]; |
| 52 | + [interface updateDeviceInfoToMutableDictionary:tmp]; |
| 53 | + |
| 54 | + XCTAssertNotNil(tmp); |
| 55 | + XCTAssertTrue(tmp[@"disable_ad_network_callouts"]); |
| 56 | +} |
| 57 | + |
| 58 | +@end |
0 commit comments