feat: deliver RSchedule service login exams and elastic glass navigation
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hepan_everyday/features/school/school_exam_adapter.dart';
|
||||
import 'package:hepan_everyday/domain/app_snapshot.dart';
|
||||
|
||||
String examHtml({String time = '', String room = '', String seat = ''}) =>
|
||||
'''
|
||||
<select id="xqbh"><option value="73" selected>2026-2027秋</option></select>
|
||||
<table id="sample-table-1"><thead><tr>
|
||||
${['id', '序号', '学号', '姓名', '课程代码', '课程名称', '考核方式', '考生编号', '考场顺序号', '考场', '座位号', '考试时间'].map((s) => '<th>$s</th>').join()}
|
||||
</tr></thead><tbody><tr>
|
||||
${['1', '1', 'private-id', 'private-name', 'MATH', '矩阵理论', '笔试', '', '', room, seat, time].map((s) => '<td>$s</td>').join()}
|
||||
</tr></tbody></table>''';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'unscheduled courses and supplied arrangement fields survive saving',
|
||||
() {
|
||||
final draft = SchoolExamAdapter.extract(examHtml());
|
||||
expect(draft.records.single.name, '矩阵理论');
|
||||
expect(draft.records.single.time, '');
|
||||
final arranged = SchoolExamAdapter.extract(
|
||||
examHtml(time: '2026-12-01 09:00–11:00', room: '品学楼A101', seat: '16'),
|
||||
);
|
||||
final saved = AppSnapshot.fromJson(
|
||||
AppSnapshot(examSchedule: arranged).toJson(),
|
||||
);
|
||||
expect(saved.examSchedule!.records.single.room, '品学楼A101');
|
||||
expect(saved.examSchedule!.records.single.seat, '16');
|
||||
expect(saved.examSchedule!.records.single.time, '2026-12-01 09:00–11:00');
|
||||
final text = saved.toJson().toString();
|
||||
expect(text, isNot(contains('private-id')));
|
||||
expect(text, isNot(contains('private-name')));
|
||||
},
|
||||
);
|
||||
test('partial exam pages cannot replace previously imported records', () {
|
||||
final headerOnly = examHtml().replaceAll(
|
||||
RegExp(r'<tbody>.*?</tbody>', dotAll: true),
|
||||
'<tbody></tbody>',
|
||||
);
|
||||
expect(() => SchoolExamAdapter.extract(headerOnly), throwsFormatException);
|
||||
expect(
|
||||
() =>
|
||||
SchoolExamAdapter.extract(examHtml().replaceFirst('<td>16</td>', '')),
|
||||
returnsNormally,
|
||||
);
|
||||
expect(
|
||||
() => SchoolExamAdapter.extract(
|
||||
examHtml().replaceFirst('<td>MATH</td>', ''),
|
||||
),
|
||||
throwsFormatException,
|
||||
);
|
||||
expect(
|
||||
() => SchoolExamAdapter.extract('<html>登录</html>'),
|
||||
throwsFormatException,
|
||||
);
|
||||
});
|
||||
final actual = Platform.environment['RSCHEDULE_EXAM_FIXTURE'];
|
||||
if (actual != null) {
|
||||
test(
|
||||
'provided exam export has eight courses with no arrangements',
|
||||
() async {
|
||||
final draft = SchoolExamAdapter.extract(
|
||||
await File(actual).readAsString(),
|
||||
);
|
||||
expect(draft.records.length, 8);
|
||||
expect(draft.semesterLabel, '2026-2027秋');
|
||||
expect(
|
||||
draft.records.every(
|
||||
(e) => e.time.isEmpty && e.room.isEmpty && e.seat.isEmpty,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hepan_everyday/features/school/school_session.dart';
|
||||
import 'package:hepan_everyday/features/school/school_navigation_policy.dart';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'login starts at graduate-specific service and accepts its HTTP callback',
|
||||
() {
|
||||
expect(SchoolSession.authUrl.path, '/pyxx/jzsso/login');
|
||||
expect(SchoolSession.authUrl.host, 'yjsjy.uestc.edu.cn');
|
||||
expect(
|
||||
SchoolNavigationPolicy.isSchoolPage(
|
||||
Uri.parse(
|
||||
'http://yjsjy.uestc.edu.cn/pyxx/jzsso/login?ticket=ST-example',
|
||||
),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
SchoolNavigationPolicy.isSchoolPage(
|
||||
Uri.parse('http://idas.uestc.edu.cn/authserver/login'),
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
SchoolNavigationPolicy.isSchoolPage(
|
||||
Uri.parse('http://yjsjy.uestc.edu.cn.evil.test/pyxx/jzsso/login'),
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hepan_everyday/features/school/school_login_flow.dart';
|
||||
|
||||
void main() {
|
||||
test('wait for student authentication then request timetable once', () {
|
||||
final flow = SchoolLoginFlow();
|
||||
final target = Uri.parse(
|
||||
'https://yjsjy.uestc.edu.cn/pyxx/pygl/xskbcx/index/1',
|
||||
);
|
||||
flow.begin(target);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse(
|
||||
'https://idas.uestc.edu.cn/authserver/login?service=graduate',
|
||||
),
|
||||
authenticated: false,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('http://yjsjy.uestc.edu.cn/pyxx/jzsso/login?ticket=ST-test'),
|
||||
authenticated: false,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('http://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
||||
authenticated: true,
|
||||
),
|
||||
target,
|
||||
);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
||||
authenticated: true,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
expect(flow.onLoaded(target, authenticated: true), isNull);
|
||||
flow.reset();
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
||||
authenticated: true,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
test(
|
||||
'reauthentication and untrusted redirects cannot jump into timetable',
|
||||
() {
|
||||
final flow = SchoolLoginFlow();
|
||||
final target = Uri.parse(
|
||||
'https://yjsjy.uestc.edu.cn/pyxx/pygl/xskbcx/index/1',
|
||||
);
|
||||
flow.begin(target);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://evil.test/pyxx/home/index'),
|
||||
authenticated: true,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
||||
authenticated: false,
|
||||
),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
||||
authenticated: true,
|
||||
),
|
||||
target,
|
||||
);
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://idas.uestc.edu.cn/authserver/login'),
|
||||
authenticated: false,
|
||||
);
|
||||
expect(
|
||||
flow.onLoaded(
|
||||
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
||||
authenticated: true,
|
||||
),
|
||||
target,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
|
||||
import 'package:hepan_everyday/features/school/school_session.dart';
|
||||
import 'package:hepan_everyday/features/school/school_exam_adapter.dart';
|
||||
|
||||
import '../support/fake_school_web.dart';
|
||||
import 'exam_adapter_test.dart' show examHtml;
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
late FakeSchoolPlatform platform;
|
||||
late SchoolSession session;
|
||||
setUp(() {
|
||||
platform = FakeSchoolPlatform();
|
||||
WebViewPlatform.instance = platform;
|
||||
session = SchoolSession();
|
||||
});
|
||||
tearDown(() => session.dispose());
|
||||
void navigate(String url) {
|
||||
platform.web.url = url;
|
||||
platform.delegate.started(url);
|
||||
platform.delegate.finished(url);
|
||||
}
|
||||
|
||||
test('actual session follows service login then reads exam HTML', () async {
|
||||
await session.openExams();
|
||||
expect(platform.web.loads.single, SchoolSession.authUrl.toString());
|
||||
navigate('https://idas.uestc.edu.cn/authserver/login?service=graduate');
|
||||
await flushSchoolEvents();
|
||||
expect(session.connectionState, SchoolConnectionState.authenticating);
|
||||
expect(session.finding, isFalse);
|
||||
platform.web.javascript = (script) async =>
|
||||
script.contains('outerHTML') ? jsonEncode(examHtml()) : true;
|
||||
navigate('http://yjsjy.uestc.edu.cn/pyxx/home/index');
|
||||
await flushSchoolEvents();
|
||||
expect(platform.web.loads.last, SchoolSession.examUrl.toString());
|
||||
expect(session.finding, isTrue);
|
||||
navigate(SchoolSession.examUrl.toString());
|
||||
await flushSchoolEvents();
|
||||
expect(session.pendingExams!.records.single.name, '矩阵理论');
|
||||
expect(session.connectionState, SchoolConnectionState.connected);
|
||||
});
|
||||
test(
|
||||
'obsolete main-frame error cannot interrupt a newer exam read',
|
||||
() async {
|
||||
await session.openExams();
|
||||
platform.web.javascript = (_) async => jsonEncode(examHtml());
|
||||
navigate(SchoolSession.examUrl.toString());
|
||||
await flushSchoolEvents();
|
||||
platform.delegate.resourceError(
|
||||
const WebResourceError(
|
||||
errorCode: -2,
|
||||
description: 'old request',
|
||||
isForMainFrame: true,
|
||||
url: 'https://yjsjy.uestc.edu.cn/pyxx/pygl/xskbcx/index/1',
|
||||
),
|
||||
);
|
||||
await flushSchoolEvents();
|
||||
expect(session.finding, isTrue);
|
||||
expect(session.message, '读取成功,正在保存…');
|
||||
},
|
||||
);
|
||||
test(
|
||||
'open waits for logout so old clearing cannot blank the new login',
|
||||
() async {
|
||||
await session.open();
|
||||
platform.cookies.clearing = Completer<bool>();
|
||||
final closing = session.logout();
|
||||
await flushSchoolEvents();
|
||||
final reopening = session.openExams();
|
||||
await flushSchoolEvents();
|
||||
platform.cookies.clearing!.complete(true);
|
||||
await closing;
|
||||
await reopening;
|
||||
expect(session.hasOpened, isTrue);
|
||||
expect(platform.web.loads.last, SchoolSession.authUrl.toString());
|
||||
expect(session.requestingExams, isTrue);
|
||||
},
|
||||
);
|
||||
test(
|
||||
'acknowledging an old saved draft preserves a newer pending import',
|
||||
() async {
|
||||
await session.openExams();
|
||||
final old = SchoolExamAdapter.extract(examHtml());
|
||||
session.pendingExams = old;
|
||||
final generation = session.pageGeneration;
|
||||
await session.openExams();
|
||||
final newer = SchoolExamAdapter.extract(examHtml(room: '品学楼A101'));
|
||||
session.pendingExams = newer;
|
||||
expect(
|
||||
session.saved(success: true, generation: generation, exams: old),
|
||||
isFalse,
|
||||
);
|
||||
expect(session.pendingExams, same(newer));
|
||||
expect(
|
||||
session.saved(
|
||||
success: true,
|
||||
generation: session.pageGeneration,
|
||||
exams: newer,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(session.pendingExams, isNull);
|
||||
},
|
||||
);
|
||||
test(
|
||||
'native logout failure is reported and subsequent login can recover',
|
||||
() async {
|
||||
await session.open();
|
||||
session.connectionState = SchoolConnectionState.connected;
|
||||
platform.cookies.clearing = Completer<bool>();
|
||||
final closing = session.logout();
|
||||
final result = closing.then((_) => true, onError: (_) => false);
|
||||
platform.cookies.clearing!.completeError(
|
||||
StateError('cookie clearing failed'),
|
||||
);
|
||||
expect(await result, isTrue);
|
||||
expect(session.connectionState, isNot(SchoolConnectionState.connected));
|
||||
expect(session.message, contains('退出未完成'));
|
||||
await session.openExams();
|
||||
expect(platform.web.loads.last, SchoolSession.authUrl.toString());
|
||||
},
|
||||
);
|
||||
test('university HTTP identity redirect upgrades to HTTPS with service preserved', () async {
|
||||
await session.open();
|
||||
const redirect =
|
||||
'http://idas.uestc.edu.cn/authserver/login?service=http%3A%2F%2Fyjsjy.uestc.edu.cn%2Fpyxx%2Fjzsso%2Flogin';
|
||||
final decision = await platform.delegate.navigation(
|
||||
const NavigationRequest(url: redirect, isMainFrame: true),
|
||||
);
|
||||
expect(decision, NavigationDecision.prevent);
|
||||
final opened = Uri.parse(platform.web.loads.last);
|
||||
expect(opened.host, 'idas.uestc.edu.cn');
|
||||
expect(opened.scheme, 'https');
|
||||
expect(opened.query, Uri.parse(redirect).query);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
|
||||
|
||||
class FakeSchoolPlatform extends WebViewPlatform {
|
||||
late FakeSchoolWeb web;
|
||||
late FakeSchoolDelegate delegate;
|
||||
final cookies = FakeSchoolCookies();
|
||||
@override
|
||||
PlatformWebViewController createPlatformWebViewController(
|
||||
PlatformWebViewControllerCreationParams params,
|
||||
) => web = FakeSchoolWeb(params);
|
||||
@override
|
||||
PlatformNavigationDelegate createPlatformNavigationDelegate(
|
||||
PlatformNavigationDelegateCreationParams params,
|
||||
) => delegate = FakeSchoolDelegate(params);
|
||||
@override
|
||||
PlatformWebViewCookieManager createPlatformCookieManager(
|
||||
PlatformWebViewCookieManagerCreationParams params,
|
||||
) => cookies;
|
||||
}
|
||||
|
||||
class FakeSchoolWeb extends PlatformWebViewController {
|
||||
FakeSchoolWeb(super.params) : super.implementation();
|
||||
final loads = <String>[];
|
||||
String? url;
|
||||
Future<Object> Function(String)? javascript;
|
||||
@override
|
||||
Future<void> setJavaScriptMode(JavaScriptMode mode) async {}
|
||||
@override
|
||||
Future<void> setPlatformNavigationDelegate(
|
||||
PlatformNavigationDelegate handler,
|
||||
) async {}
|
||||
@override
|
||||
Future<void> loadRequest(LoadRequestParams params) async {
|
||||
url = params.uri.toString();
|
||||
loads.add(url!);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> currentUrl() async => url;
|
||||
@override
|
||||
Future<Object> runJavaScriptReturningResult(String script) =>
|
||||
javascript?.call(script) ?? Future.value(false);
|
||||
@override
|
||||
Future<void> clearCache() async {}
|
||||
@override
|
||||
Future<void> clearLocalStorage() async {}
|
||||
@override
|
||||
Future<void> loadHtmlString(String html, {String? baseUrl}) async {
|
||||
url = 'about:blank';
|
||||
loads.add('about:blank');
|
||||
}
|
||||
}
|
||||
|
||||
class FakeSchoolDelegate extends PlatformNavigationDelegate {
|
||||
FakeSchoolDelegate(super.params) : super.implementation();
|
||||
late PageEventCallback started, finished;
|
||||
late WebResourceErrorCallback resourceError;
|
||||
late NavigationRequestCallback navigation;
|
||||
@override
|
||||
Future<void> setOnNavigationRequest(
|
||||
NavigationRequestCallback callback,
|
||||
) async {
|
||||
navigation = callback;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setOnPageStarted(PageEventCallback callback) async {
|
||||
started = callback;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setOnPageFinished(PageEventCallback callback) async {
|
||||
finished = callback;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setOnWebResourceError(WebResourceErrorCallback callback) async {
|
||||
resourceError = callback;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setOnHttpError(HttpResponseErrorCallback callback) async {}
|
||||
}
|
||||
|
||||
class FakeSchoolCookies extends PlatformWebViewCookieManager {
|
||||
FakeSchoolCookies()
|
||||
: super.implementation(const PlatformWebViewCookieManagerCreationParams());
|
||||
Completer<bool>? clearing;
|
||||
bool fail = false;
|
||||
@override
|
||||
Future<bool> clearCookies() => fail
|
||||
? Future.error(StateError('native cookies'))
|
||||
: clearing?.future ?? Future.value(true);
|
||||
}
|
||||
|
||||
Future<void> flushSchoolEvents() async {
|
||||
for (var i = 0; i < 12; i++) {
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,14 @@ void main() {
|
||||
await c.showDemo();
|
||||
await tester.pumpWidget(HepanApp(controller: c));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Riverside Schedule'), findsOneWidget);
|
||||
expect(find.text('RSchedule'), findsOneWidget);
|
||||
expect(tester.getRect(find.text('周日')).right, lessThanOrEqualTo(800));
|
||||
await tester.drag(find.text('周三'), const Offset(-250, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('登录学校账户'), findsNothing);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('dock-cursor')),
|
||||
const Offset(100, 0),
|
||||
const Offset(185, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('登录学校账户'), findsOneWidget);
|
||||
@@ -32,11 +32,11 @@ void main() {
|
||||
expect(find.text('登录学校账户'), findsOneWidget);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('dock-cursor')),
|
||||
const Offset(-100, 0),
|
||||
const Offset(-185, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('示例课表'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('我的'));
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('登录学校账户'), findsOneWidget);
|
||||
c.dispose();
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:timezone/data/latest.dart' as tzdata;
|
||||
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
|
||||
import 'package:hepan_everyday/app/hepan_app.dart';
|
||||
import 'package:hepan_everyday/features/school/school_session.dart';
|
||||
|
||||
import '../support/fake_school_web.dart';
|
||||
import 'navigation_test.dart' show uiController;
|
||||
|
||||
void main() {
|
||||
setUpAll(tzdata.initializeTimeZones);
|
||||
testWidgets(
|
||||
'logout failure is visible and user can retry clearing school login',
|
||||
(tester) async {
|
||||
final platform = FakeSchoolPlatform();
|
||||
WebViewPlatform.instance = platform;
|
||||
final school = SchoolSession();
|
||||
await school.open();
|
||||
final c = uiController();
|
||||
await c.initialize();
|
||||
await tester.pumpWidget(HepanApp(controller: c, school: school));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
platform.cookies.fail = true;
|
||||
await tester.tap(find.text('退出学校登录'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('保留课表和考试'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('学校退出未完成'), findsOneWidget);
|
||||
expect(find.text('重试退出学校登录'), findsOneWidget);
|
||||
platform.cookies.fail = false;
|
||||
await tester.tap(find.text('重试退出学校登录'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('保留课表和考试'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('重试退出学校登录'), findsNothing);
|
||||
expect(find.textContaining('学校退出未完成'), findsNothing);
|
||||
school.dispose();
|
||||
c.dispose();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -21,8 +21,8 @@ void main() {
|
||||
await controller.initialize();
|
||||
await tester.pumpWidget(HepanApp(controller: controller));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.bySemanticsLabel('我的'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('我的'));
|
||||
expect(find.bySemanticsLabel('个人设置'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('登录学校账户'), findsOneWidget);
|
||||
expect(find.text('课表设置'), findsOneWidget);
|
||||
|
||||
@@ -37,7 +37,7 @@ void main() {
|
||||
await tester.tap(find.text('保留损坏文件并重新建立'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.storageReady, isTrue);
|
||||
await tester.tap(find.bySemanticsLabel('我的'));
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.ensureVisible(find.text('课表设置'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hepan_everyday/app/hepan_app.dart';
|
||||
import 'package:timezone/data/latest.dart' as tzdata;
|
||||
|
||||
import 'navigation_test.dart' show uiController;
|
||||
|
||||
void main() {
|
||||
setUpAll(tzdata.initializeTimeZones);
|
||||
testWidgets('three icon tabs and vertical scroll hide and restore Dock', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final c = uiController();
|
||||
await c.initialize();
|
||||
await c.showDemo();
|
||||
await tester.pumpWidget(HepanApp(controller: c));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('RSchedule'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel('考试'), findsOneWidget);
|
||||
await tester.drag(find.text('周三'), const Offset(0, -200));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.bySemanticsLabel('考试').hitTestable(), findsNothing);
|
||||
await tester.drag(find.byType(ListView).first, const Offset(0, 100));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.bySemanticsLabel('考试').hitTestable(), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('考试'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('考试安排'), findsOneWidget);
|
||||
await tester.drag(find.text('考试安排'), const Offset(-200, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('考试安排'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('登录学校账户'), findsOneWidget);
|
||||
c.dispose();
|
||||
});
|
||||
}
|
||||
@@ -99,8 +99,8 @@ void main() {
|
||||
await controller.initialize();
|
||||
await tester.pumpWidget(HepanApp(controller: controller));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.bySemanticsLabel('我的'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('我的'));
|
||||
expect(find.bySemanticsLabel('个人设置'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.ensureVisible(find.text('课表设置'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -39,8 +39,8 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.bySemanticsLabel('课表'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel('我的'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('我的'));
|
||||
expect(find.bySemanticsLabel('个人设置'), findsOneWidget);
|
||||
await tester.tap(find.bySemanticsLabel('个人设置'));
|
||||
await tester.pumpAndSettle();
|
||||
selection.value = 'math/2026-09-09';
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in New Issue
Block a user