Skip to content

Commit

Permalink
fix: analysis_options
Browse files Browse the repository at this point in the history
  • Loading branch information
kkweon committed Jun 30, 2021
1 parent 3789dd8 commit d6be28e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
16 changes: 11 additions & 5 deletions client/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
include: package:lint/analysis_options.yaml
analyzer:
exclude:
- lib/**/*.pb*.dart
- lib/test-server.dart
- test/**/*.mocks.dart

linter:
rules:
# these rules are disabled due to gRPC/mock generated files.
constant_identifier_names: false
directives_ordering: false
avoid_implementing_value_types: false
prefer_constructors_over_static_methods: false
sort_unnamed_constructors_first: false
implementation_imports: false
invalid_implementation_override: false
9 changes: 5 additions & 4 deletions client/lib/custom_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class CustomTheme extends ChangeNotifier {

ThemeMode get themeMode => _isDarkMode ? ThemeMode.dark : ThemeMode.light;

Icon get icon => _isDarkMode
? const Icon(Icons.dark_mode_outlined)
: const Icon(Icons.light_mode_outlined);
// This type should not be a widget(e.g. Icon) because of mockito support...
IconData get icon =>
_isDarkMode ? Icons.dark_mode_outlined : Icons.light_mode_outlined;

Text get text => _isDarkMode ? const Text("다크 모드") : const Text("라이트 모드");
// This type should not be a widget(e.g. Text) because of mockito support...
String get text => _isDarkMode ? "다크 모드" : "라이트 모드";
}
4 changes: 4 additions & 0 deletions client/lib/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class GrpcClient {

return response.detail;
}

Future<ReportResponse> report(ReportRequest request) {
return _client.report(request);
}
}

// ignore: unused_element
Expand Down
4 changes: 2 additions & 2 deletions client/lib/widgets/components/custom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class CustomAppBar extends AppBar {
PopupMenuItem<VertMenu>(
value: VertMenu.themeMode,
child: ListTile(
leading: context.read<CustomTheme>().icon,
title: context.read<CustomTheme>().text)),
leading: Icon(context.read<CustomTheme>().icon),
title: Text(context.read<CustomTheme>().text))),
const PopupMenuDivider(height: 5),
const PopupMenuItem<VertMenu>(
value: VertMenu.issueReport,
Expand Down
18 changes: 18 additions & 0 deletions client/test/screens/main_screen_test_with_mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:pr12er/custom_theme.dart';
import 'package:pr12er/protos/pkg/pr12er/messages.pb.dart';
import 'package:pr12er/protos/pkg/pr12er/service.pb.dart';
import 'package:pr12er/screens/main_screen.dart';
import 'package:pr12er/service.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -74,5 +75,22 @@ void main() {
// THEN themeMode should have changed.
expect(mockTheme.themeMode, isNot(oldThemeMode));
});

testWidgets("Clicking the create issue button should send request",
(WidgetTester tester) async {
// GIVEN a user enters the main screen.
final devClient = MockGrpcClient();
when(devClient.getVideos()).thenAnswer((_) => Future.value(videos));
final req = ReportRequest();
when(devClient.report(req))
.thenAnswer((_) => Future.value(ReportResponse()));
await tester
.pumpWidget(setup(widget: MainScreen(), grpcClient: devClient));
await tester.pumpAndSettle();

// WHEN a user clicks send a request.

// THEN it should send a gRPC request.
});
});
}

0 comments on commit d6be28e

Please sign in to comment.