rustdesk/flutter/test/cm_test.dart

63 lines
2.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/pages/server_page.dart';
2022-10-20 22:05:34 +08:00
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/main.dart';
import 'package:flutter_hbb/models/server_model.dart';
2022-10-20 22:05:34 +08:00
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import 'package:window_manager/window_manager.dart';
2022-10-20 22:05:34 +08:00
final testClients = [
Client(0, false, false, "UserAAAAAA", "123123123", true, false, false),
Client(1, false, false, "UserBBBBB", "221123123", true, false, false),
Client(2, false, false, "UserC", "331123123", true, false, false),
Client(3, false, false, "UserDDDDDDDDDDDd", "441123123", true, false, false)
];
2023-02-02 20:39:25 +08:00
/// flutter run -d {platform} -t lib/cm_test.dart to test cm
void main(List<String> args) async {
2022-10-20 22:05:34 +08:00
isTest = true;
WidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
await windowManager.setSize(const Size(400, 600));
await windowManager.setAlignment(Alignment.topRight);
await initEnv(kAppTypeMain);
2022-10-20 22:05:34 +08:00
for (var client in testClients) {
gFFI.serverModel.clients.add(client);
gFFI.serverModel.tabController.add(TabInfo(
key: client.id.toString(),
label: client.name,
closable: false,
page: buildConnectionCard(client)));
2022-10-20 22:05:34 +08:00
}
runApp(GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: MyTheme.lightTheme,
darkTheme: MyTheme.darkTheme,
themeMode: MyTheme.currentThemeMode(),
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: supportedLocales,
home: const DesktopServerPage()));
2023-05-18 17:41:16 +08:00
WindowOptions windowOptions = getHiddenTitleBarWindowOptions(
size: kConnectionManagerWindowSizeClosedChat);
2022-10-20 22:05:34 +08:00
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
// ensure initial window size to be changed
2023-05-18 17:41:16 +08:00
await windowManager.setSize(kConnectionManagerWindowSizeClosedChat);
2022-10-20 22:05:34 +08:00
await Future.wait([
windowManager.setAlignment(Alignment.topRight),
windowManager.focus(),
windowManager.setOpacity(1)
]);
// ensure
windowManager.setAlignment(Alignment.topRight);
});
}