forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_utilities_test.dart
43 lines (35 loc) · 1.26 KB
/
plugin_utilities_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:test/test.dart';
String top() => "top";
class Foo {
const Foo();
static int getInt() => 1;
double getDouble() => 1.0;
}
const Foo foo = const Foo();
void main() {
test('PluginUtilities Callback Handles', () {
// Top level callback.
final hTop = PluginUtilities.getCallbackHandle(top);
expect(hTop, isNotNull);
expect(hTop, isNot(0));
expect(PluginUtilities.getCallbackHandle(top), hTop);
final topClosure = PluginUtilities.getCallbackFromHandle(hTop);
expect(topClosure, isNotNull);
expect(topClosure(), "top");
// Static method callback
final hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt);
expect(hGetInt, isNotNull);
expect(hGetInt, isNot(0));
expect(PluginUtilities.getCallbackHandle(Foo.getInt), hGetInt);
final getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt);
expect(getIntClosure, isNotNull);
expect(getIntClosure(), 1);
// Instance method callbacks cannot be looked up.
final foo = new Foo();
expect(PluginUtilities.getCallbackHandle(foo.getDouble), isNull);
});
}