Skip to content

[native_doc_dartifier] Add initial framework for End-to-End tests #2383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 14, 2025
Merged
4 changes: 4 additions & 0 deletions .github/workflows/native_doc_dartifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

env:
PUB_ENVIRONMENT: bot.github
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}

jobs:
analyze_and_test:
Expand All @@ -39,6 +40,9 @@ jobs:
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'
- name: Run pre-test tool
run: dart run tool/prepare_dartify_test.dart
if: always() && steps.install.outcome == 'success'
- name: Run VM tests
run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
1 change: 1 addition & 0 deletions pkgs/native_doc_dartifier/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dependencies:

dev_dependencies:
dart_flutter_team_lints: ^3.5.2
jnigen: ^0.14.2
test: ^1.26.0
346 changes: 346 additions & 0 deletions pkgs/native_doc_dartifier/test/dartify_simple_cases/bindings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!

// ignore_for_file: annotate_overrides
// ignore_for_file: argument_type_not_assignable
// ignore_for_file: camel_case_extensions
// ignore_for_file: camel_case_types
// ignore_for_file: constant_identifier_names
// ignore_for_file: comment_references
// ignore_for_file: doc_directive_unknown
// ignore_for_file: file_names
// ignore_for_file: inference_failure_on_untyped_parameter
// ignore_for_file: invalid_internal_annotation
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: library_prefixes
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: no_leading_underscores_for_library_prefixes
// ignore_for_file: no_leading_underscores_for_local_identifiers
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: only_throw_errors
// ignore_for_file: overridden_fields
// ignore_for_file: prefer_double_quotes
// ignore_for_file: prefer_expression_function_bodies
// ignore_for_file: unintended_html_in_doc_comment
// ignore_for_file: unnecessary_cast
// ignore_for_file: unnecessary_non_null_assertion
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: unused_element
// ignore_for_file: unused_field
// ignore_for_file: unused_import
// ignore_for_file: unused_local_variable
// ignore_for_file: unused_shown_name
// ignore_for_file: use_super_parameters

import 'dart:core' show Object, String, bool, double, int;
import 'dart:core' as core$_;

import 'package:jni/_internal.dart' as jni$_;
import 'package:jni/jni.dart' as jni$_;

/// from: `com.Accumulator`
class Accumulator extends jni$_.JObject {
@jni$_.internal
@core$_.override
final jni$_.JObjType<Accumulator> $type;

@jni$_.internal
Accumulator.fromReference(jni$_.JReference reference)
: $type = type,
super.fromReference(reference);

static final _class = jni$_.JClass.forName(r'com/Accumulator');

/// The type which includes information such as the signature of this class.
static const nullableType = $Accumulator$NullableType();
static const type = $Accumulator$Type();
static final _id_accumulator = _class.instanceFieldId(r'accumulator', r'I');

/// from: `public int accumulator`
int get accumulator => _id_accumulator.get(this, const jni$_.jintType());

/// from: `public int accumulator`
set accumulator(int value) =>
_id_accumulator.set(this, const jni$_.jintType(), value);

static final _id_new$ = _class.constructorId(r'()V');

static final _new$ =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)
>
>('globalEnv_NewObject')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)
>();

/// from: `public void <init>()`
/// The returned object must be released after use, by calling the [release] method.
factory Accumulator() {
return Accumulator.fromReference(
_new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr).reference,
);
}

static final _id_new$1 = _class.constructorId(r'(I)V');

static final _new$1 =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Int32,)>,
)
>
>('globalEnv_NewObject')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
int,
)
>();

/// from: `public void <init>(int initialValue)`
/// The returned object must be released after use, by calling the [release] method.
factory Accumulator.new$1(int initialValue) {
return Accumulator.fromReference(
_new$1(
_class.reference.pointer,
_id_new$1 as jni$_.JMethodIDPtr,
initialValue,
).reference,
);
}

static final _id_new$2 = _class.constructorId(r'(Lcom/Accumulator;)V');

static final _new$2 =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
)
>
>('globalEnv_NewObject')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.Pointer<jni$_.Void>,
)
>();

