mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
chore(mobile): add orientation tests for exif (#16806)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
2be8b6c16d
commit
653fa3f0b1
18
mobile/test/fixtures/exif.stub.dart
vendored
Normal file
18
mobile/test/fixtures/exif.stub.dart
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||||
|
|
||||||
|
abstract final class ExifStub {
|
||||||
|
static final size = const ExifInfo(assetId: 1, fileSize: 1000);
|
||||||
|
|
||||||
|
static final gps = const ExifInfo(
|
||||||
|
assetId: 2,
|
||||||
|
latitude: 20,
|
||||||
|
longitude: 20,
|
||||||
|
city: 'city',
|
||||||
|
state: 'state',
|
||||||
|
country: 'country',
|
||||||
|
);
|
||||||
|
|
||||||
|
static final rotated90CW = const ExifInfo(assetId: 3, orientation: "90");
|
||||||
|
|
||||||
|
static final rotated270CW = const ExifInfo(assetId: 4, orientation: "-90");
|
||||||
|
}
|
14
mobile/test/fixtures/user.stub.dart
vendored
14
mobile/test/fixtures/user.stub.dart
vendored
@ -1,6 +1,6 @@
|
|||||||
import 'package:immich_mobile/entities/user.entity.dart';
|
import 'package:immich_mobile/entities/user.entity.dart';
|
||||||
|
|
||||||
final class UserStub {
|
abstract final class UserStub {
|
||||||
const UserStub._();
|
const UserStub._();
|
||||||
|
|
||||||
static final admin = User(
|
static final admin = User(
|
||||||
@ -8,9 +8,9 @@ final class UserStub {
|
|||||||
updatedAt: DateTime(2021),
|
updatedAt: DateTime(2021),
|
||||||
email: "admin@test.com",
|
email: "admin@test.com",
|
||||||
name: "admin",
|
name: "admin",
|
||||||
avatarColor: AvatarColorEnum.green,
|
|
||||||
profileImagePath: '',
|
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
|
profileImagePath: '',
|
||||||
|
avatarColor: AvatarColorEnum.green,
|
||||||
);
|
);
|
||||||
|
|
||||||
static final user1 = User(
|
static final user1 = User(
|
||||||
@ -18,9 +18,9 @@ final class UserStub {
|
|||||||
updatedAt: DateTime(2022),
|
updatedAt: DateTime(2022),
|
||||||
email: "user1@test.com",
|
email: "user1@test.com",
|
||||||
name: "user1",
|
name: "user1",
|
||||||
avatarColor: AvatarColorEnum.red,
|
|
||||||
profileImagePath: '',
|
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
|
profileImagePath: '',
|
||||||
|
avatarColor: AvatarColorEnum.red,
|
||||||
);
|
);
|
||||||
|
|
||||||
static final user2 = User(
|
static final user2 = User(
|
||||||
@ -28,8 +28,8 @@ final class UserStub {
|
|||||||
updatedAt: DateTime(2023),
|
updatedAt: DateTime(2023),
|
||||||
email: "user2@test.com",
|
email: "user2@test.com",
|
||||||
name: "user2",
|
name: "user2",
|
||||||
avatarColor: AvatarColorEnum.primary,
|
|
||||||
profileImagePath: '',
|
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
|
profileImagePath: '',
|
||||||
|
avatarColor: AvatarColorEnum.primary,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:immich_mobile/domain/interfaces/exif.interface.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/repositories/exif.repository.dart';
|
||||||
|
import 'package:isar/isar.dart';
|
||||||
|
|
||||||
|
import '../../fixtures/exif.stub.dart';
|
||||||
|
import '../../test_utils.dart';
|
||||||
|
|
||||||
|
Future<void> _populateExifTable(Isar db) async {
|
||||||
|
await db.writeTxn(() async {
|
||||||
|
await db.exifInfos.putAll([
|
||||||
|
ExifInfo.fromDto(ExifStub.size),
|
||||||
|
ExifInfo.fromDto(ExifStub.gps),
|
||||||
|
ExifInfo.fromDto(ExifStub.rotated90CW),
|
||||||
|
ExifInfo.fromDto(ExifStub.rotated270CW),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
late Isar db;
|
||||||
|
late IExifInfoRepository sut;
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
db = await TestUtils.initIsar();
|
||||||
|
sut = IsarExifRepository(db);
|
||||||
|
});
|
||||||
|
|
||||||
|
group("Return with proper orientation", () {
|
||||||
|
setUp(() async {
|
||||||
|
await _populateExifTable(db);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("isFlipped true for 90CW", () async {
|
||||||
|
final exif = await sut.get(ExifStub.rotated90CW.assetId!);
|
||||||
|
expect(exif!.isFlipped, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("isFlipped true for 270CW", () async {
|
||||||
|
final exif = await sut.get(ExifStub.rotated270CW.assetId!);
|
||||||
|
expect(exif!.isFlipped, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("isFlipped false for the original non-rotated image", () async {
|
||||||
|
final exif = await sut.get(ExifStub.size.assetId!);
|
||||||
|
expect(exif!.isFlipped, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user