From 10990475b9a72ba07f36058e8d3c04e42e1f5c70 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Thu, 21 May 2015 20:46:45 -0700 Subject: Adapt metrics tests to constant flush timer Disables three tests: - testTimerFiresFlush: passes but takes 60 seconds (full MGLFlushInterval) - testFlushPostsEvents: fails - testPostEventsNetworkRequest: fails --- test/ios/MetricsTests.m | 21 ++++++--------------- .../xcshareddata/xcschemes/Mapbox GL Tests.xcscheme | 9 +++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'test') 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 @@ + + + + + + -- cgit v1.2.1