Skip to content

Commit 0108562

Browse files
committed
Tests
1 parent 4f7e1b1 commit 0108562

File tree

2 files changed

+21
-93
lines changed

2 files changed

+21
-93
lines changed

geolocator_apple/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
ignoresPersistentStateOnLaunch = "NO"
5959
debugDocumentVersioning = "YES"
6060
debugServiceExtension = "internal"
61+
enableGPUValidationMode = "1"
6162
allowLocationSimulation = "YES">
6263
<BuildableProductRunnable
6364
runnableDebuggingMode = "0">

geolocator_apple/example/ios/RunnerTests/GeolocatorPluginTests.m

+20-93
Original file line numberDiff line numberDiff line change
@@ -311,119 +311,46 @@ - (void)testRequestTemporaryFullAccuracyWithInvalidArgument {
311311
#pragma mark - Test open setting related methods
312312

313313
- (void)testOpenAppSettings {
314-
if (@available(iOS 10, *))
315-
{
316-
id mockApplication = OCMClassMock([UIApplication class]);
317-
OCMStub([mockApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
318-
options:@{}
319-
completionHandler:([OCMArg invokeBlockWithArgs:@(YES), nil])]);
320-
OCMStub(ClassMethod([mockApplication sharedApplication])).andReturn(mockApplication);
321-
322-
323-
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"openAppSettings"
324-
arguments:@{}];
325-
326-
XCTestExpectation *expectation = [self expectationWithDescription:@"openAppSettings should return yes."];
327-
GeolocatorPlugin *plugin = [[GeolocatorPlugin alloc] init];
328-
[plugin handleMethodCall:call result:^(id _Nullable result) {
329-
XCTAssertTrue(result);
330-
[expectation fulfill];
331-
}];
332-
333-
[self waitForExpectationsWithTimeout:5.0 handler:nil];
334-
return;
335-
}
336-
337-
if (@available(iOS 8, *)) {
338-
id mockApplication = OCMClassMock([UIApplication class]);
339-
OCMStub([(UIApplication *)mockApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]).andReturn(YES);
340-
OCMStub(ClassMethod([mockApplication sharedApplication])).andReturn(mockApplication);
341-
342-
343-
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"openAppSettings"
344-
arguments:@{}];
345-
346-
XCTestExpectation *expectation = [self expectationWithDescription:@"openAppSettings should return yes."];
347-
GeolocatorPlugin *plugin = [[GeolocatorPlugin alloc] init];
348-
[plugin handleMethodCall:call result:^(id _Nullable result) {
349-
XCTAssertTrue(result);
350-
[expectation fulfill];
351-
}];
352-
353-
[self waitForExpectationsWithTimeout:5.0 handler:nil];
354-
return;
355-
}
356-
314+
id mockApplication = OCMClassMock([UIApplication class]);
315+
OCMStub([mockApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
316+
options:@{}
317+
completionHandler:([OCMArg invokeBlockWithArgs:@(YES), nil])]);
318+
OCMStub(ClassMethod([mockApplication sharedApplication])).andReturn(mockApplication);
319+
320+
357321
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"openAppSettings"
358322
arguments:@{}];
359-
323+
360324
XCTestExpectation *expectation = [self expectationWithDescription:@"openAppSettings should return yes."];
361325
GeolocatorPlugin *plugin = [[GeolocatorPlugin alloc] init];
362326
[plugin handleMethodCall:call result:^(id _Nullable result) {
363-
XCTAssertFalse(result);
327+
XCTAssertTrue(result);
364328
[expectation fulfill];
365329
}];
366-
330+
367331
[self waitForExpectationsWithTimeout:5.0 handler:nil];
368332
return;
369333
}
370334

371335
- (void)testOpenLocationSettings {
372-
if (@available(iOS 10, *))
373-
{
374-
id mockApplication = OCMClassMock([UIApplication class]);
375-
OCMStub([mockApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
376-
options:@{}
377-
completionHandler:([OCMArg invokeBlockWithArgs:@(YES), nil])]);
378-
OCMStub(ClassMethod([mockApplication sharedApplication])).andReturn(mockApplication);
379-
380-
381-
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"openLocationSettings"
382-
arguments:@{}];
383-
384-
XCTestExpectation *expectation = [self expectationWithDescription:@"openLocationSettings should return yes."];
385-
GeolocatorPlugin *plugin = [[GeolocatorPlugin alloc] init];
386-
[plugin handleMethodCall:call result:^(id _Nullable result) {
387-
XCTAssertTrue(result);
388-
[expectation fulfill];
389-
}];
390-
391-
[self waitForExpectationsWithTimeout:5.0 handler:nil];
392-
return;
393-
}
394-
395-
if (@available(iOS 8, *)) {
396-
id mockApplication = OCMClassMock([UIApplication class]);
397-
OCMStub([(UIApplication *)mockApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]).andReturn(YES);
398-
OCMStub(ClassMethod([mockApplication sharedApplication])).andReturn(mockApplication);
399-
400-
401-
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"openLocationSettings"
402-
arguments:@{}];
403-
404-
XCTestExpectation *expectation = [self expectationWithDescription:@"openLocationSettings should return yes."];
405-
GeolocatorPlugin *plugin = [[GeolocatorPlugin alloc] init];
406-
[plugin handleMethodCall:call result:^(id _Nullable result) {
407-
XCTAssertTrue(result);
408-
[expectation fulfill];
409-
}];
410-
411-
[self waitForExpectationsWithTimeout:5.0 handler:nil];
412-
return;
413-
}
414-
336+
id mockApplication = OCMClassMock([UIApplication class]);
337+
OCMStub([mockApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
338+
options:@{}
339+
completionHandler:([OCMArg invokeBlockWithArgs:@(YES), nil])]);
340+
OCMStub(ClassMethod([mockApplication sharedApplication])).andReturn(mockApplication);
341+
342+
415343
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"openLocationSettings"
416344
arguments:@{}];
417-
345+
418346
XCTestExpectation *expectation = [self expectationWithDescription:@"openLocationSettings should return yes."];
419347
GeolocatorPlugin *plugin = [[GeolocatorPlugin alloc] init];
420348
[plugin handleMethodCall:call result:^(id _Nullable result) {
421-
XCTAssertFalse(result);
349+
XCTAssertTrue(result);
422350
[expectation fulfill];
423351
}];
424-
352+
425353
[self waitForExpectationsWithTimeout:5.0 handler:nil];
426-
return;
427354
}
428355

429356
@end

0 commit comments

Comments
 (0)