/// from: `public void <init>(com.Accumulator other)`
/// The returned object must be released after use, by calling the [release] method.
factory Accumulator.new$2(Accumulator? other) {
final _$other = other?.reference ?? jni$_.jNullReference;
return Accumulator.fromReference(
_new$2(
_class.reference.pointer,
_id_new$2 as jni$_.JMethodIDPtr,
_$other.pointer,
).reference,
);
}

static final _id_add = _class.instanceMethodId(r'add', r'(I)V');

static final _add =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Int32,)>,
)
>
>('globalEnv_CallVoidMethod')
.asFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
int,
)
>();

/// from: `public void add(int value)`
void add(int value) {
_add(reference.pointer, _id_add as jni$_.JMethodIDPtr, value).check();
}

static final _id_add$1 = _class.instanceMethodId(r'add', r'(II)V');

static final _add$1 =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>,
)
>
>('globalEnv_CallVoidMethod')
.asFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
int,
int,
)
>();

/// from: `public void add(int value1, int value2)`
void add$1(int value1, int value2) {
_add$1(
reference.pointer,
_id_add$1 as jni$_.JMethodIDPtr,
value1,
value2,
).check();
}

static final _id_add$2 = _class.instanceMethodId(r'add', r'(III)V');

static final _add$2 =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Int32, jni$_.Int32, jni$_.Int32)>,
)
>
>('globalEnv_CallVoidMethod')
.asFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
int,
int,
int,
)
>();

/// from: `public void add(int value1, int value2, int value3)`
void add$2(int value1, int value2, int value3) {
_add$2(
reference.pointer,
_id_add$2 as jni$_.JMethodIDPtr,
value1,
value2,
value3,
).check();
}

static final _id_add$3 = _class.instanceMethodId(
r'add',
r'(Lcom/Accumulator;)V',
);

static final _add$3 =
jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>,
)
>
>('globalEnv_CallVoidMethod')
.asFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.Pointer<jni$_.Void>,
)
>();

/// from: `public void add(com.Accumulator other)`
void add$3(Accumulator? other) {
final _$other = other?.reference ?? jni$_.jNullReference;
_add$3(
reference.pointer,
_id_add$3 as jni$_.JMethodIDPtr,
_$other.pointer,
).check();
}
}

final class $Accumulator$NullableType extends jni$_.JObjType<Accumulator?> {
@jni$_.internal
const $Accumulator$NullableType();

@jni$_.internal
@core$_.override
String get signature => r'Lcom/Accumulator;';

@jni$_.internal
@core$_.override
Accumulator? fromReference(jni$_.JReference reference) =>
reference.isNull ? null : Accumulator.fromReference(reference);
@jni$_.internal
@core$_.override
jni$_.JObjType get superType => const jni$_.JObjectNullableType();

@jni$_.internal
@core$_.override
jni$_.JObjType<Accumulator?> get nullableType => this;

@jni$_.internal
@core$_.override
final superCount = 1;

@core$_.override
int get hashCode => ($Accumulator$NullableType).hashCode;

@core$_.override
bool operator ==(Object other) {
return other.runtimeType == ($Accumulator$NullableType) &&
other is $Accumulator$NullableType;
}
}

final class $Accumulator$Type extends jni$_.JObjType<Accumulator> {
@jni$_.internal
const $Accumulator$Type();

@jni$_.internal
@core$_.override
String get signature => r'Lcom/Accumulator;';

@jni$_.internal
@core$_.override
Accumulator fromReference(jni$_.JReference reference) =>
Accumulator.fromReference(reference);
@jni$_.internal
@core$_.override
jni$_.JObjType get superType => const jni$_.JObjectNullableType();

@jni$_.internal
@core$_.override
jni$_.JObjType<Accumulator?> get nullableType =>
const $Accumulator$NullableType();

@jni$_.internal
@core$_.override
final superCount = 1;

@core$_.override
int get hashCode => ($Accumulator$Type).hashCode;

@core$_.override
bool operator ==(Object other) {
return other.runtimeType == ($Accumulator$Type) &&
other is $Accumulator$Type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import '../bindings.dart';

int overloadedMethods() {
final acc1 = Accumulator();
acc1.add(10);
acc1.add$1(10, 10);
acc1.add$2(10, 10, 10);

final acc2 = Accumulator.new$1(20);
acc2.add$3(acc1);

final acc3 = Accumulator.new$2(acc2);
return acc3.accumulator;
}
Loading
Loading