dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
3.3 KiB
157 lines
3.3 KiB
1 year ago
|
import 'package:flutter/foundation.dart' show TargetPlatform;
|
||
9 months ago
|
import 'package:flutter_quill/src/common/utils/platform.dart';
|
||
1 year ago
|
import 'package:test/test.dart';
|
||
|
|
||
|
void main() {
|
||
|
group('Test platform checking logic', () {
|
||
|
var platform = TargetPlatform.linux;
|
||
|
test('Check isDesktop()', () {
|
||
|
platform = TargetPlatform.android;
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
platform: platform,
|
||
|
supportWeb: true,
|
||
|
),
|
||
|
false,
|
||
|
);
|
||
|
|
||
|
for (final desktopPlatform in [
|
||
|
TargetPlatform.macOS,
|
||
|
TargetPlatform.linux,
|
||
|
TargetPlatform.windows
|
||
|
]) {
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
supportWeb: false,
|
||
|
overrideIsWeb: false,
|
||
1 year ago
|
platform: desktopPlatform,
|
||
1 year ago
|
),
|
||
|
true,
|
||
|
);
|
||
|
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
supportWeb: false,
|
||
|
overrideIsWeb: true,
|
||
|
platform: desktopPlatform,
|
||
|
),
|
||
|
false,
|
||
|
);
|
||
|
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
supportWeb: true,
|
||
|
overrideIsWeb: true,
|
||
|
platform: desktopPlatform,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
test('Check isMobile()', () {
|
||
|
platform = TargetPlatform.macOS;
|
||
|
expect(
|
||
|
isMobile(
|
||
|
platform: platform,
|
||
|
supportWeb: true,
|
||
|
),
|
||
|
false,
|
||
|
);
|
||
|
|
||
|
for (final mobilePlatform in [
|
||
|
TargetPlatform.android,
|
||
|
TargetPlatform.iOS,
|
||
|
]) {
|
||
|
expect(
|
||
|
isMobile(
|
||
|
platform: mobilePlatform,
|
||
1 year ago
|
supportWeb: false,
|
||
1 year ago
|
overrideIsWeb: false,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
|
||
|
expect(
|
||
|
isMobile(
|
||
1 year ago
|
platform: mobilePlatform,
|
||
1 year ago
|
supportWeb: false,
|
||
|
overrideIsWeb: true,
|
||
|
),
|
||
|
false,
|
||
|
);
|
||
|
|
||
|
expect(
|
||
|
isMobile(
|
||
|
supportWeb: true,
|
||
|
overrideIsWeb: true,
|
||
|
platform: mobilePlatform,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
test(
|
||
|
'Check supportWeb parameter when using desktop platform on web',
|
||
|
() {
|
||
|
platform = TargetPlatform.macOS;
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
platform: platform,
|
||
|
supportWeb: true,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
platform: platform,
|
||
|
supportWeb: false,
|
||
|
overrideIsWeb: false,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
|
||
|
expect(
|
||
|
isDesktop(
|
||
|
platform: platform,
|
||
|
supportWeb: false,
|
||
|
overrideIsWeb: true,
|
||
|
),
|
||
|
false,
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
|
test(
|
||
|
'Check supportWeb parameter when using mobile platform on web',
|
||
|
() {
|
||
|
platform = TargetPlatform.android;
|
||
|
expect(
|
||
|
isMobile(
|
||
|
platform: platform,
|
||
|
supportWeb: true,
|
||
|
overrideIsWeb: true,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
expect(
|
||
|
isMobile(
|
||
|
platform: platform,
|
||
|
supportWeb: false,
|
||
|
overrideIsWeb: false,
|
||
|
),
|
||
|
true,
|
||
|
);
|
||
|
|
||
|
expect(
|
||
|
isMobile(
|
||
|
platform: platform,
|
||
|
supportWeb: false,
|
||
|
overrideIsWeb: true,
|
||
|
),
|
||
|
false,
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
|
}
|