Skip to content

Commit 3e61645

Browse files
committed
fixed for allow to run tests
1 parent b05452f commit 3e61645

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ packages:
7575
path: ".."
7676
relative: true
7777
source: path
78-
version: "0.4.0+1"
78+
version: "0.4.0+2"
7979
flutter_test:
8080
dependency: "direct dev"
8181
description: flutter

lib/quickjs/ffi.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,19 @@ abstract class JSPropertyEnum extends Opaque {}
115115

116116
final DynamicLibrary _qjsLib = Platform.environment['FLUTTER_TEST'] == 'true'
117117
? (Platform.isWindows
118-
? DynamicLibrary.open('test/build/Debug/ffiquickjs.dll')
118+
? DynamicLibrary.open('quickjs_c_bridge.dll')
119119
: Platform.isMacOS
120-
? DynamicLibrary.open('test/build/libffiquickjs.dylib')
121-
: DynamicLibrary.open('test/build/libffiquickjs.so'))
120+
? DynamicLibrary.process()
121+
: DynamicLibrary.open(Platform.environment['LIBQUICKJSC_PATH'] ??
122+
'libquickjs_c_bridge_plugin.so'))
122123
: (Platform.isWindows
123124
? DynamicLibrary.open('quickjs_c_bridge.dll')
124125
: (Platform.isLinux
125-
? DynamicLibrary.open(Platform.environment['LIBQUICKJSC_PATH'] ?? 'libquickjs_c_bridge_plugin.so')
126-
: (Platform.isAndroid
127-
? DynamicLibrary.open('libfastdev_quickjs_runtime.so')
128-
: DynamicLibrary.process())));
126+
? DynamicLibrary.open(Platform.environment['LIBQUICKJSC_PATH'] ??
127+
'libquickjs_c_bridge_plugin.so')
128+
: (Platform.isAndroid
129+
? DynamicLibrary.open('libfastdev_quickjs_runtime.so')
130+
: DynamicLibrary.process())));
129131

130132
/// DLLEXPORT JSValue *jsThrow(JSContext *ctx, JSValue *obj)
131133
final Pointer<JSValue> Function(

test/flutter_js_test.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ void main() {
77

88
TestWidgetsFlutterBinding.ensureInitialized();
99

10+
late JavascriptRuntime jsRuntime;
11+
1012
setUp(() {
11-
channel.setMockMethodCallHandler((MethodCall methodCall) async {
12-
return '42';
13-
});
13+
jsRuntime = getJavascriptRuntime();
1414
});
1515

1616
tearDown(() {
17-
channel.setMockMethodCallHandler(null);
17+
try {
18+
jsRuntime.dispose();
19+
} on Error catch (_) {}
20+
});
21+
22+
test('evaluate javascript', () {
23+
final result = jsRuntime.evaluate('Math.pow(5,3)');
24+
print('${result.rawResult}, ${result.stringResult}');
25+
print(
26+
'${result.rawResult.runtimeType}, ${result.stringResult.runtimeType}');
27+
expect(result.rawResult, equals(125));
28+
expect(result.stringResult, equals('125'));
1829
});
1930
}

0 commit comments

Comments
 (0)