-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathbundle_test.dart
More file actions
106 lines (88 loc) · 3.39 KB
/
Copy pathbundle_test.dart
File metadata and controls
106 lines (88 loc) · 3.39 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:tizen_bundle/tizen_bundle.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('can create a bundle', (WidgetTester _) async {
final Bundle bundle = Bundle();
bundle['stringKey'] = 'stringValue';
expect(bundle['stringKey'], 'stringValue');
});
testWidgets('can create a bundle from another bundle', (
WidgetTester _,
) async {
final Bundle bundle = Bundle();
bundle['stringKey'] = 'stringValue';
final Bundle newBundle = Bundle.fromBundle(bundle);
expect(newBundle['stringKey'], 'stringValue');
});
testWidgets('can create a bundle from a map', (WidgetTester _) async {
final Bundle bundle = Bundle.fromMap(<String, Object>{
'stringKey': 'stringValue',
'stringsKey': <String>['value1', 'value2'],
'bytesKey': Uint8List.fromList(<int>[0x03]),
});
expect(bundle.length, 3);
expect(bundle['stringKey'], 'stringValue');
expect(bundle['stringsKey'], <String>['value1', 'value2']);
expect(bundle['bytesKey'], Uint8List.fromList(<int>[0x03]));
});
testWidgets('returns all stored keys and values', (WidgetTester _) async {
final Bundle bundle = Bundle.fromMap(<String, String>{
'key1': 'value1',
'key2': 'value2',
'key3': 'value3',
});
expect(bundle.keys, unorderedEquals(<String>['key1', 'key2', 'key3']));
expect(
bundle.values,
unorderedEquals(<String>['value1', 'value2', 'value3']),
);
});
testWidgets('checks whether the bundle is empty', (WidgetTester _) async {
final Bundle bundle = Bundle();
bundle['stringKey'] = 'stringValue';
expect(bundle.isNotEmpty, true);
bundle.remove('stringKey');
expect(bundle.isEmpty, true);
});
testWidgets('can add a Uint8List value', (WidgetTester _) async {
final Bundle bundle = Bundle();
bundle['bytesKey'] = Uint8List(10);
final Uint8List bytes = bundle['bytesKey']! as Uint8List;
expect(bytes.length, 10);
});
testWidgets('can add a List<String> value', (WidgetTester _) async {
final Bundle bundle = Bundle();
bundle['stringsKey'] = <String>['value1', 'value2'];
final List<String> strings = bundle['stringsKey']! as List<String>;
expect(strings, <String>['value1', 'value2']);
});
testWidgets('can remove all entries', (WidgetTester _) async {
final Bundle bundle = Bundle();
bundle['stringKey1'] = 'stringValue1';
bundle['stringKey2'] = 'stringValue2';
expect(bundle.length, 2);
bundle.clear();
expect(bundle.length, 0);
});
testWidgets('can remove key and its associated value', (
WidgetTester _,
) async {
final Bundle bundle = Bundle();
bundle['stringKey'] = 'stringValue';
expect(bundle.containsKey('stringKey'), true);
bundle.remove('stringKey');
expect(bundle.containsKey('stringKey'), false);
});
testWidgets('can encode and decode raw data', (WidgetTester _) async {
final Bundle bundle = Bundle();
bundle['stringKey'] = 'stringValue';
final String encoded = bundle.encode();
final Bundle newBundle = Bundle.decode(encoded);
expect(newBundle['stringKey'], 'stringValue');
});
}