Skip to content

Commit

Permalink
Update the analysis_options to include the tests/ directory and fixed…
Browse files Browse the repository at this point in the history
… the analysis issues
  • Loading branch information
imaNNeo committed Dec 27, 2024
1 parent 9918c94 commit 32f0b58
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 46 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ include: package:very_good_analysis/analysis_options.yaml
analyzer:
exclude:
- "**.mocks.dart"
- "test/**"
linter:
rules:
always_put_required_named_parameters_first: false
Expand Down
6 changes: 6 additions & 0 deletions test/chart/bar_chart/bar_chart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ void main() {
createTestWidget(
chart: BarChart(
BarChartData(alignment: alignment),
// This is for test
// ignore: avoid_redundant_argument_values
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
),
Expand Down Expand Up @@ -228,8 +230,10 @@ void main() {
createTestWidget(
chart: BarChart(
BarChartData(),
// This is for test
// ignore: avoid_redundant_argument_values
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
),
Expand Down Expand Up @@ -756,6 +760,7 @@ void main() {
chart: BarChart(
BarChartData(),
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
trackpadScrollCausesScale: true,
Expand Down Expand Up @@ -791,6 +796,7 @@ void main() {
BarChartData(),
transformationConfig: FlTransformationConfig(
scaleAxis: scaleAxis,
// This is for test
// ignore: avoid_redundant_argument_values
trackpadScrollCausesScale: false,
),
Expand Down
75 changes: 41 additions & 34 deletions test/chart/base/axis_chart/axis_chart_scaffold_widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ void main() {
height: viewSize.height,
child: AxisChartScaffoldWidget(
data: lineChartDataWithAllTitles,
// This is for test
// ignore: avoid_redundant_argument_values
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
),
Expand Down Expand Up @@ -1245,8 +1247,10 @@ void main() {
height: 300,
child: LineChart(
lineChartDataWithNoTitles,
// This is for test
// ignore: avoid_redundant_argument_values
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
),
Expand Down Expand Up @@ -1309,51 +1313,51 @@ void main() {
'oldWidget.controller is null and widget.controller is null: '
'keeps old controller',
(WidgetTester tester) async {
final actualchartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final actualChartVirtualRects = <Object?>[isNotScaled, isNotScaled];
await tester.pumpWidget(createTestWidget());
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects);
expect(chartVirtualRects, actualChartVirtualRects);

final transformationController = getTransformationController(tester);
transformationController!.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

await tester.pumpWidget(createTestWidget());
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

final transformationController2 = getTransformationController(tester);
expect(transformationController2, transformationController);
transformationController2!.value = Matrix4.identity()..scale(3.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
},
);

testWidgets(
'oldWidget.controller is null and widget.controller is not null: '
'disposes old controller and sets up widget.controller with listeners',
(WidgetTester tester) async {
final actualchartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final actualChartVirtualRects = <Object?>[isNotScaled, isNotScaled];
await tester.pumpWidget(createTestWidget());
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects);
expect(chartVirtualRects, actualChartVirtualRects);

final transformationController = getTransformationController(tester);
transformationController!.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

final transformationController2 = TransformationController();

await tester.pumpWidget(
createTestWidget(controller: transformationController2),
);
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled));

expect(transformationController2, isNot(transformationController));
expect(
Expand All @@ -1362,7 +1366,7 @@ void main() {
);
transformationController2.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
},
);

Expand All @@ -1371,31 +1375,32 @@ void main() {
'removes listeners from old controller and sets up new controller '
'with listeners',
(WidgetTester tester) async {
final actualchartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final actualChartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final transformationController = TransformationController();
await tester.pumpWidget(
createTestWidget(controller: transformationController),
);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects);
expect(chartVirtualRects, actualChartVirtualRects);

transformationController.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

await tester.pumpWidget(createTestWidget());
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled));

final transformationController2 = getTransformationController(tester);
expect(transformationController2, isNot(transformationController));
// This is for test
// ignore: invalid_use_of_protected_member
expect(transformationController.hasListeners, false);
transformationController.addListener(() {}); // throws if disposed
transformationController2!.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
},
);

Expand All @@ -1405,69 +1410,70 @@ void main() {
'removes listeners from old controller and sets up '
'widget.controller with listeners',
(WidgetTester tester) async {
final actualchartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final actualChartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final transformationController = TransformationController();
await tester.pumpWidget(
createTestWidget(controller: transformationController),
);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects);
expect(chartVirtualRects, actualChartVirtualRects);

transformationController.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

final transformationController2 = TransformationController();

await tester.pumpWidget(
createTestWidget(controller: transformationController2),
);
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled));

expect(transformationController2, isNot(transformationController));
// This is for test
// ignore: invalid_use_of_protected_member
expect(transformationController.hasListeners, false);
transformationController.addListener(() {}); // throws if disposed
transformationController2.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
},
);

testWidgets(
'oldWidget.controller is not null and widget.controller is not null, '
'controllers are the same: keeps old controller',
(WidgetTester tester) async {
final actualchartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final actualChartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final transformationController = TransformationController();
await tester.pumpWidget(
createTestWidget(
controller: transformationController,
),
);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects);
expect(chartVirtualRects, actualChartVirtualRects);

transformationController.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

await tester.pumpWidget(
createTestWidget(
controller: transformationController,
),
);
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

final transformationController2 = getTransformationController(tester);
expect(transformationController2, transformationController);
transformationController.value = Matrix4.identity()..scale(3.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));
},
);
});
Expand All @@ -1477,7 +1483,7 @@ void main() {
(WidgetTester tester) async {
final transformationController = TransformationController();
final chartVirtualRects = <Rect?>[];
final actualchartVirtualRects = <Object?>[isNotScaled, isNotScaled];
final actualChartVirtualRects = <Object?>[isNotScaled, isNotScaled];
await tester.pumpWidget(
MaterialApp(
home: AxisChartScaffoldWidget(
Expand All @@ -1493,15 +1499,15 @@ void main() {
),
);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects);
expect(chartVirtualRects, actualChartVirtualRects);

transformationController.value = Matrix4.identity()..scale(2.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isScaled));

transformationController.value = Matrix4.identity()..scale(1.0);
await tester.pump();
expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled));
expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled));
},
);

