From 5ac78bf4e5bc9e0ddb189446d2e17e60fd3a9845 Mon Sep 17 00:00:00 2001 From: abdushakoor12 Date: Sat, 5 Oct 2024 09:01:33 +0500 Subject: [PATCH 1/4] bring chart behavior test back --- .../common/behavior/chart_behavior_test.dart | 33 +++++++---------- charts_common/test/mox.dart | 1 + charts_common/test/mox.mocks.dart | 36 +++++++++++++++++++ 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/charts_common/test/chart/common/behavior/chart_behavior_test.dart b/charts_common/test/chart/common/behavior/chart_behavior_test.dart index 8effc0ee4..81f4de5dd 100644 --- a/charts_common/test/chart/common/behavior/chart_behavior_test.dart +++ b/charts_common/test/chart/common/behavior/chart_behavior_test.dart @@ -13,12 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -@Tags(['skip-file']) -library; - -import 'package:test/test.dart'; -/* - import 'package:mockito/mockito.dart'; import 'package:nimble_charts_common/src/chart/common/base_chart.dart'; import 'package:nimble_charts_common/src/chart/common/behavior/chart_behavior.dart'; @@ -27,38 +21,39 @@ import 'package:nimble_charts_common/src/chart/common/selection_model/selection_ import 'package:nimble_charts_common/src/chart/common/series_renderer.dart'; import 'package:test/test.dart'; -class MockBehavior extends Mock implements ChartBehavior {} +import '../../../mox.mocks.dart'; class ParentBehavior implements ChartBehavior { ParentBehavior(this.child); final ChartBehavior child; @override - String get role => null; + String get role => ''; @override - void attachTo(BaseChart chart) { + void attachTo(BaseChart chart) { chart.addBehavior(child); } @override - void removeFrom(BaseChart chart) { + void removeFrom(BaseChart chart) { chart.removeBehavior(child); } } class ConcreteChart extends BaseChart { @override - SeriesRenderer makeDefaultRenderer() => null; + SeriesRenderer makeDefaultRenderer() => throw UnimplementedError(); @override - List> getDatumDetails(SelectionModelType _) => null; + List> getDatumDetails(SelectionModelType _) => + throw UnimplementedError(); } void main() { - ConcreteChart chart; - MockBehavior namedBehavior; - MockBehavior unnamedBehavior; + late ConcreteChart chart; + late MockBehavior namedBehavior; + late MockBehavior unnamedBehavior; setUp(() { chart = ConcreteChart(); @@ -67,7 +62,7 @@ void main() { when(namedBehavior.role).thenReturn('foo'); unnamedBehavior = MockBehavior(); - when(unnamedBehavior.role).thenReturn(null); + when(unnamedBehavior.role).thenReturn('_role_'); // can't do null here }); group('Attach & Detach', () { @@ -91,7 +86,7 @@ void main() { }); test('detach is called when name is reused', () { - final otherBehavior = MockBehavior(); + final otherBehavior = MockBehavior(); when(otherBehavior.role).thenReturn('foo'); chart.addBehavior(namedBehavior); @@ -121,7 +116,7 @@ void main() { }); test('detach is not called when name is different', () { - final otherBehavior = MockBehavior(); + final otherBehavior = MockBehavior(); when(otherBehavior.role).thenReturn('bar'); chart.addBehavior(namedBehavior); @@ -155,5 +150,3 @@ void main() { }); }); } - -*/ diff --git a/charts_common/test/mox.dart b/charts_common/test/mox.dart index b68f8df4b..9ce9c7e29 100644 --- a/charts_common/test/mox.dart +++ b/charts_common/test/mox.dart @@ -22,5 +22,6 @@ import 'package:nimble_charts_common/src/chart/cartesian/axis/time/date_time_sca MockSpec(as: #MockChart), MockSpec(), MockSpec(), + MockSpec(as: #MockBehavior), ]) void main() {} diff --git a/charts_common/test/mox.mocks.dart b/charts_common/test/mox.mocks.dart index ab25fc54d..ef51a8677 100644 --- a/charts_common/test/mox.mocks.dart +++ b/charts_common/test/mox.mocks.dart @@ -4120,3 +4120,39 @@ class MockDateTimeScale extends _i1.Mock implements _i15.DateTimeScale { returnValueForMissingStub: false, ) as bool); } + +/// A class which mocks [ChartBehavior]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockBehavior extends _i1.Mock implements _i11.ChartBehavior { + @override + String get role => (super.noSuchMethod( + Invocation.getter(#role), + returnValue: _i17.dummyValue( + this, + Invocation.getter(#role), + ), + returnValueForMissingStub: _i17.dummyValue( + this, + Invocation.getter(#role), + ), + ) as String); + + @override + void attachTo(_i11.BaseChart? chart) => super.noSuchMethod( + Invocation.method( + #attachTo, + [chart], + ), + returnValueForMissingStub: null, + ); + + @override + void removeFrom(_i11.BaseChart? chart) => super.noSuchMethod( + Invocation.method( + #removeFrom, + [chart], + ), + returnValueForMissingStub: null, + ); +} From c5925e037fa433d51b77a037f7e68579301307a7 Mon Sep 17 00:00:00 2001 From: abdushakoor12 Date: Sun, 6 Oct 2024 22:06:33 +0500 Subject: [PATCH 2/4] renderer_neartest_detail_test --- .../renderer_nearest_detail_test.dart | 121 ++++++++---------- 1 file changed, 51 insertions(+), 70 deletions(-) diff --git a/charts_common/test/chart/scatter_plot/renderer_nearest_detail_test.dart b/charts_common/test/chart/scatter_plot/renderer_nearest_detail_test.dart index 6ec770be9..634502247 100644 --- a/charts_common/test/chart/scatter_plot/renderer_nearest_detail_test.dart +++ b/charts_common/test/chart/scatter_plot/renderer_nearest_detail_test.dart @@ -1,30 +1,11 @@ -// Copyright 2018 the Charts project authors. Please see the AUTHORS file -// for details. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -@Tags(['skip-file']) -library; - -import 'package:test/test.dart'; -/* - import 'dart:math'; import 'package:mockito/mockito.dart'; import 'package:nimble_charts_common/common.dart'; import 'package:test/test.dart'; +import '../../mox.mocks.dart'; + /// Datum/Row for the chart. class MyRow { MyRow( @@ -43,14 +24,10 @@ class MyRow { final String shape; } -class MockNumericAxis extends Mock implements Axis {} - -class MockCanvas extends Mock implements ChartCanvas {} - void main() { - Rectangle layout; + late Rectangle layout; - MutableSeries makeSeries({String id, String seriesCategory}) { + MutableSeries makeSeries({required String id, String? seriesCategory}) { final data = []; final series = MutableSeries( @@ -62,13 +39,12 @@ void main() { measureFn: (row, _) => row.clickCount, seriesCategory: seriesCategory, ), - ); - - series.measureOffsetFn = (_) => 0.0; - series.colorFn = (_) => Color.fromHex(code: '#000000'); + ) + ..measureOffsetFn = ((_) => 0.0) + ..colorFn = (_) => Color.fromHex(code: '#000000'); // Mock the Domain axis results. - final domainAxis = MockNumericAxis(); + final domainAxis = MockAxis(); when(domainAxis.rangeBand).thenReturn(100); when(domainAxis.getLocation(any)) @@ -76,7 +52,7 @@ void main() { series.setAttr(domainAxisKey, domainAxis); // Mock the Measure axis results. - final measureAxis = MockNumericAxis(); + final measureAxis = MockAxis(); when(measureAxis.getLocation(any)) .thenAnswer((input) => 1.0 * (input.positionalArguments.first as num)); series.setAttr(measureAxisKey, measureAxis); @@ -93,7 +69,7 @@ void main() { 'with both selectOverlappingPoints and selectOverlappingPoints set to ' 'false', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -103,10 +79,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -126,7 +103,7 @@ void main() { 'with both selectOverlappingPoints and selectOverlappingPoints set to ' 'true and there are points inside event', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -136,10 +113,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -160,7 +138,7 @@ void main() { 'with both selectOverlappingPoints and selectOverlappingPoints set to ' 'true and there are NO points inside event', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -170,10 +148,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -193,7 +172,7 @@ void main() { 'selectOverlappingPoints == false and there are points inside event', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -203,10 +182,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -228,7 +208,7 @@ void main() { 'selectOverlappingPoints == false and there are NO points inside event', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -238,10 +218,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -262,7 +243,7 @@ void main() { 'selectOverlappingPoints == true and there are points inside event', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -272,10 +253,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -296,7 +278,7 @@ void main() { 'selectOverlappingPoints == true and there are NO points inside event', () { // Setup - final renderer = PointRenderer(config: PointRendererConfig()) + final renderer = PointRenderer(config: PointRendererConfig()) ..layout(layout, layout); final seriesList = >[ makeSeries(id: 'foo') @@ -306,10 +288,11 @@ void main() { MyRow('point3', 30, 40, 4, 0, ''), ]), ]; - renderer.configureSeries(seriesList); - renderer.preprocessSeries(seriesList); - renderer.update(seriesList, false); - renderer.paint(MockCanvas(), 1); + renderer + ..configureSeries(seriesList) + ..preprocessSeries(seriesList) + ..update(seriesList, false) + ..paint(MockCanvas(), 1); // Act final details = renderer.getNearestDatumDetailPerSeries( @@ -325,5 +308,3 @@ void main() { }); }); } - -*/ From 2273a65d581899602c53f5a3bc8b18c5b3bcafcd Mon Sep 17 00:00:00 2001 From: abdushakoor12 Date: Sun, 6 Oct 2024 22:47:14 +0500 Subject: [PATCH 3/4] domain_highlighter_test --- .../behavior/domain_highlighter_test.dart | 99 +- charts_common/test/mox.dart | 2 + charts_common/test/mox.mocks.dart | 981 ++++++++++++++++++ 3 files changed, 1037 insertions(+), 45 deletions(-) diff --git a/charts_common/test/chart/common/behavior/domain_highlighter_test.dart b/charts_common/test/chart/common/behavior/domain_highlighter_test.dart index d11235253..86e9ca195 100644 --- a/charts_common/test/chart/common/behavior/domain_highlighter_test.dart +++ b/charts_common/test/chart/common/behavior/domain_highlighter_test.dart @@ -13,12 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -@Tags(['skip-file']) -library; - -import 'package:test/test.dart'; -/* - import 'package:mockito/mockito.dart'; import 'package:nimble_charts_common/src/chart/common/base_chart.dart'; import 'package:nimble_charts_common/src/chart/common/behavior/domain_highlighter.dart'; @@ -28,45 +22,55 @@ import 'package:nimble_charts_common/src/common/material_palette.dart'; import 'package:nimble_charts_common/src/data/series.dart'; import 'package:test/test.dart'; -class MockChart extends Mock implements BaseChart { - LifecycleListener lastListener; +import '../../../mox.mocks.dart'; + +class MockChart extends MockBaseChart { + LifecycleListener? lastListener; @override - LifecycleListener addLifecycleListener(LifecycleListener listener) => - lastListener = listener; + LifecycleListener addLifecycleListener( + LifecycleListener? listener, + ) { + lastListener = listener; + return lastListener!; + } @override - bool removeLifecycleListener(LifecycleListener listener) { + bool removeLifecycleListener(LifecycleListener? listener) { expect(listener, equals(lastListener)); lastListener = null; return true; } } -class MockSelectionModel extends Mock implements MutableSelectionModel { - SelectionModelListener lastListener; +// ignore: avoid_implementing_value_types +class MockSelectionModel extends MockMutableSelectionModel { + SelectionModelListener? lastListener; @override - void addSelectionChangedListener(SelectionModelListener listener) => - lastListener = listener; + void addSelectionChangedListener(SelectionModelListener? listener) { + lastListener = listener; + } @override - void removeSelectionChangedListener(SelectionModelListener listener) { + void removeSelectionChangedListener( + SelectionModelListener? listener, + ) { expect(listener, equals(lastListener)); lastListener = null; } } void main() { - MockChart chart; - MockSelectionModel selectionModel; + late MockChart chart; + late MockSelectionModel selectionModel; - MutableSeries series1; + late MutableSeries series1; final s1D1 = MyRow('s1d1', 11); final s1D2 = MyRow('s1d2', 12); final s1D3 = MyRow('s1d3', 13); - MutableSeries series2; + late MutableSeries series2; final s2D1 = MyRow('s2d1', 21); final s2D2 = MyRow('s2d2', 22); final s2D3 = MyRow('s2d3', 23); @@ -113,31 +117,38 @@ void main() { group('DomainHighlighter', () { test('darkens the selected bars', () { // Setup - final behavior = DomainHighlighter(); - behavior.attachTo(chart); + // ignore: unused_local_variable + final behavior = DomainHighlighter() + ..attachTo(chart); setupSelection([s1D2, s2D2]); final seriesList = [series1, series2]; // Act - selectionModel.lastListener(selectionModel); + selectionModel.lastListener?.call(selectionModel); verify(chart.redraw(skipAnimation: true, skipLayout: true)); - chart.lastListener.onPostprocess(seriesList); + chart.lastListener?.onPostprocess?.call(seriesList); // Verify final s1ColorFn = series1.colorFn; - expect(s1ColorFn(0), equals(MaterialPalette.blue.shadeDefault)); - expect(s1ColorFn(1), equals(MaterialPalette.blue.shadeDefault.darker)); - expect(s1ColorFn(2), equals(MaterialPalette.blue.shadeDefault)); + expect(s1ColorFn?.call(0), equals(MaterialPalette.blue.shadeDefault)); + expect( + s1ColorFn?.call(1), + equals(MaterialPalette.blue.shadeDefault.darker), + ); + expect(s1ColorFn?.call(2), equals(MaterialPalette.blue.shadeDefault)); final s2ColorFn = series2.colorFn; - expect(s2ColorFn(0), equals(MaterialPalette.red.shadeDefault)); - expect(s2ColorFn(1), equals(MaterialPalette.red.shadeDefault.darker)); - expect(s2ColorFn(2), equals(MaterialPalette.red.shadeDefault)); + expect(s2ColorFn?.call(0), equals(MaterialPalette.red.shadeDefault)); + expect( + s2ColorFn?.call(1), + equals(MaterialPalette.red.shadeDefault.darker), + ); + expect(s2ColorFn?.call(2), equals(MaterialPalette.red.shadeDefault)); }); test('listens to other selection models', () { // Setup - final behavior = DomainHighlighter(SelectionModelType.action); + final behavior = DomainHighlighter(SelectionModelType.action); when(chart.getSelectionModel(SelectionModelType.action)) .thenReturn(selectionModel); @@ -151,32 +162,32 @@ void main() { test('leaves everything alone with no selection', () { // Setup - final behavior = DomainHighlighter(); - behavior.attachTo(chart); + // ignore: unused_local_variable + final behavior = DomainHighlighter() + ..attachTo(chart); setupSelection([]); final seriesList = [series1, series2]; // Act - selectionModel.lastListener(selectionModel); + selectionModel.lastListener?.call(selectionModel); verify(chart.redraw(skipAnimation: true, skipLayout: true)); - chart.lastListener.onPostprocess(seriesList); + chart.lastListener?.onPostprocess?.call(seriesList); // Verify final s1ColorFn = series1.colorFn; - expect(s1ColorFn(0), equals(MaterialPalette.blue.shadeDefault)); - expect(s1ColorFn(1), equals(MaterialPalette.blue.shadeDefault)); - expect(s1ColorFn(2), equals(MaterialPalette.blue.shadeDefault)); + expect(s1ColorFn?.call(0), equals(MaterialPalette.blue.shadeDefault)); + expect(s1ColorFn?.call(1), equals(MaterialPalette.blue.shadeDefault)); + expect(s1ColorFn?.call(2), equals(MaterialPalette.blue.shadeDefault)); final s2ColorFn = series2.colorFn; - expect(s2ColorFn(0), equals(MaterialPalette.red.shadeDefault)); - expect(s2ColorFn(1), equals(MaterialPalette.red.shadeDefault)); - expect(s2ColorFn(2), equals(MaterialPalette.red.shadeDefault)); + expect(s2ColorFn?.call(0), equals(MaterialPalette.red.shadeDefault)); + expect(s2ColorFn?.call(1), equals(MaterialPalette.red.shadeDefault)); + expect(s2ColorFn?.call(2), equals(MaterialPalette.red.shadeDefault)); }); test('cleans up', () { // Setup - final behavior = DomainHighlighter(); - behavior.attachTo(chart); + final behavior = DomainHighlighter()..attachTo(chart); setupSelection([s1D2, s2D2]); // Act @@ -194,5 +205,3 @@ class MyRow { final String campaign; final int count; } - -*/ diff --git a/charts_common/test/mox.dart b/charts_common/test/mox.dart index 9ce9c7e29..7328e3b79 100644 --- a/charts_common/test/mox.dart +++ b/charts_common/test/mox.dart @@ -20,8 +20,10 @@ import 'package:nimble_charts_common/src/chart/cartesian/axis/time/date_time_sca MockSpec(as: #MockNumericScale), MockSpec(as: #MockTextStyle), MockSpec(as: #MockChart), + MockSpec(), MockSpec(), MockSpec(), MockSpec(as: #MockBehavior), + MockSpec(), ]) void main() {} diff --git a/charts_common/test/mox.mocks.dart b/charts_common/test/mox.mocks.dart index ef51a8677..63ae42fa0 100644 --- a/charts_common/test/mox.mocks.dart +++ b/charts_common/test/mox.mocks.dart @@ -3421,6 +3421,810 @@ class MockChart extends _i1.Mock implements _i11.CartesianChart { ); } +/// A class which mocks [BaseChart]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockBaseChart extends _i1.Mock implements _i11.BaseChart { + @override + _i7.ChartContext get context => (super.noSuchMethod( + Invocation.getter(#context), + returnValue: _FakeChartContext_5( + this, + Invocation.getter(#context), + ), + returnValueForMissingStub: _FakeChartContext_5( + this, + Invocation.getter(#context), + ), + ) as _i7.ChartContext); + + @override + set context(_i7.ChartContext? _context) => super.noSuchMethod( + Invocation.setter( + #context, + _context, + ), + returnValueForMissingStub: null, + ); + + @override + set graphicsFactory(_i8.GraphicsFactory? _graphicsFactory) => + super.noSuchMethod( + Invocation.setter( + #graphicsFactory, + _graphicsFactory, + ), + returnValueForMissingStub: null, + ); + + @override + Duration get transition => (super.noSuchMethod( + Invocation.getter(#transition), + returnValue: _FakeDuration_14( + this, + Invocation.getter(#transition), + ), + returnValueForMissingStub: _FakeDuration_14( + this, + Invocation.getter(#transition), + ), + ) as Duration); + + @override + set transition(Duration? _transition) => super.noSuchMethod( + Invocation.setter( + #transition, + _transition, + ), + returnValueForMissingStub: null, + ); + + @override + double get animationPercent => (super.noSuchMethod( + Invocation.getter(#animationPercent), + returnValue: 0.0, + returnValueForMissingStub: 0.0, + ) as double); + + @override + set animationPercent(double? _animationPercent) => super.noSuchMethod( + Invocation.setter( + #animationPercent, + _animationPercent, + ), + returnValueForMissingStub: null, + ); + + @override + bool get isTappable => (super.noSuchMethod( + Invocation.getter(#isTappable), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool get selectExactEventLocation => (super.noSuchMethod( + Invocation.getter(#selectExactEventLocation), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool get selectNearestByDomain => (super.noSuchMethod( + Invocation.getter(#selectNearestByDomain), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool get selectOverlappingPoints => (super.noSuchMethod( + Invocation.getter(#selectOverlappingPoints), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool get chartIsDirty => (super.noSuchMethod( + Invocation.getter(#chartIsDirty), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i11.ProxyGestureListener get gestureProxy => (super.noSuchMethod( + Invocation.getter(#gestureProxy), + returnValue: _FakeProxyGestureListener_15( + this, + Invocation.getter(#gestureProxy), + ), + returnValueForMissingStub: _FakeProxyGestureListener_15( + this, + Invocation.getter(#gestureProxy), + ), + ) as _i11.ProxyGestureListener); + + @override + set defaultRenderer(_i11.SeriesRenderer? renderer) => super.noSuchMethod( + Invocation.setter( + #defaultRenderer, + renderer, + ), + returnValueForMissingStub: null, + ); + + @override + _i11.SeriesRenderer get defaultRenderer => (super.noSuchMethod( + Invocation.getter(#defaultRenderer), + returnValue: _FakeSeriesRenderer_16( + this, + Invocation.getter(#defaultRenderer), + ), + returnValueForMissingStub: _FakeSeriesRenderer_16( + this, + Invocation.getter(#defaultRenderer), + ), + ) as _i11.SeriesRenderer); + + @override + List<_i11.ChartBehavior> get behaviors => (super.noSuchMethod( + Invocation.getter(#behaviors), + returnValue: <_i11.ChartBehavior>[], + returnValueForMissingStub: <_i11.ChartBehavior>[], + ) as List<_i11.ChartBehavior>); + + @override + _i13.Rectangle get drawAreaBounds => (super.noSuchMethod( + Invocation.getter(#drawAreaBounds), + returnValue: _FakeRectangle_17( + this, + Invocation.getter(#drawAreaBounds), + ), + returnValueForMissingStub: _FakeRectangle_17( + this, + Invocation.getter(#drawAreaBounds), + ), + ) as _i13.Rectangle); + + @override + int get marginBottom => (super.noSuchMethod( + Invocation.getter(#marginBottom), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + int get marginLeft => (super.noSuchMethod( + Invocation.getter(#marginLeft), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + int get marginRight => (super.noSuchMethod( + Invocation.getter(#marginRight), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + int get marginTop => (super.noSuchMethod( + Invocation.getter(#marginTop), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + _i13.Rectangle get drawableLayoutAreaBounds => (super.noSuchMethod( + Invocation.getter(#drawableLayoutAreaBounds), + returnValue: _FakeRectangle_17( + this, + Invocation.getter(#drawableLayoutAreaBounds), + ), + returnValueForMissingStub: _FakeRectangle_17( + this, + Invocation.getter(#drawableLayoutAreaBounds), + ), + ) as _i13.Rectangle); + + @override + List<_i11.MutableSeries> get currentSeriesList => (super.noSuchMethod( + Invocation.getter(#currentSeriesList), + returnValue: <_i11.MutableSeries>[], + returnValueForMissingStub: <_i11.MutableSeries>[], + ) as List<_i11.MutableSeries>); + + @override + bool get animatingThisDraw => (super.noSuchMethod( + Invocation.getter(#animatingThisDraw), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + void init( + _i7.ChartContext? context, + _i8.GraphicsFactory? graphicsFactory, + ) => + super.noSuchMethod( + Invocation.method( + #init, + [ + context, + graphicsFactory, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void updateConfig(_i11.LayoutConfig? layoutConfig) => super.noSuchMethod( + Invocation.method( + #updateConfig, + [layoutConfig], + ), + returnValueForMissingStub: null, + ); + + @override + void resetChartDirtyFlag() => super.noSuchMethod( + Invocation.method( + #resetChartDirtyFlag, + [], + ), + returnValueForMissingStub: null, + ); + + @override + void markChartDirty() => super.noSuchMethod( + Invocation.method( + #markChartDirty, + [], + ), + returnValueForMissingStub: null, + ); + + @override + void configurationChanged() => super.noSuchMethod( + Invocation.method( + #configurationChanged, + [], + ), + returnValueForMissingStub: null, + ); + + @override + _i11.GestureListener addGestureListener(_i11.GestureListener? listener) => + (super.noSuchMethod( + Invocation.method( + #addGestureListener, + [listener], + ), + returnValue: _FakeGestureListener_20( + this, + Invocation.method( + #addGestureListener, + [listener], + ), + ), + returnValueForMissingStub: _FakeGestureListener_20( + this, + Invocation.method( + #addGestureListener, + [listener], + ), + ), + ) as _i11.GestureListener); + + @override + void removeGestureListener(_i11.GestureListener? listener) => + super.noSuchMethod( + Invocation.method( + #removeGestureListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + _i11.LifecycleListener addLifecycleListener( + _i11.LifecycleListener? listener) => + (super.noSuchMethod( + Invocation.method( + #addLifecycleListener, + [listener], + ), + returnValue: _FakeLifecycleListener_21( + this, + Invocation.method( + #addLifecycleListener, + [listener], + ), + ), + returnValueForMissingStub: _FakeLifecycleListener_21( + this, + Invocation.method( + #addLifecycleListener, + [listener], + ), + ), + ) as _i11.LifecycleListener); + + @override + bool removeLifecycleListener(_i11.LifecycleListener? listener) => + (super.noSuchMethod( + Invocation.method( + #removeLifecycleListener, + [listener], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i11.MutableSelectionModel getSelectionModel( + _i11.SelectionModelType? type) => + (super.noSuchMethod( + Invocation.method( + #getSelectionModel, + [type], + ), + returnValue: _FakeMutableSelectionModel_22( + this, + Invocation.method( + #getSelectionModel, + [type], + ), + ), + returnValueForMissingStub: _FakeMutableSelectionModel_22( + this, + Invocation.method( + #getSelectionModel, + [type], + ), + ), + ) as _i11.MutableSelectionModel); + + @override + List<_i26.DatumDetails> getDatumDetails(_i11.SelectionModelType? type) => + (super.noSuchMethod( + Invocation.method( + #getDatumDetails, + [type], + ), + returnValue: <_i26.DatumDetails>[], + returnValueForMissingStub: <_i26.DatumDetails>[], + ) as List<_i26.DatumDetails>); + + @override + void addSeriesRenderer(_i11.SeriesRenderer? renderer) => + super.noSuchMethod( + Invocation.method( + #addSeriesRenderer, + [renderer], + ), + returnValueForMissingStub: null, + ); + + @override + _i11.SeriesRenderer getSeriesRenderer(String? rendererId) => + (super.noSuchMethod( + Invocation.method( + #getSeriesRenderer, + [rendererId], + ), + returnValue: _FakeSeriesRenderer_16( + this, + Invocation.method( + #getSeriesRenderer, + [rendererId], + ), + ), + returnValueForMissingStub: _FakeSeriesRenderer_16( + this, + Invocation.method( + #getSeriesRenderer, + [rendererId], + ), + ), + ) as _i11.SeriesRenderer); + + @override + _i11.SeriesRenderer makeDefaultRenderer() => (super.noSuchMethod( + Invocation.method( + #makeDefaultRenderer, + [], + ), + returnValue: _FakeSeriesRenderer_16( + this, + Invocation.method( + #makeDefaultRenderer, + [], + ), + ), + returnValueForMissingStub: _FakeSeriesRenderer_16( + this, + Invocation.method( + #makeDefaultRenderer, + [], + ), + ), + ) as _i11.SeriesRenderer); + + @override + bool pointWithinRenderer(_i13.Point? chartPosition) => + (super.noSuchMethod( + Invocation.method( + #pointWithinRenderer, + [chartPosition], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + List<_i26.DatumDetails> getNearestDatumDetailPerSeries( + _i13.Point? drawAreaPoint, + bool? selectAcrossAllDrawAreaComponents, + ) => + (super.noSuchMethod( + Invocation.method( + #getNearestDatumDetailPerSeries, + [ + drawAreaPoint, + selectAcrossAllDrawAreaComponents, + ], + ), + returnValue: <_i26.DatumDetails>[], + returnValueForMissingStub: <_i26.DatumDetails>[], + ) as List<_i26.DatumDetails>); + + @override + List<_i26.DatumDetails> getSelectedDatumDetails( + _i11.SelectionModelType? selectionModelType) => + (super.noSuchMethod( + Invocation.method( + #getSelectedDatumDetails, + [selectionModelType], + ), + returnValue: <_i26.DatumDetails>[], + returnValueForMissingStub: <_i26.DatumDetails>[], + ) as List<_i26.DatumDetails>); + + @override + List<_i26.DatumDetails> getAllDatumDetails( + {bool? includeOverlaySeries = false}) => + (super.noSuchMethod( + Invocation.method( + #getAllDatumDetails, + [], + {#includeOverlaySeries: includeOverlaySeries}, + ), + returnValue: <_i26.DatumDetails>[], + returnValueForMissingStub: <_i26.DatumDetails>[], + ) as List<_i26.DatumDetails>); + + @override + _i11.ChartBehavior createBehavior(_i27.BehaviorCreator? creator) => + (super.noSuchMethod( + Invocation.method( + #createBehavior, + [creator], + ), + returnValue: _FakeChartBehavior_23( + this, + Invocation.method( + #createBehavior, + [creator], + ), + ), + returnValueForMissingStub: _FakeChartBehavior_23( + this, + Invocation.method( + #createBehavior, + [creator], + ), + ), + ) as _i11.ChartBehavior); + + @override + void addBehavior(_i11.ChartBehavior? behavior) => super.noSuchMethod( + Invocation.method( + #addBehavior, + [behavior], + ), + returnValueForMissingStub: null, + ); + + @override + bool removeBehavior(_i11.ChartBehavior? behavior) => (super.noSuchMethod( + Invocation.method( + #removeBehavior, + [behavior], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + void registerTappable(_i11.ChartBehavior? behavior) => super.noSuchMethod( + Invocation.method( + #registerTappable, + [behavior], + ), + returnValueForMissingStub: null, + ); + + @override + void unregisterTappable(_i11.ChartBehavior? behavior) => + super.noSuchMethod( + Invocation.method( + #unregisterTappable, + [behavior], + ), + returnValueForMissingStub: null, + ); + + @override + void measure( + int? width, + int? height, + ) => + super.noSuchMethod( + Invocation.method( + #measure, + [ + width, + height, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void layout( + int? width, + int? height, + ) => + super.noSuchMethod( + Invocation.method( + #layout, + [ + width, + height, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void layoutInternal( + int? width, + int? height, + ) => + super.noSuchMethod( + Invocation.method( + #layoutInternal, + [ + width, + height, + ], + ), + returnValueForMissingStub: null, + ); + + @override + void addView(_i10.LayoutView? view) => super.noSuchMethod( + Invocation.method( + #addView, + [view], + ), + returnValueForMissingStub: null, + ); + + @override + void removeView(_i10.LayoutView? view) => super.noSuchMethod( + Invocation.method( + #removeView, + [view], + ), + returnValueForMissingStub: null, + ); + + @override + bool withinDrawArea(_i13.Point? point) => (super.noSuchMethod( + Invocation.method( + #withinDrawArea, + [point], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + void draw(List<_i11.Series>? seriesList) => super.noSuchMethod( + Invocation.method( + #draw, + [seriesList], + ), + returnValueForMissingStub: null, + ); + + @override + void redraw({ + bool? skipAnimation = false, + bool? skipLayout = false, + }) => + super.noSuchMethod( + Invocation.method( + #redraw, + [], + { + #skipAnimation: skipAnimation, + #skipLayout: skipLayout, + }, + ), + returnValueForMissingStub: null, + ); + + @override + void drawInternal( + List<_i11.MutableSeries>? seriesList, { + bool? skipAnimation, + bool? skipLayout, + }) => + super.noSuchMethod( + Invocation.method( + #drawInternal, + [seriesList], + { + #skipAnimation: skipAnimation, + #skipLayout: skipLayout, + }, + ), + returnValueForMissingStub: null, + ); + + @override + _i11.MutableSeries makeSeries(_i11.Series? series) => + (super.noSuchMethod( + Invocation.method( + #makeSeries, + [series], + ), + returnValue: _FakeMutableSeries_19( + this, + Invocation.method( + #makeSeries, + [series], + ), + ), + returnValueForMissingStub: _FakeMutableSeries_19( + this, + Invocation.method( + #makeSeries, + [series], + ), + ), + ) as _i11.MutableSeries); + + @override + void configureSeries(List<_i11.MutableSeries>? seriesList) => + super.noSuchMethod( + Invocation.method( + #configureSeries, + [seriesList], + ), + returnValueForMissingStub: null, + ); + + @override + Map>> preprocessSeries( + List<_i11.MutableSeries>? seriesList) => + (super.noSuchMethod( + Invocation.method( + #preprocessSeries, + [seriesList], + ), + returnValue: >>{}, + returnValueForMissingStub: >>{}, + ) as Map>>); + + @override + void onSkipLayout() => super.noSuchMethod( + Invocation.method( + #onSkipLayout, + [], + ), + returnValueForMissingStub: null, + ); + + @override + void onPostLayout( + Map>>? rendererToSeriesList) => + super.noSuchMethod( + Invocation.method( + #onPostLayout, + [rendererToSeriesList], + ), + returnValueForMissingStub: null, + ); + + @override + void paint(_i20.ChartCanvas? canvas) => super.noSuchMethod( + Invocation.method( + #paint, + [canvas], + ), + returnValueForMissingStub: null, + ); + + @override + void fireOnDraw(List<_i11.MutableSeries>? seriesList) => + super.noSuchMethod( + Invocation.method( + #fireOnDraw, + [seriesList], + ), + returnValueForMissingStub: null, + ); + + @override + void fireOnPreprocess(List<_i11.MutableSeries>? seriesList) => + super.noSuchMethod( + Invocation.method( + #fireOnPreprocess, + [seriesList], + ), + returnValueForMissingStub: null, + ); + + @override + void fireOnPostprocess(List<_i11.MutableSeries>? seriesList) => + super.noSuchMethod( + Invocation.method( + #fireOnPostprocess, + [seriesList], + ), + returnValueForMissingStub: null, + ); + + @override + void fireOnAxisConfigured() => super.noSuchMethod( + Invocation.method( + #fireOnAxisConfigured, + [], + ), + returnValueForMissingStub: null, + ); + + @override + void fireOnPostrender(_i20.ChartCanvas? canvas) => super.noSuchMethod( + Invocation.method( + #fireOnPostrender, + [canvas], + ), + returnValueForMissingStub: null, + ); + + @override + void fireOnAnimationComplete() => super.noSuchMethod( + Invocation.method( + #fireOnAnimationComplete, + [], + ), + returnValueForMissingStub: null, + ); + + @override + void destroy() => super.noSuchMethod( + Invocation.method( + #destroy, + [], + ), + returnValueForMissingStub: null, + ); +} + /// A class which mocks [OrdinalAxis]. /// /// See the documentation for Mockito's code generation for more information. @@ -4156,3 +4960,180 @@ class MockBehavior extends _i1.Mock implements _i11.ChartBehavior { returnValueForMissingStub: null, ); } + +/// A class which mocks [MutableSelectionModel]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMutableSelectionModel extends _i1.Mock + implements _i11.MutableSelectionModel { + @override + set locked(bool? locked) => super.noSuchMethod( + Invocation.setter( + #locked, + locked, + ), + returnValueForMissingStub: null, + ); + + @override + bool get locked => (super.noSuchMethod( + Invocation.getter(#locked), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool get hasDatumSelection => (super.noSuchMethod( + Invocation.getter(#hasDatumSelection), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + List<_i11.SeriesDatum> get selectedDatum => (super.noSuchMethod( + Invocation.getter(#selectedDatum), + returnValue: <_i11.SeriesDatum>[], + returnValueForMissingStub: <_i11.SeriesDatum>[], + ) as List<_i11.SeriesDatum>); + + @override + bool get hasSeriesSelection => (super.noSuchMethod( + Invocation.getter(#hasSeriesSelection), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + List<_i11.ImmutableSeries> get selectedSeries => (super.noSuchMethod( + Invocation.getter(#selectedSeries), + returnValue: <_i11.ImmutableSeries>[], + returnValueForMissingStub: <_i11.ImmutableSeries>[], + ) as List<_i11.ImmutableSeries>); + + @override + bool get hasAnySelection => (super.noSuchMethod( + Invocation.getter(#hasAnySelection), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool clearSelection({bool? notifyListeners = true}) => (super.noSuchMethod( + Invocation.method( + #clearSelection, + [], + {#notifyListeners: notifyListeners}, + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool updateSelection( + List<_i11.SeriesDatum>? datumSelection, + List<_i11.ImmutableSeries>? seriesList, { + bool? notifyListeners = true, + }) => + (super.noSuchMethod( + Invocation.method( + #updateSelection, + [ + datumSelection, + seriesList, + ], + {#notifyListeners: notifyListeners}, + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + void addSelectionChangedListener(_i11.SelectionModelListener? listener) => + super.noSuchMethod( + Invocation.method( + #addSelectionChangedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void removeSelectionChangedListener( + _i11.SelectionModelListener? listener) => + super.noSuchMethod( + Invocation.method( + #removeSelectionChangedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void addSelectionUpdatedListener(_i11.SelectionModelListener? listener) => + super.noSuchMethod( + Invocation.method( + #addSelectionUpdatedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void removeSelectionUpdatedListener( + _i11.SelectionModelListener? listener) => + super.noSuchMethod( + Invocation.method( + #removeSelectionUpdatedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void addSelectionLockChangedListener( + _i11.SelectionModelListener? listener) => + super.noSuchMethod( + Invocation.method( + #addSelectionLockChangedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void removeSelectionLockChangedListener( + _i11.SelectionModelListener? listener) => + super.noSuchMethod( + Invocation.method( + #removeSelectionLockChangedListener, + [listener], + ), + returnValueForMissingStub: null, + ); + + @override + void clearAllListeners() => super.noSuchMethod( + Invocation.method( + #clearAllListeners, + [], + ), + returnValueForMissingStub: null, + ); + + @override + bool isDatumSelected( + _i11.ImmutableSeries? series, + int? index, + ) => + (super.noSuchMethod( + Invocation.method( + #isDatumSelected, + [ + series, + index, + ], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); +} From 03540d992af781e30bf13b4d0b2e8fea0e768349 Mon Sep 17 00:00:00 2001 From: abdushakoor12 Date: Sun, 6 Oct 2024 22:48:40 +0500 Subject: [PATCH 4/4] format --- .../test/chart/common/behavior/domain_highlighter_test.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/charts_common/test/chart/common/behavior/domain_highlighter_test.dart b/charts_common/test/chart/common/behavior/domain_highlighter_test.dart index 86e9ca195..4fbfc10e8 100644 --- a/charts_common/test/chart/common/behavior/domain_highlighter_test.dart +++ b/charts_common/test/chart/common/behavior/domain_highlighter_test.dart @@ -118,8 +118,7 @@ void main() { test('darkens the selected bars', () { // Setup // ignore: unused_local_variable - final behavior = DomainHighlighter() - ..attachTo(chart); + final behavior = DomainHighlighter()..attachTo(chart); setupSelection([s1D2, s2D2]); final seriesList = [series1, series2]; @@ -163,8 +162,7 @@ void main() { test('leaves everything alone with no selection', () { // Setup // ignore: unused_local_variable - final behavior = DomainHighlighter() - ..attachTo(chart); + final behavior = DomainHighlighter()..attachTo(chart); setupSelection([]); final seriesList = [series1, series2];