为什么:a) 应用对外名称要统一成 FruitShorts(产品名,nontonki 是原型代号); b) 首发市场是印尼,界面必须有印尼语;c) 归档要求"新增 id-ID 与改名合并生成一次 l10n,别分两次"。 改名: - pubspec name: nontonki → fruitshorts(Dart 包名),description 同步;28 个文件的 package: 导入前缀替换 - Android android:label、iOS CFBundleDisplayName/CFBundleName → FruitShorts - 图标资源 assets/icon/nontonki.png → fruitshorts.png(含 pubspec 两处引用) - README 同步(补印尼语说明,顺带修掉写错的模块名 reelshort-app-api → fruitshorts-app-api) 文案: - 三份 arb 的 appName → FruitShorts、brandMark → FRUITSHORTS、shareFooter → FruitShorts(不留 demo 标记) - 新增 lib/l10n/app_id.arb:174 个值键与 en/zh 完全一致,按印尼语习惯翻译(Coin→Koin、Episode→Episode) - 一次性 flutter gen-l10n 生成 app_localizations_id.dart;id 自动进入 supportedLocales,默认 locale 未改 - 新增 test/config/l10n_id_test.dart:钉住 id 文案、supportedLocales 含 id、品牌文案无 demo 标记、占位符渲染 不动:applicationId / bundle id(lumadrama 遗留,等裁定)、目录名、业务逻辑与页面结构、语言选择页(仍只有 en/zh) 门禁:dart analyze lib test 零告警;flutter test 159 全过(基线 155 + 新增 4);残留扫描 0 命中; 三份 arb 键集一致(174/174/174);真机(iPhone iOS 26.6.1)构建安装启动成功,devicectl 列出显示名 FruitShorts
131 lines
3.8 KiB
Dart
131 lines
3.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/data/models/drama.dart';
|
|
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
|
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
|
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
|
|
|
void main() {
|
|
test('should_clamp_invalid_and_completed_values_when_resolving_resume_position', () {
|
|
const duration = Duration(seconds: 8);
|
|
expect(
|
|
clampResumePosition(const Duration(seconds: -1), duration),
|
|
Duration.zero,
|
|
);
|
|
expect(
|
|
clampResumePosition(const Duration(seconds: 3), duration),
|
|
const Duration(seconds: 3),
|
|
);
|
|
expect(
|
|
clampResumePosition(const Duration(seconds: 9), duration),
|
|
Duration.zero,
|
|
);
|
|
expect(
|
|
clampResumePosition(const Duration(milliseconds: 7700), duration),
|
|
Duration.zero,
|
|
);
|
|
});
|
|
|
|
test('should_scope_history_by_profile_drama_and_episode_when_saving', () async {
|
|
SharedPreferencesAsyncPlatform.instance =
|
|
InMemorySharedPreferencesAsync.empty();
|
|
final history = SharedPreferencesWatchHistoryRepository();
|
|
await history.save(
|
|
'profile-a',
|
|
'drama-a',
|
|
'episode-1',
|
|
const Duration(seconds: 3),
|
|
);
|
|
await history.save(
|
|
'profile-a',
|
|
'drama-a',
|
|
'episode-2',
|
|
const Duration(seconds: 5),
|
|
);
|
|
expect(
|
|
await history.positionFor('profile-a', 'drama-a', 'episode-1'),
|
|
const Duration(seconds: 3),
|
|
);
|
|
expect(
|
|
await history.positionFor('profile-b', 'drama-a', 'episode-1'),
|
|
isNull,
|
|
);
|
|
expect(await history.lastEpisodeId('profile-a', 'drama-a'), 'episode-2');
|
|
expect(await history.lastEpisodeId('profile-a', 'drama-b'), isNull);
|
|
});
|
|
|
|
test('should_prefer_first_loaded_episode_when_resuming', () async {
|
|
SharedPreferencesAsyncPlatform.instance =
|
|
InMemorySharedPreferencesAsync.empty();
|
|
final history = SharedPreferencesWatchHistoryRepository();
|
|
await history.save(
|
|
'profile-a',
|
|
'drama-a',
|
|
'episode-1',
|
|
const Duration(seconds: 3),
|
|
);
|
|
await history.save(
|
|
'profile-a',
|
|
'drama-a',
|
|
'episode-2',
|
|
const Duration(seconds: 5),
|
|
);
|
|
|
|
final drama = Drama(
|
|
id: 'drama-a',
|
|
title: 'title',
|
|
synopsis: 'synopsis',
|
|
posterUrl: '',
|
|
episodes: const [
|
|
Episode(id: 'episode-1', number: 1, title: 'E1', isFree: true),
|
|
Episode(id: 'episode-2', number: 2, title: 'E2', isFree: true),
|
|
],
|
|
);
|
|
|
|
expect(
|
|
await history.resumePositionFor('profile-a', drama),
|
|
const Duration(seconds: 3),
|
|
);
|
|
});
|
|
|
|
test('should_fall_back_to_last_watched_episode_when_resuming_a_list_card', () async {
|
|
SharedPreferencesAsyncPlatform.instance =
|
|
InMemorySharedPreferencesAsync.empty();
|
|
final history = SharedPreferencesWatchHistoryRepository();
|
|
await history.save(
|
|
'profile-a',
|
|
'drama-a',
|
|
'episode-2',
|
|
const Duration(seconds: 5),
|
|
);
|
|
|
|
const card = Drama(
|
|
id: 'drama-a',
|
|
title: 'title',
|
|
synopsis: 'synopsis',
|
|
posterUrl: '',
|
|
totalEpisodes: 12,
|
|
);
|
|
|
|
expect(
|
|
await history.resumePositionFor('profile-a', card),
|
|
const Duration(seconds: 5),
|
|
);
|
|
});
|
|
|
|
test('should_have_no_resume_position_when_list_card_has_no_history', () async {
|
|
SharedPreferencesAsyncPlatform.instance =
|
|
InMemorySharedPreferencesAsync.empty();
|
|
final history = SharedPreferencesWatchHistoryRepository();
|
|
|
|
const card = Drama(
|
|
id: 'drama-b',
|
|
title: 'title',
|
|
synopsis: 'synopsis',
|
|
posterUrl: '',
|
|
totalEpisodes: 12,
|
|
);
|
|
|
|
expect(await history.resumePositionFor('profile-a', card), isNull);
|
|
});
|
|
}
|