📝 Added tests for toString to increase coverage (#82235)
This commit is contained in:
parent
d10afc41df
commit
0581c05c88
@ -6,6 +6,7 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
import 'message_codec.dart';
|
||||
@ -258,7 +259,7 @@ class AndroidPointerProperties {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AndroidPointerProperties(id: $id, toolType: $toolType)';
|
||||
return '${objectRuntimeType(this, 'AndroidPointerProperties')}(id: $id, toolType: $toolType)';
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,7 +343,7 @@ class AndroidPointerCoords {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AndroidPointerCoords(orientation: $orientation, pressure: $pressure, size: $size, toolMajor: $toolMajor, toolMinor: $toolMinor, touchMajor: $touchMajor, touchMinor: $touchMinor, x: $x, y: $y)';
|
||||
return '${objectRuntimeType(this, 'AndroidPointerCoords')}(orientation: $orientation, pressure: $pressure, size: $size, toolMajor: $toolMajor, toolMinor: $toolMinor, touchMajor: $touchMajor, touchMinor: $touchMinor, x: $x, y: $y)';
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,7 +483,7 @@ class AndroidMotionEvent {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AndroidPointerEvent(downTime: $downTime, eventTime: $eventTime, action: $action, pointerCount: $pointerCount, pointerProperties: $pointerProperties, pointerCoords: $pointerCoords, metaState: $metaState, buttonState: $buttonState, xPrecision: $xPrecision, yPrecision: $yPrecision, deviceId: $deviceId, edgeFlags: $edgeFlags, source: $source, flags: $flags)';
|
||||
return 'AndroidPointerEvent(downTime: $downTime, eventTime: $eventTime, action: $action, pointerCount: $pointerCount, pointerProperties: $pointerProperties, pointerCoords: $pointerCoords, metaState: $metaState, buttonState: $buttonState, xPrecision: $xPrecision, yPrecision: $yPrecision, deviceId: $deviceId, edgeFlags: $edgeFlags, source: $source, flags: $flags, motionEventId: $motionEventId)';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ class SystemUiOverlayStyle {
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => _toMap().toString();
|
||||
String toString() => '${objectRuntimeType(this, 'SystemUiOverlayStyle')}(${_toMap()})';
|
||||
|
||||
/// Creates a copy of this theme with the given fields replaced with new values.
|
||||
SystemUiOverlayStyle copyWith({
|
||||
|
@ -75,4 +75,11 @@ void main() {
|
||||
' HTTP status code: 404\n',
|
||||
);
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/39998
|
||||
|
||||
test('toString works as intended', () {
|
||||
final Uri uri = Uri.http('example.org', '/path');
|
||||
final NetworkAssetBundle bundle = NetworkAssetBundle(uri);
|
||||
|
||||
expect(bundle.toString(), 'NetworkAssetBundle#${shortHash(bundle)}($uri)');
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/39998
|
||||
}
|
||||
|
@ -255,4 +255,14 @@ void main() {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('toString works as intended', () async {
|
||||
const MethodCall methodCall = MethodCall('sample method');
|
||||
final PlatformException platformException = PlatformException(code: '100');
|
||||
final MissingPluginException missingPluginException = MissingPluginException();
|
||||
|
||||
expect(methodCall.toString(), 'MethodCall(sample method, null)');
|
||||
expect(platformException.toString(), 'PlatformException(100, null, null, null)');
|
||||
expect(missingPluginException.toString(), 'MissingPluginException(null)');
|
||||
});
|
||||
}
|
||||
|
@ -300,4 +300,66 @@ void main() {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('toString works as intended', () async {
|
||||
const AndroidPointerProperties androidPointerProperties = AndroidPointerProperties(id: 0, toolType: 0);
|
||||
expect(androidPointerProperties.toString(), 'AndroidPointerProperties(id: 0, toolType: 0)');
|
||||
|
||||
const double zero = 0.0;
|
||||
const AndroidPointerCoords androidPointerCoords = AndroidPointerCoords(
|
||||
orientation: zero,
|
||||
pressure: zero,
|
||||
size: zero,
|
||||
toolMajor: zero,
|
||||
toolMinor: zero,
|
||||
touchMajor: zero,
|
||||
touchMinor: zero,
|
||||
x: zero,
|
||||
y: zero
|
||||
);
|
||||
expect(androidPointerCoords.toString(), 'AndroidPointerCoords(orientation: $zero, '
|
||||
'pressure: $zero, '
|
||||
'size: $zero, '
|
||||
'toolMajor: $zero, '
|
||||
'toolMinor: $zero, '
|
||||
'touchMajor: $zero, '
|
||||
'touchMinor: $zero, '
|
||||
'x: $zero, '
|
||||
'y: $zero)',
|
||||
);
|
||||
|
||||
final AndroidMotionEvent androidMotionEvent = AndroidMotionEvent(
|
||||
downTime: 0,
|
||||
eventTime: 0,
|
||||
action: 0,
|
||||
pointerCount: 0,
|
||||
pointerProperties: <AndroidPointerProperties>[],
|
||||
pointerCoords: <AndroidPointerCoords>[],
|
||||
metaState: 0,
|
||||
buttonState: 0,
|
||||
xPrecision: zero,
|
||||
yPrecision: zero,
|
||||
deviceId: 0,
|
||||
edgeFlags: 0,
|
||||
source: 0,
|
||||
flags: 0,
|
||||
motionEventId: 0
|
||||
);
|
||||
expect(androidMotionEvent.toString(), 'AndroidPointerEvent(downTime: 0, '
|
||||
'eventTime: 0, '
|
||||
'action: 0, '
|
||||
'pointerCount: 0, '
|
||||
'pointerProperties: [], '
|
||||
'pointerCoords: [], '
|
||||
'metaState: 0, '
|
||||
'buttonState: 0, '
|
||||
'xPrecision: $zero, '
|
||||
'yPrecision: $zero, '
|
||||
'deviceId: 0, '
|
||||
'edgeFlags: 0, '
|
||||
'source: 0, '
|
||||
'flags: 0, '
|
||||
'motionEventId: 0)',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -86,4 +86,17 @@ void main() {
|
||||
arguments: <String>['SystemUiOverlay.top'],
|
||||
));
|
||||
});
|
||||
|
||||
test('toString works as intended', () async {
|
||||
const SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle();
|
||||
|
||||
expect(systemUiOverlayStyle.toString(), 'SystemUiOverlayStyle({'
|
||||
'systemNavigationBarColor: null, '
|
||||
'systemNavigationBarDividerColor: null, '
|
||||
'statusBarColor: null, '
|
||||
'statusBarBrightness: null, '
|
||||
'statusBarIconBrightness: null, '
|
||||
'systemNavigationBarIconBrightness: null})',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user