Skip to content

Commit f27dbef

Browse files
committed
test: Add test for AppBar to see if it changes to the designated color when switching themes
1 parent 6e88d0f commit f27dbef

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/widgets/theme_test.dart

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'package:checks/checks.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter/rendering.dart';
44
import 'package:flutter_test/flutter_test.dart';
5+
import 'package:get/get.dart';
6+
import 'package:zulip/themes/appbar_theme.dart';
57
import 'package:zulip/widgets/channel_colors.dart';
68
import 'package:zulip/widgets/text.dart';
79
import 'package:zulip/widgets/theme.dart';
@@ -133,4 +135,54 @@ void main() {
133135
.isSameColorSwatchAs(ChannelColorSwatch.dark(baseColor));
134136
});
135137
});
138+
139+
group('AppBarTheme Tests', () {
140+
testWidgets('Light AppBarTheme Test', (tester) async {
141+
final designVariables = DesignVariables.light();
142+
143+
await tester.pumpWidget(GetMaterialApp(
144+
home: Scaffold(
145+
appBar: AppBar(
146+
title: const Text('Test'),
147+
),
148+
),
149+
));
150+
151+
final context = Get.context;
152+
153+
final appBarTheme = ZAppBarTheme.getAppBarTheme(context!, designVariables);
154+
155+
// Validate AppBar properties for light theme
156+
expect(appBarTheme.backgroundColor, designVariables.bgTopBar);
157+
expect(appBarTheme.actionsIconTheme!.color, designVariables.icon);
158+
expect(appBarTheme.titleTextStyle!.color, designVariables.title);
159+
expect(appBarTheme.titleTextStyle!.fontSize, 20);
160+
expect(appBarTheme.titleTextStyle!.fontFamily, kDefaultFontFamily);
161+
162+
});
163+
164+
testWidgets('Dark AppBarTheme Test', (tester) async {
165+
final designVariables = DesignVariables.dark();
166+
167+
await tester.pumpWidget(GetMaterialApp(
168+
home: Scaffold(
169+
appBar: AppBar(
170+
title: const Text('Test'),
171+
),
172+
),
173+
));
174+
175+
final context = Get.context;
176+
177+
final appBarTheme = ZAppBarTheme.getAppBarTheme(context!, designVariables);
178+
179+
// Validate AppBar properties for dark theme
180+
expect(appBarTheme.backgroundColor, designVariables.bgTopBar);
181+
expect(appBarTheme.actionsIconTheme!.color, designVariables.icon);
182+
expect(appBarTheme.titleTextStyle!.color, designVariables.title);
183+
expect(appBarTheme.titleTextStyle!.fontSize, 20);
184+
expect(appBarTheme.titleTextStyle!.fontFamily, kDefaultFontFamily);
185+
186+
});
187+
});
136188
}

0 commit comments

Comments
 (0)