From dec0b7251fe5e3710efebc386bb4e0d1c284842c Mon Sep 17 00:00:00 2001 From: 4sterisk <4sterisk@ymail.ne.jp> Date: Wed, 13 Nov 2024 17:26:11 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E5=83=8F=E8=AA=AD=E8=BE=BC=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3=E3=83=BC=E3=83=89=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/assets/images/exif_ifd_only.jpg | Bin 0 -> 281 bytes test/assets/images/exif_no_data.jpg | Bin 0 -> 203 bytes test/assets/images/exif_test.jpg | Bin 0 -> 429 bytes test/assets/images/test.gif | Bin 0 -> 156 bytes test/assets/images/test.png | Bin 0 -> 273 bytes .../note_create_page/image_exif_test.dart | 82 ++++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 test/assets/images/exif_ifd_only.jpg create mode 100644 test/assets/images/exif_no_data.jpg create mode 100644 test/assets/images/exif_test.jpg create mode 100644 test/assets/images/test.gif create mode 100644 test/assets/images/test.png create mode 100644 test/state_notifier/note_create_page/image_exif_test.dart diff --git a/test/assets/images/exif_ifd_only.jpg b/test/assets/images/exif_ifd_only.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c23bf4db2091f84bbc714e556924a53e57f712e5 GIT binary patch literal 281 zcmaJ+%MHRX41H-z6sNzWg$pCF1P4SV5Z!@8h13n$fHit%3Jwgx=K_-ir&15S@GRTU zezIlzhyTFt>s<{Y0Ko?T#bJByPC(OO1wcbwI>gLa#gZM6y@2FAO!U#HO7wE%VSu;2 zv4M;NLX?bH#Q|EWnIdfrX(E#rsY&vLD05j}SnI4w%c`^$bL($NG+MMmIQTmj!?nZy ZF%Y-sHXJyCe?f=O*0>%g!oQ;M&mUgR9CZKy literal 0 HcmV?d00001 diff --git a/test/assets/images/exif_no_data.jpg b/test/assets/images/exif_no_data.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ecbbcbc756475bd92c91ee94aceb8bf7d4c18b39 GIT binary patch literal 203 zcmaKmF%H5o3`M_biDD;hoEFZ*fK&-i!O+uj3I+~QVBsbvVWJD~OVdL(kJ` z0uew(uosSKHkDeNLhIU!cW&$0i?C;wn4*L}Fn77@lWJCp!#L2}9oPGS1{^z6Vc^pbv(H*Q9+duXb9!2sRWM17-Qr%yyTTYV`<;)Giq z$LsuD^6?}2YpesGCQ3nXTQu}0vm9a!%|@Xq^CR7J>#x%XvV4yzdJ7>cHC sVoM&=61kI!DODqV;Gmlz?RW5$M^V1Dhx836)4ss_?Ox%(LzTY%0GXX4Z2$lO literal 0 HcmV?d00001 diff --git a/test/assets/images/test.gif b/test/assets/images/test.gif new file mode 100644 index 0000000000000000000000000000000000000000..77e999f13894aea25d85e54779ffd9bf63a94d35 GIT binary patch literal 156 zcmV;N0Av40Nk%w1VPpVg0Pp|+|Ns90001HR1ONa4001li0001F0Av6F0&|3qsmtvT zqnxzbi?iOm`wxcVNS5Y_rs~SJ?hD8AOxN~}=lag~{tpZahs2`sh)gP%%%<}RjY_A~ zs`ZM^YPa03_X`e-$K-YS={|^`_I7nD%c!-#&xX9S( K_y}oO0027|WKg#N literal 0 HcmV?d00001 diff --git a/test/assets/images/test.png b/test/assets/images/test.png new file mode 100644 index 0000000000000000000000000000000000000000..c89ffa1e846462887d6febb745e2c35f321875bd GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^DIm-UBp4!QuJ{S0SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenM@oty!5+IMg z#M9T6{RKCV2$!DO?Mnp@Ef&nYMv}m4Sikk%mMR4Y~O# ZnQ4`{HH6HxxC_+4;OXk;vd$@?2>^OINL>H` literal 0 HcmV?d00001 diff --git a/test/state_notifier/note_create_page/image_exif_test.dart b/test/state_notifier/note_create_page/image_exif_test.dart new file mode 100644 index 000000000..620323915 --- /dev/null +++ b/test/state_notifier/note_create_page/image_exif_test.dart @@ -0,0 +1,82 @@ +import "dart:io"; +import "package:flutter_test/flutter_test.dart"; +import "package:image/image.dart"; +import "package:miria/state_notifier/note_create_page/note_create_state_notifier.dart"; + +void main() { + group("画像読込", () { + test("PNG画像が読み込めること", () async { + final file = File("test/assets/images/test.png"); + final d = await NoteCreateNotifier().loadImage(file); + expect(decodePng(d), isNotNull); + }); + + test("GIF画像が読み込めること", () async { + final file = File("test/assets/images/test.gif"); + final d = await NoteCreateNotifier().loadImage(file); + expect(decodeGif(d), isNotNull); + }); + + test("JPEG画像が読み込めること", () async { + final file = File("test/assets/images/exif_test.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + expect(decodeJpg(d), isNotNull); + }); + + test("入力JPEG画像にgpsIfdのキーがあること", () async { + final file = File("test/assets/images/exif_test.jpg"); + final exif = decodeJpgExif(await file.readAsBytes()); + expect(exif?.gpsIfd.values.length, 5); + }); + + test("出力JPEG画像にgpsIfdのキーが存在しないこと", () async { + final file = File("test/assets/images/exif_test.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + final exif = decodeJpgExif(d); + expect(exif, isNotNull); + expect(exif?.gpsIfd.keys.length, 0); + }); + + test("出力JPEG画像のEXIFに向き以外存在しないこと", () async { + final file = File("test/assets/images/exif_test.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + final exif = decodeJpgExif(d); + expect(exif, isNotNull); + expect(exif?.imageIfd.keys.length, 1); + expect(exif?.imageIfd.keys.first, 0x112); + }); + + test("出力JPEG画像のEXIFのOrientation値が6であること", () async { + final file = File("test/assets/images/exif_test.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + final exif = decodeJpgExif(d); + expect(exif, isNotNull); + expect(exif?.imageIfd.keys.length, 1); + expect(exif?.imageIfd.orientation, 6); + }); + + test("EXIFがIFDだけのJPEG画像が読み込めること", () async { + final file = File("test/assets/images/exif_ifd_only.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + final img = decodeJpg(d); + expect(img, isNotNull); + }); + + test("EXIFがIFDだけのJPEG画像はOrientation値が1になること", () async { + final file = File("test/assets/images/exif_ifd_only.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + final exif = decodeJpgExif(d); + expect(exif, isNotNull); + expect(exif?.imageIfd.keys.length, 1); + expect(exif?.imageIfd.orientation, 1); + }); + + test("EXIFがないJPEG画像の場合はEXIFをつけないこと", () async { + final file = File("test/assets/images/exif_no_data.jpg"); + final d = await NoteCreateNotifier().loadImage(file); + expect(decodeJpg(d), isNotNull); + final exif = decodeJpgExif(d); + expect(exif, isNull); + }); + }); +}