Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP for cameraUpdate, updating native tests
  • Loading branch information
stuartmorgan-g committed Nov 13, 2024
commit f3b73b0e4ef03265df4697016ec6c8d8ad6d1dd2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
528F16832C62941000148160 /* FGMClusterManagersControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 528F16822C62941000148160 /* FGMClusterManagersControllerTests.m */; };
528F16872C62952700148160 /* ExtractIconFromDataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 528F16862C62952700148160 /* ExtractIconFromDataTests.m */; };
6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
Expand Down Expand Up @@ -99,6 +100,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
B3A7FA04ABB7B84780729949 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -240,13 +242,15 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
BB6BD9A1101E970BEF85B6D2 /* [CP] Copy Pods Resources */,
A7D3A643E249522B15BA2B1D /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Runner;
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -322,6 +326,9 @@
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -412,24 +419,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
A7D3A643E249522B15BA2B1D /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
BB6BD9A1101E970BEF85B6D2 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -830,6 +819,20 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Prepare Flutter Framework Script"
scriptText = "/bin/sh &quot;$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh&quot; prepare&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ - (void)testCameraUpdateFromArrayNewCameraPosition {
@"newCameraPosition", @{@"target" : @[ @1, @2 ], @"zoom" : @3, @"bearing" : @4, @"tilt" : @5}
];
id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);
[[classMockCameraUpdate expect]
setCamera:[FLTGoogleMapJSONConversions cameraPostionFromDictionary:channelValue[1]]];
[classMockCameraUpdate stopMocking];
Expand All @@ -226,98 +226,106 @@ - (void)testCameraUpdateFromArrayNewCameraPosition {
// verified.
//
// The code in below test uses the 2nd approach.
- (void)skip_testCameraUpdateFromArrayNewLatLong {
NSArray *channelValue = @[ @"newLatLng", @[ @1, @2 ] ];
- (void)skip_testCameraUpdateFromNewLatLong {
const CGFloat lat = 1;
const CGFloat lng = 2;
FGMPlatformCameraUpdateNewLatLng* platformUpdate =[FGMPlatformCameraUpdateNewLatLng makeWithLatLng:[FGMPlatformLatLng makeWithLatitude:lat longitude:lng]];

GMSCameraUpdate *update = [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
options.frame = CGRectZero;
options.camera = [GMSCameraPosition cameraWithTarget:CLLocationCoordinate2DMake(5, 6) zoom:1];
GMSMapView *mapView = [[GMSMapView alloc] initWithOptions:options];
[mapView moveCamera:update];
const CGFloat accuracy = 0.001;
XCTAssertEqualWithAccuracy(mapView.camera.target.latitude, 1,
XCTAssertEqualWithAccuracy(mapView.camera.target.latitude, lat,
accuracy); // mapView.camera.target.latitude is still 5.
XCTAssertEqualWithAccuracy(mapView.camera.target.longitude, 2,
XCTAssertEqualWithAccuracy(mapView.camera.target.longitude, lng,
accuracy); // mapView.camera.target.longitude is still 6.
}

- (void)testCameraUpdateFromArrayNewLatLngBounds {
- (void)testCameraUpdateFromNewLatLngBounds {
NSArray<NSNumber *> *latlong1 = @[ @1, @2 ];
NSArray<NSNumber *> *latlong2 = @[ @(3), @(4) ];
GMSCoordinateBounds *bounds =
[FLTGoogleMapJSONConversions coordinateBoundsFromLatLongs:@[ latlong1, latlong2 ]];

const CGFloat padding = 20;
NSArray *channelValue = @[ @"newLatLngBounds", @[ latlong1, latlong2 ], @20 ];
FGMPlatformCameraUpdateNewLatLngBounds* platformUpdate =[FGMPlatformCameraUpdateNewLatLngBounds makeWithBounds:FGMGetPigeonLatLngBoundsForCoordinateBounds(bounds) padding:padding];
id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] fitBounds:bounds withPadding:20];
[[classMockCameraUpdate expect] fitBounds:bounds withPadding:padding];
[classMockCameraUpdate stopMocking];
}

- (void)testCameraUpdateFromArrayNewLatLngZoom {
- (void)testCameraUpdateFromNewLatLngZoom {
const CGFloat lat = 1;
const CGFloat lng = 2;
const CGFloat zoom = 3;
FGMPlatformCameraUpdateNewLatLngZoom *platformUpdate = [FGMPlatformCameraUpdateNewLatLngZoom makeWithLatLng:<#(nonnull FGMPlatformLatLng *)#> zoom:<#(double)#>
NSArray *channelValue = @[ @"newLatLngZoom", @[ @1, @2 ], @3 ];

id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] setTarget:CLLocationCoordinate2DMake(1, 2) zoom:3];
[[classMockCameraUpdate expect] setTarget:CLLocationCoordinate2DMake(lat, lng) zoom:zoom];
[classMockCameraUpdate stopMocking];
}

- (void)testCameraUpdateFromArrayScrollBy {
- (void)testCameraUpdateFromScrollBy {
NSArray *channelValue = @[ @"scrollBy", @1, @2 ];

id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] scrollByX:1 Y:2];
[classMockCameraUpdate stopMocking];
}

- (void)testCameraUpdateFromArrayZoomBy {
- (void)testCameraUpdateFromZoomBy {
NSArray *channelValueNoPoint = @[ @"zoomBy", @1 ];

id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] zoomBy:1];

NSArray *channelValueWithPoint = @[ @"zoomBy", @1, @[ @2, @3 ] ];

[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueWithPoint];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] zoomBy:1 atPoint:CGPointMake(2, 3)];
[classMockCameraUpdate stopMocking];
}

