@@ -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,77 @@ void main() {
133
136
.isSameColorSwatchAs (ChannelColorSwatch .dark (baseColor));
134
137
});
135
138
});
139
+
140
+
141
+ group ('ZAppBarTheme Tests' , () {
142
+ testWidgets ('Light AppBarThme Test' , (tester) async {
143
+ final designVariables = DesignVariables .light ();
144
+
145
+ await tester.pumpWidget (GetMaterialApp (
146
+ home: Scaffold (
147
+ appBar: AppBar (
148
+ title: const Text ('Test' ),
149
+ ),
150
+ ),
151
+ ));
152
+
153
+ final context = Get .context;
154
+
155
+ final appBarTheme =
156
+ ZAppBarTheme .lightAppBarTheme (context! , designVariables);
157
+
158
+ expect (appBarTheme.backgroundColor, designVariables.bgTopBar);
159
+ expect (appBarTheme.actionsIconTheme! .color, designVariables.icon);
160
+ expect (appBarTheme.titleTextStyle! .color, designVariables.title);
161
+ expect (appBarTheme.titleTextStyle! .fontSize, 20 );
162
+ expect (appBarTheme.titleTextStyle! .fontFamily, kDefaultFontFamily);
163
+ });
164
+
165
+ testWidgets ('Dark AppBarThem Test' , (tester) async {
166
+ final designVariables = DesignVariables .dark ();
167
+
168
+ await tester.pumpWidget (GetMaterialApp (
169
+ home: Scaffold (
170
+ appBar: AppBar (
171
+ title: const Text ('Test' ),
172
+ ),
173
+ ),
174
+ ));
175
+
176
+ final context = Get .context;
177
+ final appBarTheme =
178
+ ZAppBarTheme .darkAppBarTheme (context! , designVariables);
179
+
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
+
188
+ testWidgets ("Zbutton tests" , (tester) async {
189
+ final designVariables = DesignVariables .dark ();
190
+
191
+ // Use Get.context to access the context directly
192
+ await tester.pumpWidget (
193
+ GetMaterialApp (
194
+ home: Scaffold (
195
+ body: ElevatedButton (
196
+ onPressed: () {},
197
+ child: const Text ('Test Button' ),
198
+ ),
199
+ ),
200
+ ),
201
+ );
202
+
203
+ // Act
204
+ final elevatedButtonTheme = ZButtonTheme .darkElevatedButtonTheme (designVariables);
205
+
206
+ // Assert
207
+ final elevatedButtonStyle = elevatedButtonTheme.style! ;
208
+ expect (elevatedButtonStyle.backgroundColor? .resolve ({}), designVariables.bgTopBar);
209
+ expect (elevatedButtonStyle.foregroundColor? .resolve ({}), designVariables.title);
210
+ expect (elevatedButtonStyle.elevation? .resolve ({}), 4.0 );
211
+ });
136
212
}
0 commit comments