Expand All @@ -1522,6 +1528,7 @@ void main() {
),
);
await tester.pumpWidget(Container());
// This is for test
// ignore: invalid_use_of_protected_member
expect(controller.hasListeners, false);
controller.addListener(() {}); // throws if disposed
Expand Down
21 changes: 10 additions & 11 deletions test/chart/base/axis_chart/axis_chart_widgets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import 'package:flutter_test/flutter_test.dart';

void main() {
TitleMeta getTitleMeta(AxisSide axisSide) => TitleMeta(
min: 0,
max: 10,
parentAxisSize: 100,
axisPosition: 10,
appliedInterval: 10,
sideTitles: const SideTitles(),
formattedValue: '12',
axisSide: axisSide,
rotationQuarterTurns: 0,
);

min: 0,
max: 10,
parentAxisSize: 100,
axisPosition: 10,
appliedInterval: 10,
sideTitles: const SideTitles(),
formattedValue: '12',
axisSide: axisSide,
rotationQuarterTurns: 0,
);

group(
'SideTitle without FitInside enabled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ void main() {
const Size(viewSize, 40),
);
expect(
// This is for test
// ignore: invalid_use_of_protected_member
renderFlex.computeDistanceToActualBaseline(TextBaseline.alphabetic),
null,
Expand All @@ -213,6 +214,7 @@ void main() {
const Size(viewSize, 40),
);
expect(
// This is for test
// ignore: invalid_use_of_protected_member
renderFlex.computeDistanceToActualBaseline(TextBaseline.alphabetic),
null,
Expand Down
4 changes: 4 additions & 0 deletions test/chart/line_chart/line_chart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ void main() {
createTestWidget(
chart: LineChart(
LineChartData(),
// This is for test
// ignore: avoid_redundant_argument_values
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
),
Expand Down Expand Up @@ -647,6 +649,7 @@ void main() {
chart: LineChart(
LineChartData(),
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
trackpadScrollCausesScale: true,
Expand Down Expand Up @@ -684,6 +687,7 @@ void main() {
LineChartData(),
transformationConfig: FlTransformationConfig(
scaleAxis: scaleAxis,
// This is for test
// ignore: avoid_redundant_argument_values
trackpadScrollCausesScale: false,
),
Expand Down
4 changes: 4 additions & 0 deletions test/chart/scatter_chart/scatter_chart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ void main() {
createTestWidget(
chart: ScatterChart(
ScatterChartData(),
// This is for test
// ignore: avoid_redundant_argument_values
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
),
Expand Down Expand Up @@ -646,6 +648,7 @@ void main() {
chart: ScatterChart(
ScatterChartData(),
transformationConfig: const FlTransformationConfig(
// This is for test
// ignore: avoid_redundant_argument_values
scaleAxis: FlScaleAxis.none,
trackpadScrollCausesScale: true,
Expand Down Expand Up @@ -682,6 +685,7 @@ void main() {
ScatterChartData(),
transformationConfig: FlTransformationConfig(
scaleAxis: scaleAxis,
// This is for test
// ignore: avoid_redundant_argument_values
trackpadScrollCausesScale: false,
),
Expand Down

0 comments on commit 32f0b58

Please sign in to comment.