delegates_test.dart
2.04 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
// Copyright 2019 The FlutterCandies author. All rights reserved.
// Use of this source code is governed by an Apache license that can be found
// in the LICENSE file.
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
void main() {
group(AssetPickerTextDelegate, () {
test('returns the default when available', () {
expect(
assetPickerTextDelegateFromLocale(null),
equals(const AssetPickerTextDelegate()),
);
expect(
assetPickerTextDelegateFromLocale(const Locale('zh')),
equals(const AssetPickerTextDelegate()),
);
expect(
assetPickerTextDelegateFromLocale(const Locale('zxx')),
equals(const AssetPickerTextDelegate()),
);
});
test('each delegate can be obtained by its locale definition', () {
for (final delegate in assetPickerTextDelegates) {
final locale = Locale.fromSubtags(
languageCode: delegate.languageCode,
scriptCode: delegate.scriptCode,
countryCode: delegate.countryCode,
);
final matchedDelegate = assetPickerTextDelegateFromLocale(locale);
expect(matchedDelegate, equals(delegate));
}
});
});
test('Sort paths correctly', () {
final List<PathWrapper<AssetPathEntity>> paths =
<PathWrapper<AssetPathEntity>>[
PathWrapper<AssetPathEntity>(
path: AssetPathEntity(id: 'id2', name: 'Screenshots'),
),
PathWrapper<AssetPathEntity>(
path: AssetPathEntity(id: 'id1', name: 'Camera'),
),
PathWrapper<AssetPathEntity>(
path: AssetPathEntity(id: 'id0', name: 'All', isAll: true),
),
];
SortPathDelegate.common.sort(paths);
expect(paths[0], (PathWrapper<AssetPathEntity> e) => e.path.isAll);
expect(
paths[1],
(PathWrapper<AssetPathEntity> e) => e.path.name == 'Camera',
);
expect(
paths[2],
(PathWrapper<AssetPathEntity> e) => e.path.name == 'Screenshots',
);
});
}