feat: phase1 UI prep — 设备ID系统传递 + 国家本地化展示 + 继续观看直进播放页
设备标识: Android SSAID/ iOS IDFV 原生通道 → Dart DeviceIdProvider 国家解析: 注册/登录从后端 IP → 国家/语言/时区/币种 自动落库 账号资料: 全部本地化展示 (account_display.dart) 我的页: 继续观看卡片点击直接进播放页
This commit is contained in:
1 parent
1b19513efb
commit
a3f3481f4f
15 files changed
+468
-25
No files matched your search
@@ -0,0 +1,40 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/formatting/account_display.dart';
|
||||
|
||||
void main() {
|
||||
test('should_localize_country_name', () {
|
||||
expect(countryName('ID', 'zh'), '印度尼西亚');
|
||||
expect(countryName('us', 'en'), 'United States');
|
||||
expect(countryName('TH', 'id'), 'Thailand');
|
||||
// 未收录的码原样返回,避免展示成空白
|
||||
expect(countryName('ZZ', 'zh'), 'ZZ');
|
||||
expect(countryName('', 'zh'), '');
|
||||
});
|
||||
|
||||
test('should_localize_timezone_to_city', () {
|
||||
expect(timezoneName('Asia/Jakarta', 'zh'), '雅加达');
|
||||
expect(timezoneName('Asia/Jakarta', 'en'), 'Jakarta');
|
||||
expect(
|
||||
timezoneName('America/Argentina/Buenos_Aires', 'en'),
|
||||
'Buenos Aires',
|
||||
);
|
||||
expect(timezoneName('', 'zh'), '');
|
||||
});
|
||||
|
||||
test('should_localize_language_by_primary_tag', () {
|
||||
expect(languageName('id-ID', 'zh'), '印度尼西亚语');
|
||||
expect(languageName('zh-TW', 'en'), 'Chinese');
|
||||
expect(languageName('en-US', 'id'), 'Inggris');
|
||||
expect(languageName('', 'zh'), '');
|
||||
});
|
||||
|
||||
test('should_localize_status_and_vip_level', () {
|
||||
expect(accountStatusText('normal', 'zh'), '正常');
|
||||
expect(accountStatusText('banned', 'id'), 'Diblokir');
|
||||
expect(accountStatusText('weird', 'zh'), 'weird');
|
||||
expect(vipLevelText(0, 'zh'), '未开通');
|
||||
expect(vipLevelText(2, 'zh'), 'VIP 2');
|
||||
});
|
||||
}
|
||||
@@ -8,9 +8,10 @@ import 'package:shared_preferences_platform_interface/shared_preferences_async_p
|
||||
|
||||
/// 可控的系统设备标识来源。
|
||||
class _FakeDeviceIdProvider implements DeviceIdProvider {
|
||||
_FakeDeviceIdProvider(this.value);
|
||||
_FakeDeviceIdProvider(this.value, {this.region});
|
||||
|
||||
final String? value;
|
||||
final String? region;
|
||||
int calls = 0;
|
||||
|
||||
@override
|
||||
@@ -18,6 +19,9 @@ class _FakeDeviceIdProvider implements DeviceIdProvider {
|
||||
calls++;
|
||||
return value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> deviceRegion() async => region;
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -62,4 +66,16 @@ void main() {
|
||||
|
||||
expect(provider.calls, 1);
|
||||
});
|
||||
|
||||
test('should_return_device_region_or_empty_string', () async {
|
||||
final store = AuthSessionStore(
|
||||
deviceIdProvider: _FakeDeviceIdProvider(null, region: 'TH'),
|
||||
);
|
||||
final missing = AuthSessionStore(
|
||||
deviceIdProvider: _FakeDeviceIdProvider(null),
|
||||
);
|
||||
|
||||
expect(await store.deviceRegion(), 'TH');
|
||||
expect(await missing.deviceRegion(), '');
|
||||
});
|
||||
}
|
||||
@@ -437,6 +437,24 @@ void main() {
|
||||
expect(find.byKey(const Key('following-history-grid')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_player_when_tapping_continue_watching_card', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(
|
||||
tester,
|
||||
signedIn: true,
|
||||
history: InMemoryWatchHistoryRepository(seed: [_recent]),
|
||||
);
|
||||
await _openMine(tester);
|
||||
|
||||
await tester.tap(find.byKey(const Key('mine-continue-city-lights-demo')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-scaffold')), findsOneWidget);
|
||||
// 继续观看直接进播放页,不应该先落到历史列表
|
||||
expect(find.byKey(const Key('following-page')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_open_vip_from_mine_without_floating_player', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in new issue
Block a user