Skip to content

Commit 4fb1a51

Browse files
Merge branch 'main' into camera-windows-example-deprecation
2 parents 88d86e1 + 3caa48b commit 4fb1a51

File tree

11 files changed

+104
-61
lines changed

11 files changed

+104
-61
lines changed

.ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ platform_properties:
9595
[
9696
{"dependency": "ruby", "version": "ruby_3.1-pod_1.13"}
9797
]
98-
os: Mac-14|Mac-15.5
98+
os: Mac-15.5|Mac-15.7
9999
device_type: none
100100
cpu: arm64
101101
$flutter/osx_sdk : >-
@@ -108,7 +108,7 @@ platform_properties:
108108
[
109109
{"dependency": "ruby", "version": "ruby_3.1-pod_1.13"}
110110
]
111-
os: Mac-14|Mac-15.5
111+
os: Mac-15.5|Mac-15.7
112112
device_type: none
113113
cpu: x86
114114
$flutter/osx_sdk : >-

packages/go_router/test/extra_codec_test.dart

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:convert';
77
import 'package:flutter/material.dart';
88
import 'package:flutter_test/flutter_test.dart';
99
import 'package:go_router/go_router.dart';
10+
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1011

1112
import 'test_helpers.dart';
1213

@@ -52,33 +53,40 @@ void main() {
5253
expect(find.text(initialString), findsOneWidget);
5354
});
5455

55-
testWidgets('Restores state correctly', (WidgetTester tester) async {
56-
const String initialString = 'some string';
57-
const String empty = 'empty';
58-
final List<RouteBase> routes = <RouteBase>[
59-
GoRoute(
60-
path: '/',
61-
builder: (_, GoRouterState state) {
62-
return Text((state.extra as ComplexData?)?.data ?? empty);
63-
},
64-
),
65-
];
56+
testWidgets(
57+
'Restores state correctly',
58+
(WidgetTester tester) async {
59+
const String initialString = 'some string';
60+
const String empty = 'empty';
61+
final List<RouteBase> routes = <RouteBase>[
62+
GoRoute(
63+
path: '/',
64+
builder: (_, GoRouterState state) {
65+
return Text((state.extra as ComplexData?)?.data ?? empty);
66+
},
67+
),
68+
];
6669

67-
await createRouter(
68-
routes,
69-
tester,
70-
initialExtra: ComplexData(initialString),
71-
restorationScopeId: 'test',
72-
extraCodec: ComplexDataCodec(),
73-
);
74-
expect(find.text(initialString), findsOneWidget);
70+
await createRouter(
71+
routes,
72+
tester,
73+
initialExtra: ComplexData(initialString),
74+
restorationScopeId: 'test',
75+
extraCodec: ComplexDataCodec(),
76+
);
77+
expect(find.text(initialString), findsOneWidget);
7578

76-
await tester.restartAndRestore();
77-
addTearDown(tester.binding.restorationManager.dispose);
79+
await tester.restartAndRestore();
7880

79-
await tester.pumpAndSettle();
80-
expect(find.text(initialString), findsOneWidget);
81-
});
81+
await tester.pumpAndSettle();
82+
expect(find.text(initialString), findsOneWidget);
83+
},
84+
// TODO(hgraceb): Remove when minimum flutter version includes
85+
// https://github.com/flutter/flutter/pull/176519
86+
experimentalLeakTesting: LeakTesting.settings.withIgnored(
87+
classes: const <String>['TestRestorationManager', 'RestorationBucket'],
88+
),
89+
);
8290
}
8391

