forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '287af0f8f99d3afb9eaef1576ee34d683f0e2f79'
* commit '287af0f8f99d3afb9eaef1576ee34d683f0e2f79': [ios_platform_images] ignore DecoderCallback deprecation (flutter#5806) Roll Flutter from ac29c11 to efb9368 (3 revisions) (flutter#5827) Fix issue where map updates don't take effect in Flutter v3.0.0 (flutter#5787) Roll Flutter from e4c7f6e to ac29c11 (1 revision) (flutter#5826) Roll Flutter from 7ca4984 to e4c7f6e (4 revisions) (flutter#5824) Roll Flutter from 35c0a3e to 7ca4984 (3 revisions) (flutter#5823) [ci] Initial migration to Cirrus Apple silicon (flutter#5794) Roll Flutter from 9398c14 to 35c0a3e (9 revisions) (flutter#5821) Roll Flutter from f852092 to 9398c14 (3 revisions) (flutter#5817) Roll Flutter from 7ece8f9 to f852092 (5 revisions) (flutter#5815) Roll Flutter from ec20ea8 to 7ece8f9 (3 revisions) (flutter#5813) [google_maps_flutter] Fix prefer_const_literals_to_create_immutables (flutter#5811) [google_maps_flutter] Updates platform interface to new analysis options (flutter#5793) [Camera] Return all possible cameras on iOS (flutter#5636)
- Loading branch information
Showing
57 changed files
with
882 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ec20ea80ad98007bd022648168e7b3cc38b2e665 | ||
efb9368573f605fdf63b6143d7a352b400805a72 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@import camera; | ||
@import camera.Test; | ||
@import XCTest; | ||
@import AVFoundation; | ||
#import <OCMock/OCMock.h> | ||
#import "MockFLTThreadSafeFlutterResult.h" | ||
|
||
@interface AvailableCamerasTest : XCTestCase | ||
@end | ||
|
||
@implementation AvailableCamerasTest | ||
|
||
- (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { | ||
CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; | ||
XCTestExpectation *expectation = | ||
[[XCTestExpectation alloc] initWithDescription:@"Result finished"]; | ||
|
||
// iPhone 13 Cameras: | ||
AVCaptureDevice *wideAngleCamera = OCMClassMock([AVCaptureDevice class]); | ||
OCMStub([wideAngleCamera uniqueID]).andReturn(@"0"); | ||
OCMStub([wideAngleCamera position]).andReturn(AVCaptureDevicePositionBack); | ||
|
||
AVCaptureDevice *frontFacingCamera = OCMClassMock([AVCaptureDevice class]); | ||
OCMStub([frontFacingCamera uniqueID]).andReturn(@"1"); | ||
OCMStub([frontFacingCamera position]).andReturn(AVCaptureDevicePositionFront); | ||
|
||
AVCaptureDevice *ultraWideCamera = OCMClassMock([AVCaptureDevice class]); | ||
OCMStub([ultraWideCamera uniqueID]).andReturn(@"2"); | ||
OCMStub([ultraWideCamera position]).andReturn(AVCaptureDevicePositionBack); | ||
|
||
AVCaptureDevice *telephotoCamera = OCMClassMock([AVCaptureDevice class]); | ||
OCMStub([telephotoCamera uniqueID]).andReturn(@"3"); | ||
OCMStub([telephotoCamera position]).andReturn(AVCaptureDevicePositionBack); | ||
|
||
NSMutableArray *requiredTypes = | ||
[@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] | ||
mutableCopy]; | ||
if (@available(iOS 13.0, *)) { | ||
[requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; | ||
} | ||
|
||
id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); | ||
OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:requiredTypes | ||
mediaType:AVMediaTypeVideo | ||
position:AVCaptureDevicePositionUnspecified]) | ||
.andReturn(discoverySessionMock); | ||
|
||
NSMutableArray *cameras = [NSMutableArray array]; | ||
[cameras addObjectsFromArray:@[ wideAngleCamera, frontFacingCamera, telephotoCamera ]]; | ||
if (@available(iOS 13.0, *)) { | ||
[cameras addObject:ultraWideCamera]; | ||
} | ||
OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); | ||
|
||
MockFLTThreadSafeFlutterResult *resultObject = | ||
[[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; | ||
|
||
// Set up method call | ||
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"availableCameras" | ||
arguments:nil]; | ||
|
||
[camera handleMethodCallAsync:call result:resultObject]; | ||
|
||
// Verify the result | ||
NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; | ||
if (@available(iOS 13.0, *)) { | ||
XCTAssertTrue([dictionaryResult count] == 4); | ||
} else { | ||
XCTAssertTrue([dictionaryResult count] == 3); | ||
} | ||
} | ||
- (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { | ||
CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; | ||
XCTestExpectation *expectation = | ||
[[XCTestExpectation alloc] initWithDescription:@"Result finished"]; | ||
|
||
// iPhone 8 Cameras: | ||
AVCaptureDevice *wideAngleCamera = OCMClassMock([AVCaptureDevice class]); | ||
OCMStub([wideAngleCamera uniqueID]).andReturn(@"0"); | ||
OCMStub([wideAngleCamera position]).andReturn(AVCaptureDevicePositionBack); | ||
|
||
AVCaptureDevice *frontFacingCamera = OCMClassMock([AVCaptureDevice class]); | ||
OCMStub([frontFacingCamera uniqueID]).andReturn(@"1"); | ||
OCMStub([frontFacingCamera position]).andReturn(AVCaptureDevicePositionFront); | ||
|
||
NSMutableArray *requiredTypes = | ||
[@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] | ||
mutableCopy]; | ||
if (@available(iOS 13.0, *)) { | ||
[requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; | ||
} | ||
|
||
id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); | ||
OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:requiredTypes | ||
mediaType:AVMediaTypeVideo | ||
position:AVCaptureDevicePositionUnspecified]) | ||
.andReturn(discoverySessionMock); | ||
|
||
NSMutableArray *cameras = [NSMutableArray array]; | ||
[cameras addObjectsFromArray:@[ wideAngleCamera, frontFacingCamera ]]; | ||
OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); | ||
|
||
MockFLTThreadSafeFlutterResult *resultObject = | ||
[[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; | ||
|
||
// Set up method call | ||
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"availableCameras" | ||
arguments:nil]; | ||
|
||
[camera handleMethodCallAsync:call result:resultObject]; | ||
|
||
// Verify the result | ||
NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; | ||
XCTAssertTrue([dictionaryResult count] == 2); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.