@@ -2,6 +2,9 @@ import 'package:checks/checks.dart';
2
2
import 'package:flutter/material.dart' ;
3
3
import 'package:flutter/rendering.dart' ;
4
4
import 'package:flutter_test/flutter_test.dart' ;
5
+ import 'package:get/get.dart' ;
6
+ import 'package:zulip/themes/appbar_theme.dart' ;
7
+ import 'package:zulip/themes/elevated_button_theme.dart' ;
5
8
import 'package:zulip/widgets/channel_colors.dart' ;
6
9
import 'package:zulip/widgets/text.dart' ;
7
10
import 'package:zulip/widgets/theme.dart' ;
@@ -133,4 +136,76 @@ void main() {
133
136
.isSameColorSwatchAs (ChannelColorSwatch .dark (baseColor));
134
137
});
135
138
});
139
+
140
+ group ('ZAppBarTheme Tests' , () {
141
+ testWidgets ('Light AppBarThme Test' , (tester) async {
142
+ final designVariables = DesignVariables .light ();
143
+
144
+ await tester.pumpWidget (GetMaterialApp (
145
+ home: Scaffold (
146
+ appBar: AppBar (
147
+ title: const Text ('Test' ),
148
+ ),
149
+ ),
150
+ ));
151
+
152
+ final context = Get .context;
153
+
154
+ final appBarTheme =
155
+ ZAppBarTheme .lightAppBarTheme (context! , designVariables);
156
+
157
+ expect (appBarTheme.backgroundColor, designVariables.bgTopBar);
158
+ expect (appBarTheme.actionsIconTheme! .color, designVariables.icon);
159
+ expect (appBarTheme.titleTextStyle! .color, designVariables.title);
160
+ expect (appBarTheme.titleTextStyle! .fontSize, 20 );
161
+ expect (appBarTheme.titleTextStyle! .fontFamily, kDefaultFontFamily);
162
+ });
163
+
164
+ testWidgets ('Dark AppBarThem 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
+ final appBarTheme =
177
+ ZAppBarTheme .darkAppBarTheme (context! , designVariables);
178
+
179
+ expect (appBarTheme.backgroundColor, designVariables.bgTopBar);
180
+ expect (appBarTheme.actionsIconTheme! .color, designVariables.icon);
181
+ expect (appBarTheme.titleTextStyle! .color, designVariables.title);
182
+ expect (appBarTheme.titleTextStyle! .fontSize, 20 );
183
+ expect (appBarTheme.titleTextStyle! .fontFamily, kDefaultFontFamily);
184
+ });
185
+ });
186
+
187
+ testWidgets ("Zbutton tests" , (tester) async {
188
+ final designVariables = DesignVariables .dark ();
189
+
190
+ // Use Get.context to access the context directly
191
+ await tester.pumpWidget (
192
+ GetMaterialApp (
193
+ home: Scaffold (
194
+ body: ElevatedButton (
195
+ onPressed: () {},
196
+ child: const Text ('Test Button' ),
197
+ ),
198
+ ),
199
+ ),
200
+ );
201
+
202
+ // Act
203
+ final elevatedButtonTheme = ZButtonTheme .darkElevatedButtonTheme (designVariables);
204
+
205
+ // Assert
206
+ final elevatedButtonStyle = elevatedButtonTheme.style! ;
207
+ expect (elevatedButtonStyle.backgroundColor? .resolve ({}), designVariables.bgTopBar);
208
+ expect (elevatedButtonStyle.foregroundColor? .resolve ({}), designVariables.title);
209
+ expect (elevatedButtonStyle.elevation? .resolve ({}), 4.0 );
210
+ });
136
211
}
0 commit comments