Nothing is built in: Settings → 宠物 shows "尚未导入宠物" until a zip is picked. The zip holds a dsh-Go pack.json and PNG sheets; it is validated (pack.json, every named sheet) and unpacked under the app's private files directory, with enable, size (40/52/64) and remove kept on the device. A pack's canvas, anchor, per-animation box and frame list drive rendering: PetSlot reserves the area above the baseline and stands the sprite on the composer's top edge (or on the activity cap while a turn runs). Idle, thinking, working and error follow the chat's state, and a tap plays the pack's react-left/react-right. Only one sheet is decoded at a time. path_provider's JNI binding does not load on this engine, so MainActivity exposes the files directory over a tiny method channel instead. dist/deepy-whale-pet.zip is the Deepy whale for testing. Tests cover the real pack manifest, frame/state mapping and zip import. 0.4.0 (400).
35 lines
1.3 KiB
Dart
35 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:openchamber/screens/settings_screen.dart';
|
|
import 'package:openchamber/state.dart';
|
|
|
|
void main() {
|
|
testWidgets('settings shows appearance, chat and the pet placeholder',
|
|
(tester) async {
|
|
final app = AppState();
|
|
addTearDown(app.dispose);
|
|
|
|
await tester.pumpWidget(MaterialApp(home: SettingsScreen(app: app)));
|
|
|
|
expect(find.text('外观'), findsOneWidget);
|
|
expect(find.text('聊天'), findsOneWidget);
|
|
expect(find.text('宠物'), findsOneWidget);
|
|
expect(find.text('主题模式'), findsOneWidget);
|
|
expect(find.text('主题色'), findsOneWidget);
|
|
expect(find.text('追问处理行为'), findsOneWidget);
|
|
expect(find.text('尚未导入宠物'), findsOneWidget);
|
|
expect(find.text('导入宠物包'), findsOneWidget);
|
|
|
|
// The choice is the server-backed follow-up behavior.
|
|
ChoiceChip chip(String label) =>
|
|
tester.widget<ChoiceChip>(find.widgetWithText(ChoiceChip, label));
|
|
expect(chip('排队').selected, isTrue);
|
|
|
|
await tester.tap(find.text('转向'));
|
|
await tester.pumpAndSettle();
|
|
expect(app.followUpBehavior, 'steer');
|
|
expect(chip('转向').selected, isTrue);
|
|
expect(chip('排队').selected, isFalse);
|
|
});
|
|
}
|