Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions testing/dart/fragment_shader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import 'impeller_enabled.dart';
import 'shader_test_file_utils.dart';
Expand Down Expand Up @@ -402,22 +402,23 @@ void main() async {
path.join('supported_glsl_op_shaders', 'iplr'),
'.iplr',
);
expect(iplrSupportedGLSLOpShaders.isNotEmpty, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we losing these asserts? I see the print statement below, are we just going to fail further down in execution?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package test can't run assertions outside of a test block and these functions generate tests. I think the test will still fail approximately at the same time though?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to a fail

_expectFragmentShadersRenderGreen(iplrSupportedGLSLOpShaders);

// Test all supported instructions. See lib/spirv/lib/src/constants.dart
final Map<String, FragmentProgram> iplrSupportedOpShaders = await _loadShaderAssets(
path.join('supported_op_shaders', 'iplr'),
'.iplr',
);
expect(iplrSupportedOpShaders.isNotEmpty, true);
_expectFragmentShadersRenderGreen(iplrSupportedOpShaders);
}

// Expect that all of the shaders in this folder render green.
// Keeping the outer loop of the test synchronous allows for easy printing
// of the file name within the test case.
void _expectFragmentShadersRenderGreen(Map<String, FragmentProgram> programs) {
if (programs.isEmpty) {
print('No shaders found.');
}
for (final String key in programs.keys) {
test('FragmentProgram $key renders green', () async {
final FragmentProgram program = programs[key]!;
Expand Down
63 changes: 39 additions & 24 deletions testing/dart/platform_isolate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:isolate';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

int counter = 0;

Expand Down Expand Up @@ -62,34 +62,47 @@ void main() {
expect(await future3, 3);
});

test('PlatformIsolate runOnPlatformThread, send and receive messages',
() async {
// Send numbers 1 to 10 to the platform isolate. The platform isolate
// multiplies them by 100 and sends them back.
int sum = 0;
final RawReceivePort recvPort = RawReceivePort((Object message) {
if (message is SendPort) {
for (int i = 1; i <= 10; ++i) {
message.send(i);
}
} else {
sum += message as int;
test('PlatformIsolate runOnPlatformThread, send/receive messages', () async {
late SendPort toPlatformThread;
var sumOfReceivedMessages = 0;
var countofReceivedMessages = 0;
final recvPort = RawReceivePort((Object message) {
switch (message) {
case final SendPort sendPort:
toPlatformThread = sendPort;
for (int i = 1; i <= 10; i++) {
sendPort.send(i);
}
case final int value:
sumOfReceivedMessages += value;
countofReceivedMessages++;
if (countofReceivedMessages == 10) {
toPlatformThread.send(true);
}
default:
fail('Unexpected message: $message');
}
});
final SendPort sendPort = recvPort.sendPort;

final sendPort = recvPort.sendPort;
await runOnPlatformThread(() async {
final Completer<void> completer = Completer<void>();
final RawReceivePort recvPort = RawReceivePort((Object message) {
sendPort.send((message as int) * 100);
if (message == 10) {
completer.complete();
final completer = Completer<void>();
final recvPort = RawReceivePort((Object message) {
switch (message) {
case final int value:
sendPort.send(value * 100);
case true:
completer.complete();
default:
fail('Unexpected message: $message');
}
});
sendPort.send(recvPort.sendPort);
await completer.future;
recvPort.close();
});
expect(sum, 5500); // sum(1 to 10) * 100

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please bring back this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


expect(sumOfReceivedMessages, 5500);
recvPort.close();
});

Expand Down Expand Up @@ -122,9 +135,11 @@ void main() {

test('PlatformIsolate runOnPlatformThread, disabled on helper isolates',
() async {
await Isolate.run(() {
expect(() => runOnPlatformThread(() => print('Unreachable')), throws);
});
await expectLater(() async {
await Isolate.run(() {
return runOnPlatformThread(() => print('Unreachable'));
});
}, throws);
});

test('PlatformIsolate runOnPlatformThread, on platform isolate', () async {
Expand All @@ -134,7 +149,7 @@ void main() {
});

test('PlatformIsolate runOnPlatformThread, exit disabled', () async {
await runOnPlatformThread(() => expect(() => Isolate.exit(), throws));
await expectLater(runOnPlatformThread(() => Isolate.exit()), throws);
});

test('PlatformIsolate runOnPlatformThread, unsendable object', () async {
Expand Down
1 change: 0 additions & 1 deletion testing/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ resolution: workspace

dependencies:
ffi: any
litetest: any
path: any
skia_gold_client: any
sky_engine: any
Expand Down
5 changes: 1 addition & 4 deletions tools/clangd_check/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@ dependencies:
source_span: any

dev_dependencies:
async_helper: any
expect: any
litetest: any
process_fakes: any
smith: any