Skip to content

Commit 7decdad

Browse files
committed
feat: add animateCamera tests
1 parent 223d177 commit 7decdad

4 files changed

Lines changed: 85 additions & 8 deletions

File tree

example/e2e/map.test.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,56 +41,63 @@ describe('Map view tests', () => {
4141
await expectSuccess();
4242
});
4343

44-
it('MT03 - initialize map and test camera tilt bearing zoom', async () => {
44+
it('MT03 - initialize map and test animate camera', async () => {
45+
await selectTestByName('testAnimateCamera');
46+
await waitForTestToFinish();
47+
await expectNoErrors();
48+
await expectSuccess();
49+
});
50+
51+
it('MT04 - initialize map and test camera tilt bearing zoom', async () => {
4552
await selectTestByName('testTiltZoomBearingCamera');
4653
await waitForTestToFinish();
4754
await expectNoErrors();
4855
await expectSuccess();
4956
});
5057

51-
it('MT04 - test adding and removing markers', async () => {
58+
it('MT05 - test adding and removing markers', async () => {
5259
await selectTestByName('testMapMarkers');
5360
await waitForTestToFinish();
5461
await expectNoErrors();
5562
await expectSuccess();
5663
});
5764

58-
it('MT05 - test adding and removing circles', async () => {
65+
it('MT06 - test adding and removing circles', async () => {
5966
await selectTestByName('testMapCircles');
6067
await waitForTestToFinish();
6168
await expectNoErrors();
6269
await expectSuccess();
6370
});
6471

65-
it('MT06 - test adding and removing polylines', async () => {
72+
it('MT07 - test adding and removing polylines', async () => {
6673
await selectTestByName('testMapPolylines');
6774
await waitForTestToFinish();
6875
await expectNoErrors();
6976
await expectSuccess();
7077
});
7178

72-
it('MT07 - test adding and removing polygons', async () => {
79+
it('MT08 - test adding and removing polygons', async () => {
7380
await selectTestByName('testMapPolygons');
7481
await waitForTestToFinish();
7582
await expectNoErrors();
7683
await expectSuccess();
7784
});
7885

79-
it('MT08 - test adding and removing ground overlays', async () => {
86+
it('MT09 - test adding and removing ground overlays', async () => {
8087
await selectTestByName('testMapGroundOverlays');
8188
await waitForTestToFinish();
8289
await expectNoErrors();
8390
await expectSuccess();
8491
});
8592

86-
it('MT09 - test setting map style via JSON', async () => {
93+
it('MT10 - test setting map style via JSON', async () => {
8794
await selectTestByName('testMapStyle');
8895
await waitForTestToFinish();
8996
await expectNoErrors();
9097
await expectSuccess();
9198
});
9299

93-
it('MT10 - test min and max zoom level constraints', async () => {
100+
it('MT11 - test min and max zoom level constraints', async () => {
94101
await selectTestByName('testMinMaxZoomLevels');
95102
await waitForTestToFinish();
96103
await expectNoErrors();

example/src/controls/mapsControls.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ const MapsControls: React.FC<MapControlsProps> = ({
142142
});
143143
};
144144

145+
const animateCamera = () => {
146+
mapViewController.animateCamera({
147+
target: { lat: Number(latitude), lng: Number(longitude) },
148+
zoom: 1,
149+
bearing: 60,
150+
tilt: 60,
151+
});
152+
};
153+
145154
const setMapType = (newMapType: MapType) => {
146155
onMapTypeChange?.(newMapType);
147156
};
@@ -410,6 +419,7 @@ const MapsControls: React.FC<MapControlsProps> = ({
410419
keyboardType="numeric"
411420
/>
412421
<ExampleAppButton title="Move camera" onPress={moveCamera} />
422+
<ExampleAppButton title="Animate camera" onPress={animateCamera} />
413423
<ExampleAppButton
414424
title="Zoom in"
415425
onPress={() => {

example/src/screens/IntegrationTestsScreen.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
testRouteSegments,
4343
testGetCurrentTimeAndDistance,
4444
testMoveCamera,
45+
testAnimateCamera,
4546
testTiltZoomBearingCamera,
4647
testMapMarkers,
4748
testMapCircles,
@@ -279,6 +280,9 @@ const IntegrationTestsScreen = () => {
279280
case 'testMoveCamera':
280281
await testMoveCamera(getTestTools());
281282
break;
283+
case 'testAnimateCamera':
284+
await testAnimateCamera(getTestTools());
285+
break;
282286
case 'testTiltZoomBearingCamera':
283287
await testTiltZoomBearingCamera(getTestTools());
284288
break;
@@ -451,6 +455,13 @@ const IntegrationTestsScreen = () => {
451455
}}
452456
testID="testMoveCamera"
453457
/>
458+
<ExampleAppButton
459+
title="testAnimateCamera"
460+
onPress={() => {
461+
runTest('testAnimateCamera');
462+
}}
463+
testID="testAnimateCamera"
464+
/>
454465
<ExampleAppButton
455466
title="testTiltZoomBearingCamera"
456467
onPress={() => {

example/src/screens/integration_tests/integration_test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,55 @@ export const testMoveCamera = async (testTools: TestTools) => {
814814
passTest();
815815
};
816816

817+
export const testAnimateCamera = async (testTools: TestTools) => {
818+
const { mapViewController, passTest, failTest, expectFalseError } = testTools;
819+
if (!mapViewController) {
820+
return failTest('mapViewController was expected to exist');
821+
}
822+
823+
// Animate camera to Hong Kong
824+
await mapViewController.animateCamera({
825+
target: {
826+
lat: 22.2987849,
827+
lng: 114.1719271,
828+
},
829+
});
830+
831+
const hongKongPosition = await waitForCondition(
832+
() => mapViewController.getCameraPosition(),
833+
position =>
834+
roundDown(position.target.lat) === 22 &&
835+
roundDown(position.target.lng) === 114
836+
);
837+
if (!hongKongPosition) {
838+
expectFalseError(
839+
'roundDown(hongKongPosition.target.lat) !== 22 || roundDown(hongKongPosition.target.lng) !== 114'
840+
);
841+
}
842+
843+
// Animate camera to Tokyo
844+
await mapViewController.animateCamera({
845+
target: {
846+
lat: 35.6805707,
847+
lng: 139.7658596,
848+
},
849+
});
850+
851+
const tokyoPosition = await waitForCondition(
852+
() => mapViewController.getCameraPosition(),
853+
position =>
854+
roundDown(position.target.lat) === 35 &&
855+
roundDown(position.target.lng) === 139
856+
);
857+
if (!tokyoPosition) {
858+
expectFalseError(
859+
'roundDown(tokyoPosition.target.lat) !== 35 || roundDown(tokyoPosition.target.lng) !== 139'
860+
);
861+
}
862+
863+
passTest();
864+
};
865+
817866
export const testTiltZoomBearingCamera = async (testTools: TestTools) => {
818867
const { mapViewController, passTest, failTest, expectFalseError } = testTools;
819868
if (!mapViewController) {

0 commit comments

Comments
 (0)