fix(ui): harden settings focus and semantics
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:plezy/data/ducet_order.dart';
|
||||
|
||||
void main() {
|
||||
test('applies CLDR kana ordering', () {
|
||||
expect(ducetCompare('ア', 'あ'), isNegative);
|
||||
expect(ducetCompare('カ', 'か'), isNegative);
|
||||
});
|
||||
|
||||
test('orders representative scripts by DUCET rank', () {
|
||||
expect(ducetCompare('A', 'α'), isNegative);
|
||||
expect(ducetCompare('α', 'Ж'), isNegative);
|
||||
expect(ducetCompare('Ж', '一'), isNegative);
|
||||
});
|
||||
|
||||
test('decomposes Kangxi radicals to their unified equivalents', () {
|
||||
expect(ducetCompare('⼀', '一'), 0);
|
||||
expect(ducetCompare('⿕', '龠'), 0);
|
||||
});
|
||||
|
||||
test('uses codepoint fallback for missing BMP and supplementary characters', () {
|
||||
expect(ducetCompare('\u0378', '\u0379'), isNegative);
|
||||
expect(ducetCompare('\u0378', 'A'), isPositive);
|
||||
expect(ducetCompare('😀', '😁'), isNegative);
|
||||
expect(ducetCompare('😀', 'A'), isPositive);
|
||||
});
|
||||
|
||||
test('preserves apostrophe, backslash, and dollar ranks in generated literal', () {
|
||||
expect(ducetCompare("'", r'$'), isNegative);
|
||||
expect(ducetCompare(r'$', r'\'), isPositive);
|
||||
});
|
||||
|
||||
test('compares only the first rune', () {
|
||||
expect(ducetCompare('A trailing text', 'A different text'), 0);
|
||||
expect(ducetCompare('😀 trailing text', '😀 different text'), 0);
|
||||
});
|
||||
|
||||
test('preserves empty-input failure', () {
|
||||
expect(() => ducetCompare('', 'A'), throwsStateError);
|
||||
expect(() => ducetCompare('A', ''), throwsStateError);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:plezy/data/hid_key_labels.dart';
|
||||
import 'package:plezy/models/hotkey_model.dart';
|
||||
|
||||
void main() {
|
||||
test('catalog preserves all 325 unique keys in canonical numeric order', () {
|
||||
final ids = hidKeyLabels.keys.toList();
|
||||
final sortedIds = [...ids]..sort();
|
||||
|
||||
expect(hidKeyLabels, hasLength(325));
|
||||
expect(ids.toSet(), hasLength(ids.length));
|
||||
expect(ids, sortedIds);
|
||||
expect(ids.every((id) => id >= 0 && id <= 0xffffffff), isTrue);
|
||||
expect(hidKeyLabels.values.every((label) => label.trim().isNotEmpty), isTrue);
|
||||
});
|
||||
|
||||
test('catalog preserves representative labels across usage groups', () {
|
||||
expect(hidKeyLabels[0x00000012], 'Fn');
|
||||
expect(hidKeyLabels[0x000100b5], 'Display Toggle');
|
||||
expect(hidKeyLabels[0x0005ff1f], 'Game Button Z');
|
||||
expect(hidKeyLabels[0x00070031], r'\');
|
||||
expect(hidKeyLabels[0x000c00cd], 'Play/Pause');
|
||||
expect(hidKeyLabels[0x000c029f], 'Show All Windows');
|
||||
});
|
||||
|
||||
test('physicalKeyLabel uses the catalog and formats an unknown HID fallback', () {
|
||||
expect(physicalKeyLabel(PhysicalKeyboardKey.keyA), 'A');
|
||||
expect(physicalKeyLabel(const PhysicalKeyboardKey(0xffffffff)), 'Key 0xffffffff');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:plezy/data/iso_639_data.dart';
|
||||
import 'package:plezy/utils/language_codes.dart';
|
||||
|
||||
void main() {
|
||||
test('catalog preserves 184 canonical entries and globally unique codes', () {
|
||||
final primaryCodes = languageEntries.keys.toList();
|
||||
final sortedPrimaryCodes = [...primaryCodes]..sort();
|
||||
final allCodes = <String>{};
|
||||
|
||||
expect(languageEntries, hasLength(184));
|
||||
expect(primaryCodes, sortedPrimaryCodes);
|
||||
for (final mapEntry in languageEntries.entries) {
|
||||
final entry = mapEntry.value;
|
||||
expect(entry.code1, mapEntry.key);
|
||||
expect(entry.code1, matches(RegExp(r'^[a-z]{2}$')));
|
||||
expect(entry.code2, matches(RegExp(r'^[a-z]{3}$')));
|
||||
expect(entry.name.trim(), isNotEmpty);
|
||||
expect(allCodes.add(entry.code1), isTrue);
|
||||
expect(allCodes.add(entry.code2), isTrue);
|
||||
if (entry.code2B case final bibliographic?) {
|
||||
expect(bibliographic, matches(RegExp(r'^[a-z]{3}$')));
|
||||
expect(allCodes.add(bibliographic), isTrue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('reverse maps are derived completely from terminology and bibliographic aliases', () {
|
||||
expect(code2ToCode1, hasLength(184));
|
||||
expect(code2BToCode1, hasLength(20));
|
||||
|
||||
for (final entry in languageEntries.values) {
|
||||
expect(code2ToCode1[entry.code2], entry.code1);
|
||||
if (entry.code2B case final bibliographic?) {
|
||||
expect(code2BToCode1[bibliographic], entry.code1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('representative terminology and bibliographic aliases preserve behavior', () {
|
||||
final german = languageEntries['de']!;
|
||||
expect(german.code2, 'deu');
|
||||
expect(german.code2B, 'ger');
|
||||
expect(german.name, 'German');
|
||||
expect(languageEntries['bn']!.name, 'Bengali, Bangla');
|
||||
expect(languageEntries['mi']!.name, 'Māori');
|
||||
|
||||
expect(LanguageCodes.getIso6391Code(' DEU '), 'de');
|
||||
expect(LanguageCodes.getIso6391Code('ger'), 'de');
|
||||
expect(LanguageCodes.getLanguageName('GER'), 'German');
|
||||
expect(LanguageCodes.getVariations('ger'), unorderedEquals(<String>['ger', 'de', 'deu']));
|
||||
expect(LanguageCodes.getLanguageName('zzz'), isNull);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user