Skip to content

Commit b086d0d

Browse files
authoredNov 14, 2021
Add App theme test (#88)
1 parent 5962894 commit b086d0d

File tree

2 files changed

+192
-0
lines changed

2 files changed

+192
-0
lines changed
 

‎test/widgets/app_theme_test.dart

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:gsettings/gsettings.dart';
4+
import 'package:mockito/annotations.dart';
5+
import 'package:settings/view/app_theme.dart';
6+
import 'app_theme_test.mocks.dart';
7+
import 'package:mockito/mockito.dart';
8+
9+
@GenerateMocks([GSettings])
10+
void main() {
11+
test(
12+
'App Theme Dark Mode Test',
13+
() {
14+
GSettings settings = MockGSettings();
15+
AppTheme theme = AppTheme(settings);
16+
17+
when(settings.setValue('gtk-theme', 'Yaru-dark')).thenAnswer(
18+
(realInvocation) => true,
19+
);
20+
21+
theme.apply(Brightness.dark);
22+
verify(settings.setValue('gtk-theme', 'Yaru-dark')).called(1);
23+
},
24+
);
25+
26+
test(
27+
'App Theme Light Mode Test',
28+
() {
29+
GSettings settings = MockGSettings();
30+
AppTheme theme = AppTheme(settings);
31+
32+
when(settings.setValue('gtk-theme', 'Yaru')).thenAnswer(
33+
(realInvocation) => true,
34+
);
35+
36+
theme.apply(Brightness.light);
37+
verify(settings.setValue('gtk-theme', 'Yaru')).called(1);
38+
},
39+
);
40+
}
+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// Mocks generated by Mockito 5.0.16 from annotations
2+
// in settings/test/widgets/app_theme_test.dart.
3+
// Do not manually edit this file.
4+
5+
import 'dart:ffi' as _i1;
6+
7+
import 'package:gsettings/src/bindings.dart' as _i5;
8+
import 'package:gsettings/src/settings.dart' as _i3;
9+
import 'package:mockito/mockito.dart' as _i2;
10+
import 'package:more/more.dart' as _i4;
11+
12+
// ignore_for_file: avoid_redundant_argument_values
13+
// ignore_for_file: avoid_setters_without_getters
14+
// ignore_for_file: comment_references
15+
// ignore_for_file: implementation_imports
16+
// ignore_for_file: invalid_use_of_visible_for_testing_member
17+
// ignore_for_file: prefer_const_constructors
18+
// ignore_for_file: unnecessary_parenthesis
19+
// ignore_for_file: camel_case_types
20+
21+
22+
class _FakeGSettings_1 extends _i2.Fake implements _i3.GSettings {}
23+
24+
class _FakeTuple_2 extends _i2.Fake implements _i4.Tuple {}
25+
26+
/// A class which mocks [GSettings].
27+
///
28+
/// See the documentation for Mockito's code generation for more information.
29+
// ignore: must_be_immutable
30+
class MockGSettings extends _i2.Mock implements _i3.GSettings {
31+
MockGSettings() {
32+
_i2.throwOnMissingStub(this);
33+
}
34+
35+
@override
36+
List<Object> get props =>
37+
(super.noSuchMethod(Invocation.getter(#props), returnValue: <Object>[])
38+
as List<Object>);
39+
@override
40+
String get schemaId =>
41+
(super.noSuchMethod(Invocation.getter(#schemaId), returnValue: '')
42+
as String);
43+
@override
44+
String get path =>
45+
(super.noSuchMethod(Invocation.getter(#path), returnValue: '') as String);
46+
47+
@override
48+
void sync() => super.noSuchMethod(Invocation.method(#sync, []),
49+
returnValueForMissingStub: null);
50+
@override
51+
void dispose() => super.noSuchMethod(Invocation.method(#dispose, []),
52+
returnValueForMissingStub: null);
53+
@override
54+
Object? value(String? key) =>
55+
(super.noSuchMethod(Invocation.method(#value, [key])) as Object?);
56+
@override
57+
bool setValue(String? key, Object? value) =>
58+
(super.noSuchMethod(Invocation.method(#setValue, [key, value]),
59+
returnValue: false) as bool);
60+
@override
61+
bool isWritable(String? key) =>
62+
(super.noSuchMethod(Invocation.method(#isWritable, [key]),
63+
returnValue: false) as bool);
64+
@override
65+
void delay() => super.noSuchMethod(Invocation.method(#delay, []),
66+
returnValueForMissingStub: null);
67+
@override
68+
void apply() => super.noSuchMethod(Invocation.method(#apply, []),
69+
returnValueForMissingStub: null);
70+
@override
71+
void revert() => super.noSuchMethod(Invocation.method(#revert, []),
72+
returnValueForMissingStub: null);
73+
@override
74+
bool hasUnapplied() =>
75+
(super.noSuchMethod(Invocation.method(#hasUnapplied, []),
76+
returnValue: false) as bool);
77+
@override
78+
_i3.GSettings child(String? name) =>
79+
(super.noSuchMethod(Invocation.method(#child, [name]),
80+
returnValue: _FakeGSettings_1()) as _i3.GSettings);
81+
@override
82+
void resetValue(String? key) =>
83+
super.noSuchMethod(Invocation.method(#resetValue, [key]),
84+
returnValueForMissingStub: null);
85+
@override
86+
Object? userValue(String? key) =>
87+
(super.noSuchMethod(Invocation.method(#userValue, [key])) as Object?);
88+
@override
89+
Object? defaultValue(String? key) =>
90+
(super.noSuchMethod(Invocation.method(#defaultValue, [key])) as Object?);
91+
@override
92+
List<String> children() =>
93+
(super.noSuchMethod(Invocation.method(#children, []),
94+
returnValue: <String>[]) as List<String>);
95+
@override
96+
bool boolValue(String? key) =>
97+
(super.noSuchMethod(Invocation.method(#boolValue, [key]),
98+
returnValue: false) as bool);
99+
@override
100+
int intValue(String? key) =>
101+
(super.noSuchMethod(Invocation.method(#intValue, [key]), returnValue: 0)
102+
as int);
103+
@override
104+
double doubleValue(String? key) =>
105+
(super.noSuchMethod(Invocation.method(#doubleValue, [key]),
106+
returnValue: 0.0) as double);
107+
@override
108+
String stringValue(String? key) => (super
109+
.noSuchMethod(Invocation.method(#stringValue, [key]), returnValue: '')
110+
as String);
111+
@override
112+
Object? maybeValue(String? key) =>
113+
(super.noSuchMethod(Invocation.method(#maybeValue, [key])) as Object?);
114+
@override
115+
Map<Object, Object?> dictValue(String? key) =>
116+
(super.noSuchMethod(Invocation.method(#dictValue, [key]),
117+
returnValue: <Object, Object?>{}) as Map<Object, Object?>);
118+
@override
119+
List<Object?> arrayValue(String? key) =>
120+
(super.noSuchMethod(Invocation.method(#arrayValue, [key]),
121+
returnValue: <Object?>[]) as List<Object?>);
122+
@override
123+
List<int?> byteArrayValue(String? key) =>
124+
(super.noSuchMethod(Invocation.method(#byteArrayValue, [key]),
125+
returnValue: <int?>[]) as List<int?>);
126+
@override
127+
List<String?> stringArrayValue(String? key) =>
128+
(super.noSuchMethod(Invocation.method(#stringArrayValue, [key]),
129+
returnValue: <String?>[]) as List<String?>);
130+
@override
131+
_i4.Tuple tupleValue(String? key) =>
132+
(super.noSuchMethod(Invocation.method(#tupleValue, [key]),
133+
returnValue: _FakeTuple_2()) as _i4.Tuple);
134+
@override
135+
int enumValue(String? key) =>
136+
(super.noSuchMethod(Invocation.method(#enumValue, [key]), returnValue: 0)
137+
as int);
138+
@override
139+
bool setEnumValue(String? key, int? value) =>
140+
(super.noSuchMethod(Invocation.method(#setEnumValue, [key, value]),
141+
returnValue: false) as bool);
142+
@override
143+
int flagsValue(String? key) =>
144+
(super.noSuchMethod(Invocation.method(#flagsValue, [key]), returnValue: 0)
145+
as int);
146+
@override
147+
bool setFlagsValue(String? key, int? value) =>
148+
(super.noSuchMethod(Invocation.method(#setFlagsValue, [key, value]),
149+
returnValue: false) as bool);
150+
@override
151+
String toString() => super.toString();
152+
}

0 commit comments

Comments
 (0)
Please sign in to comment.