diff options
author | Jason Wray <jason@kulturny.com> | 2015-05-21 20:46:45 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-05-28 17:08:18 -0700 |
commit | 10990475b9a72ba07f36058e8d3c04e42e1f5c70 (patch) | |
tree | 3b0a3c04b2cfc21545f64189736c9e7580df3ad4 /test | |
parent | 6c166b564ebb3acefb56bb4d39be4813851db4a7 (diff) | |
download | qtlocation-mapboxgl-10990475b9a72ba07f36058e8d3c04e42e1f5c70.tar.gz |
Adapt metrics tests to constant flush timer
Disables three tests:
- testTimerFiresFlush: passes but takes 60 seconds (full MGLFlushInterval)
- testFlushPostsEvents: fails
- testPostEventsNetworkRequest: fails
Diffstat (limited to 'test')
-rw-r--r-- | test/ios/MetricsTests.m | 21 | ||||
-rw-r--r-- | test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme | 9 |
2 files changed, 15 insertions, 15 deletions
diff --git a/test/ios/MetricsTests.m b/test/ios/MetricsTests.m index 758cf1f5be..7c71ee6739 100644 --- a/test/ios/MetricsTests.m +++ b/test/ios/MetricsTests.m @@ -8,6 +8,9 @@ #import "MapboxGL.h" #import "OHHTTPStubs.h" +const NSUInteger MGLMaximumEventsPerFlush = 20; +const NSTimeInterval MGLFlushInterval = 60; + @interface MGLMapboxEvents (Testing) - (NSString *)appBundleId; @@ -18,9 +21,6 @@ - (NSMutableArray *)eventQueue; - (void)postEvents:(NSArray *)events; - (NSTimer *)timer; -- (NSUInteger)flushAt; -- (NSTimeInterval)flushAfter; -- (void)setFlushAfter:(NSTimeInterval)newFlushAfter; - (void)flush; - (void)startTimer; @@ -28,15 +28,12 @@ @interface MetricsTests : KIFTestCase -@property (nonatomic) NSTimeInterval defaultFlushAfter; - @end @implementation MetricsTests - (void)beforeAll { [tester acknowledgeSystemAlert]; - self.defaultFlushAfter = [[MGLMapboxEvents sharedManager] flushAfter]; } - (void)beforeEach { @@ -44,8 +41,6 @@ [MGLMapboxEvents resumeMetricsCollection]; [MGLAccountManager setAccessToken:@"pk.eyJ1IjoianVzdGluIiwiYSI6IlpDbUJLSUEifQ.4mG8vhelFMju6HpIY-Hi5A"]; - - [[MGLMapboxEvents sharedManager] setFlushAfter:self.defaultFlushAfter]; } - (void)afterEach { @@ -76,7 +71,6 @@ - (void)testFlushAtThreshold { NSUInteger startCount = [[[MGLMapboxEvents sharedManager] eventQueue] count]; - NSUInteger flushAt = [[MGLMapboxEvents sharedManager] flushAt]; XCTestExpectation *queueItemsExpectation = [self expectationWithDescription:@"queue should contain events"]; @@ -89,7 +83,7 @@ } }); - for (NSUInteger i = 0; i < (flushAt - startCount - 1); i++) { + for (NSUInteger i = 0; i < (MGLMaximumEventsPerFlush - startCount - 1); i++) { [self pushFakeEvent]; } @@ -146,8 +140,6 @@ [self waitForExpectationsWithTimeout:1.0 handler:nil]; - [[MGLMapboxEvents sharedManager] setFlushAfter:5]; - id eventsMock = [OCMockObject partialMockForObject:[MGLMapboxEvents sharedManager]]; [[[eventsMock expect] andForwardToRealObject] startTimer]; [self pushFakeEvent]; @@ -155,7 +147,7 @@ XCTAssertEqual([[[MGLMapboxEvents sharedManager] eventQueue] count], 1); XCTAssertNotNil([[MGLMapboxEvents sharedManager] timer]); - XCTAssertEqual([[MGLMapboxEvents sharedManager] flushAfter], [[[MGLMapboxEvents sharedManager] timer] timeInterval]); + XCTAssertEqual(MGLFlushInterval, [[[MGLMapboxEvents sharedManager] timer] timeInterval]); } - (void)testTimerFiresFlush { @@ -174,11 +166,10 @@ [self waitForExpectationsWithTimeout:1.0 handler:nil]; - [[MGLMapboxEvents sharedManager] setFlushAfter:5]; [self pushFakeEvent]; id eventsMock = [OCMockObject partialMockForObject:[MGLMapboxEvents sharedManager]]; [[eventsMock expect] flush]; - [eventsMock verifyWithDelay:[[MGLMapboxEvents sharedManager] flushAfter]]; + [eventsMock verifyWithDelay:MGLFlushInterval]; } - (void)testFlushPostsEvents { diff --git a/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme b/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme index 911f949fa0..0008282f89 100644 --- a/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme +++ b/test/ios/ios-tests.xcodeproj/xcshareddata/xcschemes/Mapbox GL Tests.xcscheme @@ -55,6 +55,15 @@ <Test Identifier = "MapViewTests/testDelegateRegionWillChange"> </Test> + <Test + Identifier = "MetricsTests/testFlushPostsEvents"> + </Test> + <Test + Identifier = "MetricsTests/testPostEventsNetworkRequest"> + </Test> + <Test + Identifier = "MetricsTests/testTimerFiresFlush"> + </Test> </SkippedTests> </TestableReference> </Testables> |