-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add ImageTransformationOptions tests
- Loading branch information
Showing
9 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Assets/MediaPipeUnity/Samples/Mediapipe.Unity.Sample.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Mediapipe.Unity.Sample", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:04c4d86a70aa56c55a78c61f1ab1a56d" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
7 changes: 7 additions & 0 deletions
7
Assets/MediaPipeUnity/Samples/Mediapipe.Unity.Sample.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
Assets/MediaPipeUnity/Tests/EditMode/ImageTransformationOptionsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Copyright (c) 2023 homuler | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
using NUnit.Framework; | ||
|
||
namespace Mediapipe.Unity.Sample.Tests | ||
{ | ||
public class ImageTransformationOptionsTest | ||
{ | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// a---------b a---------b c---------d a---------b a---------b | ||
// | | | | | v | | | | | | ||
// | ^ | | ^ | | | | ^ | | ^ | | ||
// c---------d c---------d a---------b c---------d c---------d | ||
[TestCase(false, false, RotationAngle.Rotation0, false, true, RotationAngle.Rotation0)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// a---------b a---------b a---------b a---------b a---------b | ||
// | | | | | | | | | | | ||
// | ^ | | ^ | | ^ | | ^ | | ^ | | ||
// c---------d c---------d c---------d c---------d c---------d | ||
[TestCase(false, true, RotationAngle.Rotation0, false, false, RotationAngle.Rotation0)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// a---------b a---------b d---------c b---------a b---------a | ||
// | | | | | v | | | | | | ||
// | ^ | | ^ | | | | ^ | | ^ | | ||
// c---------d c---------d b---------a d---------c d---------c | ||
[TestCase(true, false, RotationAngle.Rotation0, true, true, RotationAngle.Rotation0)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// a---------b a---------b b---------a b---------a b---------a | ||
// | | | | | | | | | | | ||
// | ^ | | ^ | | ^ | | ^ | | ^ | | ||
// c---------d c---------d d---------c d---------c d---------c | ||
[TestCase(true, true, RotationAngle.Rotation0, true, false, RotationAngle.Rotation0)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// b-----d a---------b b---------a d---------c b-----d | ||
// | | | | | | | < | | | | ||
// | ^ | | > | | < | | | | ^ | | ||
// a-----c c---------d d---------c b---------a a-----c | ||
[TestCase(false, false, RotationAngle.Rotation90, true, false, RotationAngle.Rotation270)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// b-----d a---------b d---------c d---------c b-----d | ||
// | | | | | < | | < | | | | ||
// | ^ | | > | | | | | | ^ | | ||
// a-----c c---------d b---------a b---------a a-----c | ||
[TestCase(false, true, RotationAngle.Rotation90, true, true, RotationAngle.Rotation270)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// b-----d a---------b d---------c b---------a d-----b | ||
// | | | > | | | | < | | | | ||
// | ^ | | | | < | | | | ^ | | ||
// a-----c c---------d b---------a d---------c c-----a | ||
[TestCase(true, false, RotationAngle.Rotation90, true, true, RotationAngle.Rotation270)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// b-----d a---------b b---------a b---------a d-----b | ||
// | | | > | | < | | < | | | | ||
// | ^ | | | | | | | | ^ | | ||
// a-----c c---------d d---------c d---------c c-----a | ||
[TestCase(true, true, RotationAngle.Rotation90, true, false, RotationAngle.Rotation270)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// d---------c a---------b c---------d a---------b d---------c | ||
// | | | v | | | | v | | | | ||
// | ^ | | | | ^ | | | | ^ | | ||
// b---------a c---------d a---------b c---------d b---------a | ||
[TestCase(false, false, RotationAngle.Rotation180, false, true, RotationAngle.Rotation180)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// d---------c a---------b a---------b a---------b d---------c | ||
// | | | v | | v | | v | | | | ||
// | ^ | | | | | | | | ^ | | ||
// b---------a c---------d c---------d c---------d b---------a | ||
[TestCase(false, true, RotationAngle.Rotation180, false, false, RotationAngle.Rotation180)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// d---------c a---------b d---------c b---------a c---------d | ||
// | | | v | | | | v | | | | ||
// | ^ | | | | ^ | | | | ^ | | ||
// b---------a c---------d b---------a d---------c a---------b | ||
[TestCase(true, false, RotationAngle.Rotation180, true, true, RotationAngle.Rotation180)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// d---------c a---------b b---------a b---------a c---------d | ||
// | | | v | | v | | v | | | | ||
// | ^ | | | | | | | | ^ | | ||
// b---------a c---------d d---------c d---------c a---------b | ||
[TestCase(true, true, RotationAngle.Rotation180, true, false, RotationAngle.Rotation180)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// c-----a a---------b b---------a d---------c c-----a | ||
// | | | < | | > | | | | | | ||
// | ^ | | | | | | > | | ^ | | ||
// d-----b c---------d d---------c b---------a d-----b | ||
[TestCase(false, false, RotationAngle.Rotation270, true, false, RotationAngle.Rotation90)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// c-----a a---------b d---------c d---------c c-----a | ||
// | | | < | | | | | | | | ||
// | ^ | | | | > | | > | | ^ | | ||
// d-----b c---------d b---------a b---------a d-----b | ||
[TestCase(false, true, RotationAngle.Rotation270, true, true, RotationAngle.Rotation90)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// c-----a a---------b d---------c b---------a a-----c | ||
// | | | | | > | | | | | | ||
// | ^ | | < | | | | > | | ^ | | ||
// d-----b c---------d b---------a d---------c b-----d | ||
[TestCase(true, false, RotationAngle.Rotation270, true, true, RotationAngle.Rotation90)] | ||
// raw -> unrotated -> flip -> input image -> rotated | ||
// c-----a a---------b b---------a b---------a a-----c | ||
// | | | | | | | | | | | ||
// | ^ | | < | | > | | > | | ^ | | ||
// d-----b c---------d d---------c d---------c b-----d | ||
[TestCase(true, true, RotationAngle.Rotation270, true, false, RotationAngle.Rotation90)] | ||
public void TestBuild( | ||
bool shouldFlipHorizontally, bool isFlippedVertically, RotationAngle rotationAngle, | ||
bool flipHorizontally, bool flipVertically, RotationAngle expectedRotationAngle) | ||
{ | ||
var options = ImageTransformationOptions.Build(shouldFlipHorizontally, isFlippedVertically, rotationAngle); | ||
Assert.AreEqual(flipHorizontally, options.flipHorizontally); | ||
Assert.AreEqual(flipVertically, options.flipVertically); | ||
Assert.AreEqual(expectedRotationAngle, options.rotationAngle); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/MediaPipeUnity/Tests/EditMode/ImageTransformationOptionsTest.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
Assets/MediaPipeUnity/Tests/EditMode/MediaPipe.Unity.Sample.Tests.EditMode.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "MediaPipe.Unity.Sample.Tests.EditMode", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:27619889b8ba8c24980f49ee34dbb44a", | ||
"GUID:0acc523941302664db1f4e527237feb3", | ||
"GUID:04c4d86a70aa56c55a78c61f1ab1a56d", | ||
"GUID:f32148de13e8ca8369101d3ef3260930" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"nunit.framework.dll" | ||
], | ||
"autoReferenced": true, | ||
"defineConstraints": [ | ||
"UNITY_INCLUDE_TESTS" | ||
], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
7 changes: 7 additions & 0 deletions
7
Assets/MediaPipeUnity/Tests/EditMode/MediaPipe.Unity.Sample.Tests.EditMode.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters