mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 14:23:42 +00:00
feat: new ui (#1455)
This commit is contained in:
742 files changed
+59951
-5934
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gopeed/api/model/create_task.dart';
|
||||
import 'package:gopeed/api/model/request.dart';
|
||||
import 'package:gopeed/core/window/app_window_launcher.dart';
|
||||
import 'package:gopeed/core/window/window_capability_transport.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
const multiWindowChannel = MethodChannel('mixin.one/desktop_multi_window');
|
||||
const windowChannels = MethodChannel('mixin.one/desktop_multi_window/channels');
|
||||
final messenger = TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
|
||||
setUp(() {
|
||||
messenger.setMockMethodCallHandler(windowChannels, (call) async => null);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await AppWindowCapabilityHost.instance.stop();
|
||||
messenger.setMockMethodCallHandler(multiWindowChannel, null);
|
||||
messenger.setMockMethodCallHandler(windowChannels, null);
|
||||
});
|
||||
|
||||
test('create-task window stays hidden until child bootstrap is ready', () async {
|
||||
final calls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(multiWindowChannel, (call) async {
|
||||
calls.add(call);
|
||||
if (call.method == 'createWindow') return 'create-window-id';
|
||||
return null;
|
||||
});
|
||||
messenger.setMockMethodCallHandler(windowChannels, (call) async {
|
||||
calls.add(call);
|
||||
return null;
|
||||
});
|
||||
|
||||
final opened = await AppWindowLauncher.openCreateTaskWindow(
|
||||
createTask: CreateTask(req: Request(url: 'https://example.com/file.zip')),
|
||||
);
|
||||
|
||||
expect(opened, isTrue);
|
||||
final createCall = calls.firstWhere((call) => call.method == 'createWindow');
|
||||
final configuration = Map<String, dynamic>.from(createCall.arguments as Map);
|
||||
expect(configuration['hiddenAtLaunch'], isTrue);
|
||||
expect(
|
||||
calls.where((call) => call.method == 'window_show' && (call.arguments as Map)['windowId'] == 'create-window-id'),
|
||||
isEmpty,
|
||||
);
|
||||
});
|
||||
|
||||
test('create-task window failure reports fallback availability', () async {
|
||||
messenger.setMockMethodCallHandler(multiWindowChannel, (call) async {
|
||||
if (call.method == 'createWindow') {
|
||||
throw PlatformException(code: 'create_failed');
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
expect(await AppWindowLauncher.openCreateTaskWindow(), isFalse);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gopeed/core/window/app_window_bootstrap.dart';
|
||||
import 'package:gopeed/core/window/app_window_payload.dart';
|
||||
import 'package:gopeed/l10n/l10n.dart';
|
||||
|
||||
void main() {
|
||||
test('create-task child window has a localized native title', () {
|
||||
expect(
|
||||
AppWindowBootstrap.subWindowTitle(AppWindowType.createTask, appLocalizationsFor('en')),
|
||||
'Create Task - Gopeed',
|
||||
);
|
||||
expect(AppWindowBootstrap.subWindowTitle(AppWindowType.createTask, appLocalizationsFor('zh')), '创建任务 - Gopeed');
|
||||
});
|
||||
|
||||
test('create-task payload only carries initial task data', () {
|
||||
final raw = AppWindowPayload.createTask(
|
||||
createTask: {
|
||||
'urls': ['https://example.com/file.zip'],
|
||||
},
|
||||
).toRaw();
|
||||
final decoded = jsonDecode(raw) as Map<String, dynamic>;
|
||||
|
||||
expect(decoded.keys, containsAll(<String>['type', 'createTask']));
|
||||
expect(decoded.keys, hasLength(2));
|
||||
expect(decoded, isNot(contains('apiToken')));
|
||||
expect(decoded, isNot(contains('theme')));
|
||||
expect(decoded, isNot(contains('createHistory')));
|
||||
});
|
||||
|
||||
test('create-task payload preserves nested browser request parameters', () {
|
||||
final payload = AppWindowPayload.createTask(
|
||||
createTask: {
|
||||
'req': {
|
||||
'rawUrl': 'https://page.example/download',
|
||||
'url': 'https://cdn.example/archive.zip',
|
||||
'extra': {
|
||||
'method': 'GET',
|
||||
'header': {'Cookie': 'session=abc', 'Referer': 'https://page.example/', 'Authorization': 'Bearer token'},
|
||||
'body': '',
|
||||
},
|
||||
'labels': {'source': 'browser-extension'},
|
||||
'skipVerifyCert': true,
|
||||
},
|
||||
'opts': {'name': 'archive.zip', 'path': 'D:/Downloads', 'selectFiles': <int>[], 'extra': null},
|
||||
},
|
||||
);
|
||||
|
||||
final decoded = AppWindowPayload.fromRaw(payload.toRaw()).createTask;
|
||||
|
||||
expect(decoded?['req'], payload.createTask?['req']);
|
||||
expect(decoded?['opts'], payload.createTask?['opts']);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user