- (void)testCameraUpdateFromArrayZoomIn {
- (void)testCameraUpdateFromZoomIn {
NSArray *channelValueNoPoint = @[ @"zoomIn" ];

id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] zoomIn];
[classMockCameraUpdate stopMocking];
}

- (void)testCameraUpdateFromArrayZoomOut {
- (void)testCameraUpdateFromZoomOut {
NSArray *channelValueNoPoint = @[ @"zoomOut" ];

id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] zoomOut];
[classMockCameraUpdate stopMocking];
}

- (void)testCameraUpdateFromArrayZoomTo {
- (void)testCameraUpdateFromZoomTo {
NSArray *channelValueNoPoint = @[ @"zoomTo", @1 ];

id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]);
[FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint];
GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate([FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]);

[[classMockCameraUpdate expect] zoomTo:1];
[classMockCameraUpdate stopMocking];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
5B5EF9A6C72A03092BDA553E /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28D4666EF03E57DB7D03E916 /* Pods_RunnerTests.framework */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
Expand Down Expand Up @@ -78,6 +79,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
AF2E6994ED025F4BCE652A48 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -196,13 +198,15 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
BB6BD9A1101E970BEF85B6D2 /* [CP] Copy Pods Resources */,
851CD952D11C6D91E216A90F /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Runner;
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -255,6 +259,9 @@
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -340,24 +347,6 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
851CD952D11C6D91E216A90F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -694,6 +683,20 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ extern GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type)
extern FGMPlatformCluster *FGMGetPigeonCluster(GMUStaticCluster *cluster,
NSString *clusterManagerIdentifier);

extern GMSCameraUpdate *_Nullable FGMGetCameraUpdateForPigeonCameraUpdate(
FGMPlatformCameraUpdate *update);

@interface FLTGoogleMapJSONConversions : NSObject

extern NSString *const kHeatmapsToAddKey;
Expand All @@ -72,7 +75,6 @@ extern NSString *const kHeatmapGradientColorMapSizeKey;
+ (NSArray<NSArray<CLLocation *> *> *)holesFromPointsArray:(NSArray *)data;
+ (nullable GMSCameraPosition *)cameraPostionFromDictionary:(nullable NSDictionary *)channelValue;
+ (GMSCoordinateBounds *)coordinateBoundsFromLatLongs:(NSArray *)latlongs;
+ (nullable GMSCameraUpdate *)cameraUpdateFromArray:(NSArray *)channelValue;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason these are moved instead of just renamed is that I'm chipping away at the functions-as-bag-of-static-methods-on-a-fake-class approach that the JSON conversion methods used, to the IMO-cleaner functions-as-functions approach. Once the conversion is complete this class will be gone.

+ (nullable GMUWeightedLatLng *)weightedLatLngFromArray:(NSArray<id> *)data;
+ (NSArray<id> *)arrayFromWeightedLatLng:(GMUWeightedLatLng *)weightedLatLng;
+ (NSArray<GMUWeightedLatLng *> *)weightedDataFromArray:(NSArray<NSArray<id> *> *)data;
Expand Down
Loading