mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-08-12 06:10:55 +02:00
0078e344fd
* Update Logging feature to replace @LoggingFeature annotation with LoggerName mixin for runtime accessibility Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Bump version to 2.0.2 in pubspec.yaml and update CHANGELOG to reflect the new version Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Add migration steps for replacing @LoggingFeature annotation with LoggerName mixin in CHANGELOG Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Fix class declaration in migration example for LoggerName mixin Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Enhance CI workflow, coverage enforcement, and environment tests (#10) * Enhance CI workflow and coverage enforcement; update tests and add new environment tests Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Revert version bump in pubspec.yaml and remove test coverage note from CHANGELOG Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Update test to expect a thrown exception when no interfaces are registered Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Add ArcaneEnvironmentModeController and related tests for debug mode management Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Refactor theme switcher tests to use platform dispatcher for brightness change simulation Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> --------- Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * refactor(api): Remove export of Error and Ok from result_monad (#11) The `Error` and `Ok` symbols from the `result_monad` package are no longer re-exported directly by `arcane_framework`. Consumers needing these symbols must now explicitly import them from `package:result_monad`. This clarifies dependency ownership and reduces `arcane_framework`'s public API surface. --------- Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
105 lines
3.6 KiB
Dart
105 lines
3.6 KiB
Dart
import "package:arcane_framework/src/services/theme/theme_service.dart";
|
|
import "package:flutter/material.dart";
|
|
import "package:flutter_test/flutter_test.dart";
|
|
|
|
void main() {
|
|
group("ArcaneThemeService", () {
|
|
setUp(() {
|
|
ArcaneThemeService.I.reset();
|
|
});
|
|
|
|
test("default state is light theme, not following system", () {
|
|
expect(ArcaneThemeService.I.isFollowingSystemTheme, isFalse);
|
|
expect(ArcaneThemeService.I.currentThemeMode, ThemeMode.light);
|
|
expect(ArcaneThemeService.I.currentTheme, isA<ThemeData>());
|
|
});
|
|
|
|
test("switchTheme toggles between light and dark", () {
|
|
ArcaneThemeService.I.switchTheme(themeMode: ThemeMode.light);
|
|
expect(ArcaneThemeService.I.currentThemeMode, ThemeMode.light);
|
|
ArcaneThemeService.I.switchTheme();
|
|
expect(ArcaneThemeService.I.currentThemeMode, ThemeMode.dark);
|
|
ArcaneThemeService.I.switchTheme();
|
|
expect(ArcaneThemeService.I.currentThemeMode, ThemeMode.light);
|
|
});
|
|
|
|
test("setDarkTheme and setLightTheme update themes", () {
|
|
final customDark =
|
|
ThemeData(primaryColor: Colors.red, brightness: Brightness.dark);
|
|
final customLight =
|
|
ThemeData(primaryColor: Colors.blue, brightness: Brightness.light);
|
|
ArcaneThemeService.I.setDarkTheme(customDark);
|
|
expect(ArcaneThemeService.I.dark, customDark);
|
|
ArcaneThemeService.I.setLightTheme(customLight);
|
|
expect(ArcaneThemeService.I.light, customLight);
|
|
});
|
|
|
|
test("dark and light setters delegate to setDarkTheme/setLightTheme", () {
|
|
final customDark =
|
|
ThemeData(primaryColor: Colors.teal, brightness: Brightness.dark);
|
|
final customLight =
|
|
ThemeData(primaryColor: Colors.amber, brightness: Brightness.light);
|
|
|
|
ArcaneThemeService.I.dark = customDark;
|
|
ArcaneThemeService.I.light = customLight;
|
|
|
|
expect(ArcaneThemeService.I.dark, customDark);
|
|
expect(ArcaneThemeService.I.light, customLight);
|
|
});
|
|
|
|
testWidgets("currentModeOf returns context themeMode", (tester) async {
|
|
ArcaneThemeService.I.switchTheme(themeMode: ThemeMode.dark);
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Builder(
|
|
builder: (context) {
|
|
expect(
|
|
ArcaneThemeService.I.currentModeOf(context),
|
|
ThemeMode.dark,
|
|
);
|
|
return const SizedBox();
|
|
},
|
|
),
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets("setInitialTheme handles explicit dark mode", (tester) async {
|
|
ArcaneThemeService.I.switchTheme(themeMode: ThemeMode.dark);
|
|
|
|
late BuildContext capturedContext;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Builder(
|
|
builder: (context) {
|
|
capturedContext = context;
|
|
return const SizedBox();
|
|
},
|
|
),
|
|
),
|
|
);
|
|
|
|
ArcaneThemeService.I.setInitialTheme(capturedContext);
|
|
expect(ArcaneThemeService.I.currentTheme.brightness, Brightness.dark);
|
|
});
|
|
|
|
test("reset restores defaults", () {
|
|
ArcaneThemeService.I.setDarkTheme(
|
|
ThemeData(primaryColor: Colors.red, brightness: Brightness.dark),
|
|
);
|
|
ArcaneThemeService.I.setLightTheme(
|
|
ThemeData(primaryColor: Colors.blue, brightness: Brightness.light),
|
|
);
|
|
ArcaneThemeService.I.reset();
|
|
expect(ArcaneThemeService.I.dark, ThemeData.dark());
|
|
expect(ArcaneThemeService.I.light, ThemeData.light());
|
|
expect(ArcaneThemeService.I.isFollowingSystemTheme, isFalse);
|
|
});
|
|
|
|
test("dispose does not throw", () {
|
|
ArcaneThemeService.I.dispose();
|
|
});
|
|
});
|
|
}
|