8492
class ComplexData {

packages/pigeon/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 26.0.5
2+
3+
* [kotlin] Serialize custom enums as `Long` instead of `Int` to avoid `ClassCastException` on decoding.
4+
15
## 26.0.4
26

37
* Adds compatibility with `analyzer` 8.x.

packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private open class MessagesPigeonCodec : StandardMessageCodec() {
142142
when (value) {
143143
is Code -> {
144144
stream.write(129)
145-
writeValue(stream, value.raw)
145+
writeValue(stream, value.raw.toLong())
146146
}
147147
is MessageData -> {
148148
stream.write(130)

packages/pigeon/lib/src/generator_tools.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'generator.dart';
1515
/// The current version of pigeon.
1616
///
1717
/// This must match the version in pubspec.yaml.
18-
const String pigeonVersion = '26.0.4';
18+
const String pigeonVersion = '26.0.5';
1919

2020
/// Read all the content from [stdin] to a String.
2121
String readStdin() {

packages/pigeon/lib/src/kotlin/kotlin_generator.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ class KotlinGenerator extends StructuredGenerator<InternalKotlinOptions> {
475475

476476
void writeEncodeLogic(EnumeratedType customType) {
477477
final String encodeString =
478-
customType.type == CustomTypes.customClass ? 'toList()' : 'raw';
478+
customType.type == CustomTypes.customClass
479+
? 'toList()'
480+
: 'raw.toLong()';
479481
final String valueString =
480482
customType.enumeration < maximumCodecFieldKey
481483
? 'value.$encodeString'

packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,11 @@ private open class CoreTestsPigeonCodec : StandardMessageCodec() {
704704
when (value) {
705705
is AnEnum -> {
706706
stream.write(129)
707-
writeValue(stream, value.raw)
707+
writeValue(stream, value.raw.toLong())
708708
}
709709
is AnotherEnum -> {
710710
stream.write(130)
711-
writeValue(stream, value.raw)
711+
writeValue(stream, value.raw.toLong())
712712
}
713713
is UnusedClass -> {
714714
stream.write(131)

packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/EventChannelTests.gen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,11 @@ private open class EventChannelTestsPigeonCodec : StandardMessageCodec() {
477477
when (value) {
478478
is EventEnum -> {
479479
stream.write(129)
480-
writeValue(stream, value.raw)
480+
writeValue(stream, value.raw.toLong())
481481
}
482482
is AnotherEventEnum -> {
483483
stream.write(130)
484-
writeValue(stream, value.raw)
484+
writeValue(stream, value.raw.toLong())
485485
}
486486
is EventAllNullableTypes -> {
487487
stream.write(131)

packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/ProxyApiTests.gen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ private open class ProxyApiTestsPigeonCodec : StandardMessageCodec() {
560560
when (value) {
561561
is ProxyApiTestEnum -> {
562562
stream.write(129)
563-
writeValue(stream, value.raw)
563+
writeValue(stream, value.raw.toLong())
564564
}
565565
else -> super.writeValue(stream, value)
566566
}

packages/pigeon/platform_tests/test_plugin/android/src/test/kotlin/com/example/test_plugin/AllDatatypesTest.kt

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,52 @@ internal class AllDatatypesTest {
4646
}
4747

4848
@Test
49-
fun testHasValues() {
49+
fun testRoundtripNullValues() {
50+
val everything = AllNullableTypes()
51+
val codec = FlutterIntegrationCoreApi.codec
52+
val encoded = codec.encodeMessage(everything)
53+
encoded?.rewind()
54+
val decoded = codec.decodeMessage(encoded)
55+
assertEquals(everything, decoded)
56+
}
57+
58+
fun getFullyPopulatedAllNullableTypes(): AllNullableTypes {
5059
val stringList = listOf("string", "another one")
51-
val everything =
52-
AllNullableTypes(
53-
aNullableBool = false,
54-
aNullableInt = 1234L,
55-
aNullableDouble = 2.0,
56-
aNullableString = "hello",
57-
aNullableByteArray = byteArrayOf(1, 2, 3, 4),
58-
aNullable4ByteArray = intArrayOf(1, 2, 3, 4),
59-
aNullable8ByteArray = longArrayOf(1, 2, 3, 4),
60-
aNullableFloatArray = doubleArrayOf(0.5, 0.25, 1.5, 1.25),
61-
aNullableObject = 0,
62-
list = listOf(1, 2, 3),
63-
stringList = stringList,
64-
boolList = listOf(true, false),
65-
intList = listOf(1, 2),
66-
doubleList = listOf(1.1, 2.2),
67-
objectList = listOf(1, 2, 3),
68-
listList = listOf(stringList, stringList.toList()),
69-
mapList = listOf(mapOf("hello" to 1234), mapOf("hello" to 1234)),
70-
map = mapOf("hello" to 1234),
71-
stringMap = mapOf("hello" to "you"),
72-
intMap = mapOf(1L to 0L),
73-
objectMap = mapOf("hello" to 1234),
74-
listMap = mapOf(1L to stringList),
75-
mapMap = mapOf(1L to mapOf()))
60+
61+
return AllNullableTypes(
62+
aNullableBool = false,
63+
aNullableInt = 1234L,
64+
aNullableDouble = 2.0,
65+
aNullableString = "hello",
66+
aNullableByteArray = byteArrayOf(1, 2, 3, 4),
67+
aNullable4ByteArray = intArrayOf(1, 2, 3, 4),
68+
aNullable8ByteArray = longArrayOf(1, 2, 3, 4),
69+
aNullableFloatArray = doubleArrayOf(0.5, 0.25, 1.5, 1.25),
70+
aNullableEnum = AnEnum.TWO,
71+
anotherNullableEnum = AnotherEnum.JUST_IN_CASE,
72+
aNullableObject = 0,
73+
list = listOf(1, 2, 3),
74+
stringList = stringList,
75+
boolList = listOf(true, false),
76+
enumList = listOf(AnEnum.ONE, AnEnum.TWO),
77+
intList = listOf(1, 2),
78+
doubleList = listOf(1.1, 2.2),
79+
objectList = listOf(1, 2, 3),
80+
listList = listOf(stringList, stringList.toList()),
81+
mapList = listOf(mapOf("hello" to 1234), mapOf("hello" to 1234)),
82+
map = mapOf("hello" to 1234),
83+
stringMap = mapOf("hello" to "you"),
84+
intMap = mapOf(1L to 0L),
85+
objectMap = mapOf("hello" to 1234),
86+
enumMap =
87+
mapOf(AnEnum.ONE to AnEnum.FORTY_TWO, AnEnum.TWO to AnEnum.FOUR_HUNDRED_TWENTY_TWO),
88+
listMap = mapOf(1L to stringList),
89+
mapMap = mapOf(1L to mapOf()))
90+
}
91+
92+
@Test
93+
fun testHasValues() {
94+
val everything = getFullyPopulatedAllNullableTypes()
7695
val binaryMessenger = mockk<BinaryMessenger>()
7796
val api = FlutterIntegrationCoreApi(binaryMessenger)
7897

@@ -97,6 +116,16 @@ internal class AllDatatypesTest {
97116
assertTrue(didCall)
98117
}
99118

119+
@Test
120+
fun testRoundtripHasValues() {
121+
val everything = getFullyPopulatedAllNullableTypes()
122+
val codec = FlutterIntegrationCoreApi.codec
123+
val encoded = codec.encodeMessage(everything)
124+
encoded?.rewind()
125+
val decoded = codec.decodeMessage(encoded)
126+
assertEquals(everything, decoded)
127+
}
128+
100129
private val correctList = listOf<Any?>("a", 2, "three")
101130
private val matchingList = correctList.toMutableList()
102131
private val differentList = listOf<Any?>("a", 2, "three", 4.0)

0 commit comments

Comments
 (0)