mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 05:27:23 +00:00
update android build
This commit is contained in:
4
analysis_options.yaml
Normal file
4
analysis_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
|
# Additional information about this file can be found at
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
9
android/.gitignore
vendored
Normal file
9
android/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/libraries
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.cxx
|
75
android/build.gradle
Normal file
75
android/build.gradle
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
group 'soko.ekibun.flutter_qjs'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.7.10'
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:8.0.1'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
android {
|
||||||
|
if (project.android.hasProperty("namespace")) {
|
||||||
|
namespace 'soko.ekibun.flutter_qjs'
|
||||||
|
}
|
||||||
|
|
||||||
|
compileSdk 34
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path "src/main/cxx/CMakeLists.txt"
|
||||||
|
version "3.10.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
test.java.srcDirs += 'src/test/kotlin'
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 19
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation 'org.jetbrains.kotlin:kotlin-test'
|
||||||
|
testImplementation 'org.mockito:mockito-core:5.0.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
testOptions {
|
||||||
|
unitTests.all {
|
||||||
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
testLogging {
|
||||||
|
events "passed", "skipped", "failed", "standardOut", "standardError"
|
||||||
|
outputs.upToDateWhen {false}
|
||||||
|
showStandardStreams = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
android/settings.gradle
Normal file
1
android/settings.gradle
Normal file
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'flutter_qjs'
|
3
android/src/main/AndroidManifest.xml
Normal file
3
android/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="soko.ekibun.flutter_qjs">
|
||||||
|
</manifest>
|
@@ -0,0 +1,35 @@
|
|||||||
|
package soko.ekibun.flutter_qjs
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull
|
||||||
|
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||||
|
import io.flutter.plugin.common.MethodChannel.Result
|
||||||
|
|
||||||
|
/** FlutterQjsPlugin */
|
||||||
|
class FlutterQjsPlugin: FlutterPlugin, MethodCallHandler {
|
||||||
|
/// The MethodChannel that will the communication between Flutter and native Android
|
||||||
|
///
|
||||||
|
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
|
||||||
|
/// when the Flutter Engine is detached from the Activity
|
||||||
|
private lateinit var channel : MethodChannel
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_qjs")
|
||||||
|
channel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: Result) {
|
||||||
|
if (call.method == "getPlatformVersion") {
|
||||||
|
result.success("Android ${android.os.Build.VERSION.RELEASE}")
|
||||||
|
} else {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
channel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,27 @@
|
|||||||
|
package soko.ekibun.flutter_qjs
|
||||||
|
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import kotlin.test.Test
|
||||||
|
import org.mockito.Mockito
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This demonstrates a simple unit test of the Kotlin portion of this plugin's implementation.
|
||||||
|
*
|
||||||
|
* Once you have built the plugin's example app, you can run these tests from the command
|
||||||
|
* line by running `./gradlew testDebugUnitTest` in the `example/android/` directory, or
|
||||||
|
* you can run them directly from IDEs that support JUnit such as Android Studio.
|
||||||
|
*/
|
||||||
|
|
||||||
|
internal class FlutterQjsPluginTest {
|
||||||
|
@Test
|
||||||
|
fun onMethodCall_getPlatformVersion_returnsExpectedValue() {
|
||||||
|
val plugin = FlutterQjsPlugin()
|
||||||
|
|
||||||
|
val call = MethodCall("getPlatformVersion", null)
|
||||||
|
val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java)
|
||||||
|
plugin.onMethodCall(call, mockResult)
|
||||||
|
|
||||||
|
Mockito.verify(mockResult).success("Android " + android.os.Build.VERSION.RELEASE)
|
||||||
|
}
|
||||||
|
}
|
26
example/ios/RunnerTests/RunnerTests.swift
Normal file
26
example/ios/RunnerTests/RunnerTests.swift
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Flutter
|
||||||
|
import UIKit
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
@testable import flutter_qjs
|
||||||
|
|
||||||
|
// This demonstrates a simple unit test of the Swift portion of this plugin's implementation.
|
||||||
|
//
|
||||||
|
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
|
||||||
|
|
||||||
|
class RunnerTests: XCTestCase {
|
||||||
|
|
||||||
|
func testGetPlatformVersion() {
|
||||||
|
let plugin = FlutterQjsPlugin()
|
||||||
|
|
||||||
|
let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: [])
|
||||||
|
|
||||||
|
let resultExpectation = expectation(description: "result block must be called.")
|
||||||
|
plugin.handle(call) { result in
|
||||||
|
XCTAssertEqual(result as! String, "iOS " + UIDevice.current.systemVersion)
|
||||||
|
resultExpectation.fulfill()
|
||||||
|
}
|
||||||
|
waitForExpectations(timeout: 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -7,13 +7,9 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <flutter_qjs/flutter_qjs_plugin.h>
|
#include <flutter_qjs/flutter_qjs_plugin.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) flutter_qjs_registrar =
|
g_autoptr(FlPluginRegistrar) flutter_qjs_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterQjsPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterQjsPlugin");
|
||||||
flutter_qjs_plugin_register_with_registrar(flutter_qjs_registrar);
|
flutter_qjs_plugin_register_with_registrar(flutter_qjs_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
|
||||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
flutter_qjs
|
flutter_qjs
|
||||||
sqlite3_flutter_libs
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
@@ -6,9 +6,7 @@ import FlutterMacOS
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import flutter_qjs
|
import flutter_qjs
|
||||||
import sqlite3_flutter_libs
|
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FlutterQjsPlugin.register(with: registry.registrar(forPlugin: "FlutterQjsPlugin"))
|
FlutterQjsPlugin.register(with: registry.registrar(forPlugin: "FlutterQjsPlugin"))
|
||||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
|
||||||
}
|
}
|
||||||
|
27
example/macos/RunnerTests/RunnerTests.swift
Normal file
27
example/macos/RunnerTests/RunnerTests.swift
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import FlutterMacOS
|
||||||
|
import Cocoa
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
@testable import flutter_qjs
|
||||||
|
|
||||||
|
// This demonstrates a simple unit test of the Swift portion of this plugin's implementation.
|
||||||
|
//
|
||||||
|
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
|
||||||
|
|
||||||
|
class RunnerTests: XCTestCase {
|
||||||
|
|
||||||
|
func testGetPlatformVersion() {
|
||||||
|
let plugin = FlutterQjsPlugin()
|
||||||
|
|
||||||
|
let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: [])
|
||||||
|
|
||||||
|
let resultExpectation = expectation(description: "result block must be called.")
|
||||||
|
plugin.handle(call) { result in
|
||||||
|
XCTAssertEqual(result as! String,
|
||||||
|
"macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
|
||||||
|
resultExpectation.fulfill()
|
||||||
|
}
|
||||||
|
waitForExpectations(timeout: 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -90,14 +90,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.0"
|
version: "0.7.0"
|
||||||
js:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: js
|
|
||||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.6.7"
|
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -167,22 +159,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.10.0"
|
||||||
sqlite3:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: sqlite3
|
|
||||||
sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.4.2"
|
|
||||||
sqlite3_flutter_libs:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: sqlite3_flutter_libs
|
|
||||||
sha256: d6c31c8511c441d1f12f20b607343df1afe4eddf24a1cf85021677c8eea26060
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.5.20"
|
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -240,5 +216,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "13.0.0"
|
version: "13.0.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.3.0 <4.0.0"
|
dart: ">=3.3.0-279.1.beta <4.0.0"
|
||||||
flutter: ">=3.0.0"
|
flutter: ">=3.0.0"
|
||||||
|
27
example/test/widget_test.dart
Normal file
27
example/test/widget_test.dart
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// This is a basic Flutter widget test.
|
||||||
|
//
|
||||||
|
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||||
|
// utility in the flutter_test package. For example, you can send tap and scroll
|
||||||
|
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||||
|
// tree, read text, and verify that the values of widget properties are correct.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'package:flutter_qjs_example/main.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Verify Platform version', (WidgetTester tester) async {
|
||||||
|
// Build our app and trigger a frame.
|
||||||
|
await tester.pumpWidget(const MyApp());
|
||||||
|
|
||||||
|
// Verify that platform version is retrieved.
|
||||||
|
expect(
|
||||||
|
find.byWidgetPredicate(
|
||||||
|
(Widget widget) => widget is Text &&
|
||||||
|
widget.data!.startsWith('Running on:'),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
@@ -7,11 +7,8 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <flutter_qjs/flutter_qjs_plugin.h>
|
#include <flutter_qjs/flutter_qjs_plugin.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FlutterQjsPluginRegisterWithRegistrar(
|
FlutterQjsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterQjsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterQjsPlugin"));
|
||||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
flutter_qjs
|
flutter_qjs
|
||||||
sqlite3_flutter_libs
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
19
ios/Classes/FlutterQjsPlugin.swift
Normal file
19
ios/Classes/FlutterQjsPlugin.swift
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import Flutter
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
public class FlutterQjsPlugin: NSObject, FlutterPlugin {
|
||||||
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||||
|
let channel = FlutterMethodChannel(name: "flutter_qjs", binaryMessenger: registrar.messenger())
|
||||||
|
let instance = FlutterQjsPlugin()
|
||||||
|
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
|
switch call.method {
|
||||||
|
case "getPlatformVersion":
|
||||||
|
result("iOS " + UIDevice.current.systemVersion)
|
||||||
|
default:
|
||||||
|
result(FlutterMethodNotImplemented)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
linux/flutter_qjs_plugin_private.h
Normal file
10
linux/flutter_qjs_plugin_private.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include <flutter_linux/flutter_linux.h>
|
||||||
|
|
||||||
|
#include "include/flutter_qjs/flutter_qjs_plugin.h"
|
||||||
|
|
||||||
|
// This file exposes some plugin internals for unit testing. See
|
||||||
|
// https://github.com/flutter/flutter/issues/88724 for current limitations
|
||||||
|
// in the unit-testable API.
|
||||||
|
|
||||||
|
// Handles the getPlatformVersion method call.
|
||||||
|
FlMethodResponse *get_platform_version();
|
31
linux/test/flutter_qjs_plugin_test.cc
Normal file
31
linux/test/flutter_qjs_plugin_test.cc
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <flutter_linux/flutter_linux.h>
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "include/flutter_qjs/flutter_qjs_plugin.h"
|
||||||
|
#include "flutter_qjs_plugin_private.h"
|
||||||
|
|
||||||
|
// This demonstrates a simple unit test of the C portion of this plugin's
|
||||||
|
// implementation.
|
||||||
|
//
|
||||||
|
// Once you have built the plugin's example app, you can run these tests
|
||||||
|
// from the command line. For instance, for a plugin called my_plugin
|
||||||
|
// built for x64 debug, run:
|
||||||
|
// $ build/linux/x64/debug/plugins/my_plugin/my_plugin_test
|
||||||
|
|
||||||
|
namespace flutter_qjs {
|
||||||
|
namespace test {
|
||||||
|
|
||||||
|
TEST(FlutterQjsPlugin, GetPlatformVersion) {
|
||||||
|
g_autoptr(FlMethodResponse) response = get_platform_version();
|
||||||
|
ASSERT_NE(response, nullptr);
|
||||||
|
ASSERT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
|
||||||
|
FlValue* result = fl_method_success_response_get_result(
|
||||||
|
FL_METHOD_SUCCESS_RESPONSE(response));
|
||||||
|
ASSERT_EQ(fl_value_get_type(result), FL_VALUE_TYPE_STRING);
|
||||||
|
// The full string varies, so just validate that it has the right format.
|
||||||
|
EXPECT_THAT(fl_value_get_string(result), testing::StartsWith("Linux "));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace test
|
||||||
|
} // namespace flutter_qjs
|
31
windows/flutter_qjs_plugin.h
Normal file
31
windows/flutter_qjs_plugin.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef FLUTTER_PLUGIN_FLUTTER_QJS_PLUGIN_H_
|
||||||
|
#define FLUTTER_PLUGIN_FLUTTER_QJS_PLUGIN_H_
|
||||||
|
|
||||||
|
#include <flutter/method_channel.h>
|
||||||
|
#include <flutter/plugin_registrar_windows.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace flutter_qjs {
|
||||||
|
|
||||||
|
class FlutterQjsPlugin : public flutter::Plugin {
|
||||||
|
public:
|
||||||
|
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
|
||||||
|
|
||||||
|
FlutterQjsPlugin();
|
||||||
|
|
||||||
|
virtual ~FlutterQjsPlugin();
|
||||||
|
|
||||||
|
// Disallow copy and assign.
|
||||||
|
FlutterQjsPlugin(const FlutterQjsPlugin&) = delete;
|
||||||
|
FlutterQjsPlugin& operator=(const FlutterQjsPlugin&) = delete;
|
||||||
|
|
||||||
|
// Called when a method is called on this plugin's channel from Dart.
|
||||||
|
void HandleMethodCall(
|
||||||
|
const flutter::MethodCall<flutter::EncodableValue> &method_call,
|
||||||
|
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace flutter_qjs
|
||||||
|
|
||||||
|
#endif // FLUTTER_PLUGIN_FLUTTER_QJS_PLUGIN_H_
|
12
windows/flutter_qjs_plugin_c_api.cpp
Normal file
12
windows/flutter_qjs_plugin_c_api.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#include "include/flutter_qjs/flutter_qjs_plugin_c_api.h"
|
||||||
|
|
||||||
|
#include <flutter/plugin_registrar_windows.h>
|
||||||
|
|
||||||
|
#include "flutter_qjs_plugin.h"
|
||||||
|
|
||||||
|
void FlutterQjsPluginCApiRegisterWithRegistrar(
|
||||||
|
FlutterDesktopPluginRegistrarRef registrar) {
|
||||||
|
flutter_qjs::FlutterQjsPlugin::RegisterWithRegistrar(
|
||||||
|
flutter::PluginRegistrarManager::GetInstance()
|
||||||
|
->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
|
||||||
|
}
|
23
windows/include/flutter_qjs/flutter_qjs_plugin_c_api.h
Normal file
23
windows/include/flutter_qjs/flutter_qjs_plugin_c_api.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef FLUTTER_PLUGIN_FLUTTER_QJS_PLUGIN_C_API_H_
|
||||||
|
#define FLUTTER_PLUGIN_FLUTTER_QJS_PLUGIN_C_API_H_
|
||||||
|
|
||||||
|
#include <flutter_plugin_registrar.h>
|
||||||
|
|
||||||
|
#ifdef FLUTTER_PLUGIN_IMPL
|
||||||
|
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void FlutterQjsPluginCApiRegisterWithRegistrar(
|
||||||
|
FlutterDesktopPluginRegistrarRef registrar);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // FLUTTER_PLUGIN_FLUTTER_QJS_PLUGIN_C_API_H_
|
43
windows/test/flutter_qjs_plugin_test.cpp
Normal file
43
windows/test/flutter_qjs_plugin_test.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#include <flutter/method_call.h>
|
||||||
|
#include <flutter/method_result_functions.h>
|
||||||
|
#include <flutter/standard_method_codec.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
#include "flutter_qjs_plugin.h"
|
||||||
|
|
||||||
|
namespace flutter_qjs {
|
||||||
|
namespace test {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using flutter::EncodableMap;
|
||||||
|
using flutter::EncodableValue;
|
||||||
|
using flutter::MethodCall;
|
||||||
|
using flutter::MethodResultFunctions;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
TEST(FlutterQjsPlugin, GetPlatformVersion) {
|
||||||
|
FlutterQjsPlugin plugin;
|
||||||
|
// Save the reply value from the success callback.
|
||||||
|
std::string result_string;
|
||||||
|
plugin.HandleMethodCall(
|
||||||
|
MethodCall("getPlatformVersion", std::make_unique<EncodableValue>()),
|
||||||
|
std::make_unique<MethodResultFunctions<>>(
|
||||||
|
[&result_string](const EncodableValue* result) {
|
||||||
|
result_string = std::get<std::string>(*result);
|
||||||
|
},
|
||||||
|
nullptr, nullptr));
|
||||||
|
|
||||||
|
// Since the exact string varies by host, just ensure that it's a string
|
||||||
|
// with the expected format.
|
||||||
|
EXPECT_TRUE(result_string.rfind("Windows ", 0) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace test
|
||||||
|
} // namespace flutter_qjs
|
Reference in New Issue
Block a user