cm_test.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_hbb/common.dart';
  3. import 'package:flutter_hbb/consts.dart';
  4. import 'package:flutter_hbb/desktop/pages/server_page.dart';
  5. import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
  6. import 'package:flutter_hbb/main.dart';
  7. import 'package:flutter_hbb/models/server_model.dart';
  8. import 'package:flutter_localizations/flutter_localizations.dart';
  9. import 'package:get/get.dart';
  10. import 'package:window_manager/window_manager.dart';
  11. final testClients = [
  12. Client(0, false, false, "UserAAAAAA", "123123123", true, false, false),
  13. Client(1, false, false, "UserBBBBB", "221123123", true, false, false),
  14. Client(2, false, false, "UserC", "331123123", true, false, false),
  15. Client(3, false, false, "UserDDDDDDDDDDDd", "441123123", true, false, false)
  16. ];
  17. /// flutter run -d {platform} -t test/cm_test.dart to test cm
  18. void main(List<String> args) async {
  19. isTest = true;
  20. WidgetsFlutterBinding.ensureInitialized();
  21. await windowManager.ensureInitialized();
  22. await windowManager.setSize(const Size(400, 600));
  23. await windowManager.setAlignment(Alignment.topRight);
  24. await initEnv(kAppTypeMain);
  25. for (var client in testClients) {
  26. gFFI.serverModel.clients.add(client);
  27. gFFI.serverModel.tabController.add(TabInfo(
  28. key: client.id.toString(),
  29. label: client.name,
  30. closable: false,
  31. page: buildConnectionCard(client)));
  32. }
  33. runApp(GetMaterialApp(
  34. debugShowCheckedModeBanner: false,
  35. theme: MyTheme.lightTheme,
  36. darkTheme: MyTheme.darkTheme,
  37. themeMode: MyTheme.currentThemeMode(),
  38. localizationsDelegates: const [
  39. GlobalMaterialLocalizations.delegate,
  40. GlobalWidgetsLocalizations.delegate,
  41. GlobalCupertinoLocalizations.delegate,
  42. ],
  43. supportedLocales: supportedLocales,
  44. home: const DesktopServerPage()));
  45. WindowOptions windowOptions = getHiddenTitleBarWindowOptions(
  46. size: kConnectionManagerWindowSizeClosedChat);
  47. windowManager.waitUntilReadyToShow(windowOptions, () async {
  48. await windowManager.show();
  49. // ensure initial window size to be changed
  50. await windowManager.setSize(kConnectionManagerWindowSizeClosedChat);
  51. await Future.wait([
  52. windowManager.setAlignment(Alignment.topRight),
  53. windowManager.focus(),
  54. windowManager.setOpacity(1)
  55. ]);
  56. // ensure
  57. windowManager.setAlignment(Alignment.topRight);
  58. });
  59. }