Skip to content

Commit e110de0

Browse files
[native_doc_dartifier] Add initial framework for End-to-End tests (#2383)
Add e2e testing workflow that validates Dartified Java code against expected Java behavior.
1 parent c350f56 commit e110de0

File tree

9 files changed

+547
-0
lines changed

9 files changed

+547
-0
lines changed

.github/workflows/native_doc_dartifier.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
env:
1616
PUB_ENVIRONMENT: bot.github
17+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
1718

1819
jobs:
1920
analyze_and_test:
@@ -39,6 +40,9 @@ jobs:
3940
- name: Analyze code
4041
run: dart analyze --fatal-infos
4142
if: always() && steps.install.outcome == 'success'
43+
- name: Run pre-test tool
44+
run: dart run tool/prepare_dartify_test.dart
45+
if: always() && steps.install.outcome == 'success'
4246
- name: Run VM tests
4347
run: dart test --platform vm
4448
if: always() && steps.install.outcome == 'success'

pkgs/native_doc_dartifier/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ dependencies:
1616

1717
dev_dependencies:
1818
dart_flutter_team_lints: ^3.5.2
19+
jnigen: ^0.14.2
1920
test: ^1.26.0
Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
2+
3+
// ignore_for_file: annotate_overrides
4+
// ignore_for_file: argument_type_not_assignable
5+
// ignore_for_file: camel_case_extensions
6+
// ignore_for_file: camel_case_types
7+
// ignore_for_file: constant_identifier_names
8+
// ignore_for_file: comment_references
9+
// ignore_for_file: doc_directive_unknown
10+
// ignore_for_file: file_names
11+
// ignore_for_file: inference_failure_on_untyped_parameter
12+
// ignore_for_file: invalid_internal_annotation
13+
// ignore_for_file: invalid_use_of_internal_member
14+
// ignore_for_file: library_prefixes
15+
// ignore_for_file: lines_longer_than_80_chars
16+
// ignore_for_file: no_leading_underscores_for_library_prefixes
17+
// ignore_for_file: no_leading_underscores_for_local_identifiers
18+
// ignore_for_file: non_constant_identifier_names
19+
// ignore_for_file: only_throw_errors
20+
// ignore_for_file: overridden_fields
21+
// ignore_for_file: prefer_double_quotes
22+
// ignore_for_file: prefer_expression_function_bodies
23+
// ignore_for_file: unintended_html_in_doc_comment
24+
// ignore_for_file: unnecessary_cast
25+
// ignore_for_file: unnecessary_non_null_assertion
26+
// ignore_for_file: unnecessary_parenthesis
27+
// ignore_for_file: unused_element
28+
// ignore_for_file: unused_field
29+
// ignore_for_file: unused_import
30+
// ignore_for_file: unused_local_variable
31+
// ignore_for_file: unused_shown_name
32+
// ignore_for_file: use_super_parameters
33+
34+
import 'dart:core' show Object, String, bool, double, int;
35+
import 'dart:core' as core$_;
36+
37+
import 'package:jni/_internal.dart' as jni$_;
38+
import 'package:jni/jni.dart' as jni$_;
39+
40+
/// from: `com.Accumulator`
41+
class Accumulator extends jni$_.JObject {
42+
@jni$_.internal
43+
@core$_.override
44+
final jni$_.JObjType<Accumulator> $type;
45+
46+
@jni$_.internal
47+
Accumulator.fromReference(jni$_.JReference reference)
48+
: $type = type,
49+
super.fromReference(reference);
50+
51+
static final _class = jni$_.JClass.forName(r'com/Accumulator');
52+
53+
/// The type which includes information such as the signature of this class.
54+
static const nullableType = $Accumulator$NullableType();
55+
static const type = $Accumulator$Type();
56+
static final _id_accumulator = _class.instanceFieldId(r'accumulator', r'I');
57+
58+
/// from: `public int accumulator`
59+
int get accumulator => _id_accumulator.get(this, const jni$_.jintType());
60+
61+
/// from: `public int accumulator`
62+
set accumulator(int value) =>
63+
_id_accumulator.set(this, const jni$_.jintType(), value);
64+
65+
static final _id_new$ = _class.constructorId(r'()V');
66+
67+
static final _new$ =
68+
jni$_.ProtectedJniExtensions.lookup<
69+
jni$_.NativeFunction<
70+
jni$_.JniResult Function(
71+
jni$_.Pointer<jni$_.Void>,
72+
jni$_.JMethodIDPtr,
73+
)
74+
>
75+
>('globalEnv_NewObject')
76+
.asFunction<
77+
jni$_.JniResult Function(
78+
jni$_.Pointer<jni$_.Void>,
79+
jni$_.JMethodIDPtr,
80+
)
81+
>();
82+
83+
/// from: `public void <init>()`
84+
/// The returned object must be released after use, by calling the [release] method.
85+
factory Accumulator() {
86+
return Accumulator.fromReference(
87+
_new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr).reference,
88+
);
89+
}
90+
91+
static final _id_new$1 = _class.constructorId(r'(I)V');
92+
93+
static final _new$1 =
94+
jni$_.ProtectedJniExtensions.lookup<
95+
jni$_.NativeFunction<
96+
jni$_.JniResult Function(
97+
jni$_.Pointer<jni$_.Void>,
98+
jni$_.JMethodIDPtr,
99+
jni$_.VarArgs<(jni$_.Int32,)>,
100+
)
101+
>
102+
>('globalEnv_NewObject')
103+
.asFunction<
104+
jni$_.JniResult Function(
105+
jni$_.Pointer<jni$_.Void>,
106+
jni$_.JMethodIDPtr,
107+
int,
108+
)
109+
>();
110+
111+
/// from: `public void <init>(int initialValue)`
112+
/// The returned object must be released after use, by calling the [release] method.
113+
factory Accumulator.new$1(int initialValue) {
114+
return Accumulator.fromReference(
115+
_new$1(
116+
_class.reference.pointer,
117+
_id_new$1 as jni$_.JMethodIDPtr,
118+
initialValue,
119+
).reference,
120+
);
121+
}
122+
123+
static final _id_new$2 = _class.constructorId(r'(Lcom/Accumulator;)V');
124+
125+
static final _new$2 =
126+
jni$_.ProtectedJniExtensions.lookup<
127+
jni$_.NativeFunction<
128+
jni$_.JniResult Function(
129+
jni$_.Pointer<jni$_.Void>,
130+
jni$_.JMethodIDPtr,
131+
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
132+
)
133+
>
134+
>('globalEnv_NewObject')
135+
.asFunction<
136+
jni$_.JniResult Function(
137+
jni$_.Pointer<jni$_.Void>,
138+
jni$_.JMethodIDPtr,
139+
jni$_.Pointer<jni$_.Void>,
140+
)
141+
>();
142+
143+
/// from: `public void <init>(com.Accumulator other)`
144+
/// The returned object must be released after use, by calling the [release] method.
145+
factory Accumulator.new$2(Accumulator? other) {
146+
final _$other = other?.reference ?? jni$_.jNullReference;
147+
return Accumulator.fromReference(
148+
_new$2(
149+
_class.reference.pointer,
150+
_id_new$2 as jni$_.JMethodIDPtr,
151+
_$other.pointer,
152+
).reference,
153+
);
154+
}
155+
156+
static final _id_add = _class.instanceMethodId(r'add', r'(I)V');
157+
158+
static final _add =
159+
jni$_.ProtectedJniExtensions.lookup<
160+
jni$_.NativeFunction<
161+
jni$_.JThrowablePtr Function(
162+
jni$_.Pointer<jni$_.Void>,
163+
jni$_.JMethodIDPtr,
164+
jni$_.VarArgs<(jni$_.Int32,)>,
165+
)
166+
>
167+
>('globalEnv_CallVoidMethod')
168+
.asFunction<
169+
jni$_.JThrowablePtr Function(
170+
jni$_.Pointer<jni$_.Void>,
171+
jni$_.JMethodIDPtr,
172+
int,
173+
)
174+
>();
175+
176+
/// from: `public void add(int value)`
177+
void add(int value) {
178+
_add(reference.pointer, _id_add as jni$_.JMethodIDPtr, value).check();
179+
}
180+
181+
static final _id_add$1 = _class.instanceMethodId(r'add', r'(II)V');
182+
183+
static final _add$1 =
184+
jni$_.ProtectedJniExtensions.lookup<
185+
jni$_.NativeFunction<
186+
jni$_.JThrowablePtr Function(
187+
jni$_.Pointer<jni$_.Void>,
188+
jni$_.JMethodIDPtr,
189+
jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>,
190+
)
191+
>
192+
>('globalEnv_CallVoidMethod')
193+
.asFunction<
194+
jni$_.JThrowablePtr Function(
195+
jni$_.Pointer<jni$_.Void>,
196+
jni$_.JMethodIDPtr,
197+
int,
198+
int,
199+
)
200+
>();
201+
202+
/// from: `public void add(int value1, int value2)`
203+
void add$1(int value1, int value2) {
204+
_add$1(
205+
reference.pointer,
206+
_id_add$1 as jni$_.JMethodIDPtr,
207+
value1,
208+
value2,
209+
).check();
210+
}
211+
212+
static final _id_add$2 = _class.instanceMethodId(r'add', r'(III)V');
213+
214+
static final _add$2 =
215+
jni$_.ProtectedJniExtensions.lookup<
216+
jni$_.NativeFunction<
217+
jni$_.JThrowablePtr Function(
218+
jni$_.Pointer<jni$_.Void>,
219+
jni$_.JMethodIDPtr,
220+
jni$_.VarArgs<(jni$_.Int32, jni$_.Int32, jni$_.Int32)>,
221+
)
222+
>
223+
>('globalEnv_CallVoidMethod')
224+
.asFunction<
225+
jni$_.JThrowablePtr Function(
226+
jni$_.Pointer<jni$_.Void>,
227+
jni$_.JMethodIDPtr,
228+
int,
229+
int,
230+
int,
231+
)
232+
>();
233+
234+
/// from: `public void add(int value1, int value2, int value3)`
235+
void add$2(int value1, int value2, int value3) {
236+
_add$2(
237+
reference.pointer,
238+
_id_add$2 as jni$_.JMethodIDPtr,
239+
value1,
240+
value2,
241+
value3,
242+
).check();
243+
}
244+
245+
static final _id_add$3 = _class.instanceMethodId(
246+
r'add',
247+
r'(Lcom/Accumulator;)V',
248+
);
249+
250+
static final _add$3 =
251+
jni$_.ProtectedJniExtensions.lookup<
252+
jni$_.NativeFunction<
253+
jni$_.JThrowablePtr Function(
254+
jni$_.Pointer<jni$_.Void>,
255+
jni$_.JMethodIDPtr,
256+
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
257+
)
258+
>
259+
>('globalEnv_CallVoidMethod')
260+
.asFunction<
261+
jni$_.JThrowablePtr Function(
262+
jni$_.Pointer<jni$_.Void>,
263+
jni$_.JMethodIDPtr,
264+
jni$_.Pointer<jni$_.Void>,
265+
)
266+
>();
267+
268+
/// from: `public void add(com.Accumulator other)`
269+
void add$3(Accumulator? other) {
270+
final _$other = other?.reference ?? jni$_.jNullReference;
271+
_add$3(
272+
reference.pointer,
273+
_id_add$3 as jni$_.JMethodIDPtr,
274+
_$other.pointer,
275+
).check();
276+
}
277+
}
278+
279+
final class $Accumulator$NullableType extends jni$_.JObjType<Accumulator?> {
280+
@jni$_.internal
281+
const $Accumulator$NullableType();
282+
283+
@jni$_.internal
284+
@core$_.override
285+
String get signature => r'Lcom/Accumulator;';
286+
287+
@jni$_.internal
288+
@core$_.override
289+
Accumulator? fromReference(jni$_.JReference reference) =>
290+
reference.isNull ? null : Accumulator.fromReference(reference);
291+
@jni$_.internal
292+
@core$_.override
293+
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
294+
295+
@jni$_.internal
296+
@core$_.override
297+
jni$_.JObjType<Accumulator?> get nullableType => this;
298+
299+
@jni$_.internal
300+
@core$_.override
301+
final superCount = 1;
302+
303+
@core$_.override
304+
int get hashCode => ($Accumulator$NullableType).hashCode;
305+
306+
@core$_.override
307+
bool operator ==(Object other) {
308+
return other.runtimeType == ($Accumulator$NullableType) &&
309+
other is $Accumulator$NullableType;
310+
}
311+
}
312+
313+
final class $Accumulator$Type extends jni$_.JObjType<Accumulator> {
314+
@jni$_.internal
315+
const $Accumulator$Type();
316+
317+
@jni$_.internal
318+
@core$_.override
319+
String get signature => r'Lcom/Accumulator;';
320+
321+
@jni$_.internal
322+
@core$_.override
323+
Accumulator fromReference(jni$_.JReference reference) =>
324+
Accumulator.fromReference(reference);
325+
@jni$_.internal
326+
@core$_.override
327+
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
328+
329+
@jni$_.internal
330+
@core$_.override
331+
jni$_.JObjType<Accumulator?> get nullableType =>
332+
const $Accumulator$NullableType();
333+
334+
@jni$_.internal
335+
@core$_.override
336+
final superCount = 1;
337+
338+
@core$_.override
339+
int get hashCode => ($Accumulator$Type).hashCode;
340+
341+
@core$_.override
342+
bool operator ==(Object other) {
343+
return other.runtimeType == ($Accumulator$Type) &&
344+
other is $Accumulator$Type;
345+
}
346+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import '../bindings.dart';
6+
7+
int overloadedMethods() {
8+
final acc1 = Accumulator();
9+
acc1.add(10);
10+
acc1.add$1(10, 10);
11+
acc1.add$2(10, 10, 10);
12+
13+
final acc2 = Accumulator.new$1(20);
14+
acc2.add$3(acc1);
15+
16+
final acc3 = Accumulator.new$2(acc2);
17+
return acc3.accumulator;
18+
}

0 commit comments

Comments
 (0)