Files
MapLibreParticleLab/platform/ios/Integration Tests/MGLNetworkConfigurationIntegrationTests.mm
Julian Rex e62a7cade3 Updates mapbox-gl-native submodule to release-unicorn branch (#151)
* Update submodule

* [ios] Ignore patches

* Use new FileSourceManager interface

* Remove filesource-files.json

* Update submodule

* Remove http_file_source.mm from this repo for clarity.

* Adds set of MGLNativeNetworkManager (via MGLMapView and MGLOfflineStorage); includes tests.

* - Create testing methods, so that we don't need to export MGLNativeNetworkManager in GL
- Singleton accessors now set the delegate with each call; tests modified accordingly.

* Add test for expected properties

* [ios] Update MGLResourceTests for SKU changes

Co-authored-by: Alexander Shalamov <alexander.shalamov@mapbox.com>
Co-authored-by: Jordan Kiley <jmkiley@users.noreply.github.com>
2020-01-22 15:09:18 -08:00

85 lines
2.5 KiB
Plaintext

#import <XCTest/XCTest.h>
#import "MGLNetworkIntegrationManager.h"
#import "MGLNetworkConfiguration.h"
#import "MGLNetworkConfiguration_Private.h"
#import "MGLOfflineStorage_Private.h"
#import "MGLMapView.h"
#import "MGLFoundation_Private.h"
@interface MGLNetworkConfiguration (Testing)
+ (void)testing_clearNativeNetworkManagerDelegate;
+ (id)testing_nativeNetworkManagerDelegate;
@end
@interface MGLNetworkConfigurationIntegrationTests : XCTestCase
@end
#define ASSERT_DELEGATE_IS_NIL() \
XCTAssertNil([MGLNetworkConfiguration testing_nativeNetworkManagerDelegate])
#define ASSERT_DELEGATE_IS_NOT_NIL() \
XCTAssertNotNil([MGLNetworkConfiguration testing_nativeNetworkManagerDelegate])
// NOTE: These tests are currently assumed to run in this specific order.
@implementation MGLNetworkConfigurationIntegrationTests
- (void)setUp {
[super setUp];
// Reset before each test
[MGLNetworkConfiguration testing_clearNativeNetworkManagerDelegate];
}
- (void)test1_NativeNetworkManagerDelegateIsSet
{
ASSERT_DELEGATE_IS_NIL();
[MGLNetworkConfiguration setNativeNetworkManagerDelegateToDefault];
id delegate = [MGLNetworkConfiguration testing_nativeNetworkManagerDelegate];
id<MGLNativeNetworkDelegate> manager = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(delegate, MGLNativeNetworkDelegate);
XCTAssertNotNil(manager);
// Expected properties
XCTAssertNotNil([manager skuToken]);
XCTAssertNotNil([manager sessionConfiguration]);
}
- (void)test2_NativeNetworkManagerDelegateIsSetBySharedManager
{
ASSERT_DELEGATE_IS_NIL();
// Just calling the shared manager is also sufficient (even though, it's a
// singleton and created with a dispatch_once, the delegate is re-set for
// each call.
[MGLNetworkConfiguration sharedManager];
ASSERT_DELEGATE_IS_NOT_NIL();
}
- (void)test3_NativeNetworkManagerDelegateIsSetBySharedOfflineStorage
{
ASSERT_DELEGATE_IS_NIL();
// Similar to `[MGLNetworkConfiguration sharedManager]`,
// `[MGLOfflineStorage sharedOfflineStorage]` also sets the delegate.
[MGLOfflineStorage sharedOfflineStorage];
ASSERT_DELEGATE_IS_NOT_NIL();
}
- (void)test4_NativeNetworkManagerDelegateIsSetBySharedOfflineStorageASecondTime
{
// Testing a second time...
ASSERT_DELEGATE_IS_NIL();
[MGLOfflineStorage sharedOfflineStorage];
ASSERT_DELEGATE_IS_NOT_NIL();
}
- (void)test5_NativeNetworkManagerDelegateIsSetByMapViewInit
{
ASSERT_DELEGATE_IS_NIL();
(void)[[MGLMapView alloc] init];
ASSERT_DELEGATE_IS_NOT_NIL();
}
@end