feat(ui): 更新品牌启动页与选集交互
This commit is contained in:
1 parent
4778ce2c75
commit
c1cb7d1c11
87 files changed
+919
-552
No files matched your search
@@ -0,0 +1,73 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/episode_picker_cell.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_show_lock_when_episode_needs_unlock', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
const Episode(
|
||||
id: '12',
|
||||
number: 12,
|
||||
title: 'Paid',
|
||||
isFree: false,
|
||||
locked: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.lock_outline), findsOneWidget);
|
||||
expect(find.text('12'), findsOneWidget);
|
||||
final cell = tester.getRect(find.byType(EpisodePickerCell));
|
||||
final cover = tester.getRect(find.byKey(const ValueKey('episode-lock-cover-12')));
|
||||
final number = tester.getRect(find.text('12'));
|
||||
final lock = tester.getRect(find.byIcon(Icons.lock_outline));
|
||||
expect(number.overlaps(lock), isFalse);
|
||||
expect(number.top, greaterThanOrEqualTo(lock.bottom));
|
||||
final wash = tester.widget<ColoredBox>(
|
||||
find.byKey(const ValueKey('episode-lock-cover-12')),
|
||||
);
|
||||
expect(cover.width, greaterThanOrEqualTo(cell.width - 1));
|
||||
expect(cover.height, greaterThanOrEqualTo(cell.height - 1));
|
||||
expect(cover.contains(lock.center), isTrue);
|
||||
expect(wash.color.a, greaterThan(0));
|
||||
expect(wash.color.a, lessThan(1));
|
||||
});
|
||||
|
||||
testWidgets('should_hide_lock_when_episode_is_free', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
const Episode(
|
||||
id: '1',
|
||||
number: 1,
|
||||
title: 'Free',
|
||||
isFree: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.lock_outline), findsNothing);
|
||||
expect(find.byKey(const ValueKey('episode-lock-cover-1')), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _host(Episode episode) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: 52,
|
||||
height: 50,
|
||||
child: EpisodePickerCell(
|
||||
episode: episode,
|
||||
selected: false,
|
||||
lockLabel: 'Locked',
|
||||
onTap: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user