f338752e75
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
40 lines
1.3 KiB
Dart
40 lines
1.3 KiB
Dart
import "dart:io";
|
|
import "dart:typed_data";
|
|
|
|
import "package:dartamp_skin/dartamp_skin.dart";
|
|
import "package:flutter_test/flutter_test.dart";
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
test("decodes the bundled normal cursor", () async {
|
|
final bytes = File("assets/skins/base/normal.cur").readAsBytesSync();
|
|
final cursor = await CurDecoder.decode(bytes);
|
|
expect(cursor.image.width, 32);
|
|
expect(cursor.image.height, 32);
|
|
// The classic Winamp arrow's hotspot sits at the tip, near the top-left.
|
|
expect(cursor.hotspotX, 0);
|
|
expect(cursor.hotspotY, 0);
|
|
final data = await cursor.image.toByteData();
|
|
expect(data, isNotNull);
|
|
// The arrow is not fully transparent: at least one opaque pixel exists.
|
|
var opaque = 0;
|
|
for (var i = 3; i < data!.lengthInBytes; i += 4) {
|
|
if (data.getUint8(i) != 0) opaque++;
|
|
}
|
|
expect(opaque, greaterThan(0));
|
|
});
|
|
|
|
test("rejects non-cursor files", () async {
|
|
await expectLater(
|
|
CurDecoder.decode(Uint8List.fromList([0x42, 0x4D, 0, 0])),
|
|
throwsFormatException,
|
|
);
|
|
});
|
|
|
|
test("base skin bundles the classic cursors", () async {
|
|
final skin = await loadBaseSkin();
|
|
expect(skin.cursors.keys, containsAll(["normal", "move", "resize"]));
|
|
});
|
|
}
|