mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Migrate some more non-test utils for tests (#67351)
This commit is contained in:
parent
8998167d0f
commit
42fa4f033b
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
class Dessert {
|
class Dessert {
|
||||||
Dessert(this.name, this.calories, this.fat, this.carbs, this.protein, this.sodium, this.calcium, this.iron);
|
Dessert(this.name, this.calories, this.fat, this.carbs, this.protein, this.sodium, this.calcium, this.iron);
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
/// Tracks how often feedback has been requested since its instantiation.
|
/// Tracks how often feedback has been requested since its instantiation.
|
||||||
|
@ -10,7 +10,6 @@ import 'package:flutter/painting.dart';
|
|||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
|
||||||
class TestImageProvider extends ImageProvider<TestImageProvider> {
|
class TestImageProvider extends ImageProvider<TestImageProvider> {
|
||||||
TestImageProvider(this.testImage);
|
TestImageProvider(this.testImage);
|
||||||
|
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
|
|
||||||
void checkEncoding<T>(MessageCodec<T> codec, T message, List<int> expectedBytes) {
|
void checkEncoding<T>(MessageCodec<T> codec, T message, List<int> expectedBytes) {
|
||||||
final ByteData encoded = codec.encodeMessage(message);
|
final ByteData encoded = codec.encodeMessage(message)!;
|
||||||
expect(
|
expect(
|
||||||
encoded.buffer.asUint8List(0, encoded.lengthInBytes),
|
encoded.buffer.asUint8List(0, encoded.lengthInBytes),
|
||||||
orderedEquals(expectedBytes),
|
orderedEquals(expectedBytes),
|
||||||
@ -18,17 +16,17 @@ void checkEncoding<T>(MessageCodec<T> codec, T message, List<int> expectedBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkEncodeDecode<T>(MessageCodec<T> codec, T message) {
|
void checkEncodeDecode<T>(MessageCodec<T> codec, T message) {
|
||||||
final ByteData encoded = codec.encodeMessage(message);
|
final ByteData? encoded = codec.encodeMessage(message);
|
||||||
final T decoded = codec.decodeMessage(encoded);
|
final T decoded = codec.decodeMessage(encoded);
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
expect(encoded, isNull);
|
expect(encoded, isNull);
|
||||||
expect(decoded, isNull);
|
expect(decoded, isNull);
|
||||||
} else {
|
} else {
|
||||||
expect(deepEquals(message, decoded), isTrue);
|
expect(deepEquals(message, decoded), isTrue);
|
||||||
final ByteData encodedAgain = codec.encodeMessage(decoded);
|
final ByteData encodedAgain = codec.encodeMessage(decoded)!;
|
||||||
expect(
|
expect(
|
||||||
encodedAgain.buffer.asUint8List(),
|
encodedAgain.buffer.asUint8List(),
|
||||||
orderedEquals(encoded.buffer.asUint8List()),
|
orderedEquals(encoded!.buffer.asUint8List()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user