@@ -84,6 +84,7 @@ struct CgltfImporterTest: TestSuite::Tester {
84
84
void animation ();
85
85
void animationOutOfBounds ();
86
86
void animationInvalid ();
87
+ void animationInvalidBufferNotFound ();
87
88
void animationInvalidInterpolation ();
88
89
void animationMismatchingCount ();
89
90
void animationMissingTargetNode ();
@@ -122,6 +123,7 @@ struct CgltfImporterTest: TestSuite::Tester {
122
123
void skin ();
123
124
void skinOutOfBounds ();
124
125
void skinInvalid ();
126
+ void skinInvalidBufferNotFound ();
125
127
void skinNoJointsProperty ();
126
128
127
129
void mesh ();
@@ -138,6 +140,7 @@ struct CgltfImporterTest: TestSuite::Tester {
138
140
void meshPrimitivesTypes ();
139
141
void meshOutOfBounds ();
140
142
void meshInvalid ();
143
+ void meshInvalidIndicesBufferNotFound ();
141
144
void meshInvalidSkinAttributes ();
142
145
void meshInvalidTypes ();
143
146
@@ -258,6 +261,14 @@ constexpr struct {
258
261
{" unsupported path" , " unsupported track target 0" }
259
262
};
260
263
264
+ constexpr struct {
265
+ const char * name;
266
+ const char * message;
267
+ } AnimationInvalidBufferNotFoundData[]{
268
+ {" input buffer not found" , " error opening file: /nonexistent1.bin : file not found" },
269
+ {" output buffer not found" , " error opening file: /nonexistent2.bin : file not found" }
270
+ };
271
+
261
272
constexpr struct {
262
273
const char * name;
263
274
const char * message;
@@ -603,6 +614,9 @@ CgltfImporterTest::CgltfImporterTest() {
603
614
addInstancedTests ({&CgltfImporterTest::animationInvalid},
604
615
Containers::arraySize (AnimationInvalidData));
605
616
617
+ addInstancedTests ({&CgltfImporterTest::animationInvalidBufferNotFound},
618
+ Containers::arraySize (AnimationInvalidBufferNotFoundData));
619
+
606
620
addTests ({&CgltfImporterTest::animationInvalidInterpolation,
607
621
&CgltfImporterTest::animationMismatchingCount,
608
622
&CgltfImporterTest::animationMissingTargetNode});
@@ -661,6 +675,8 @@ CgltfImporterTest::CgltfImporterTest() {
661
675
addInstancedTests ({&CgltfImporterTest::skinInvalid},
662
676
Containers::arraySize (SkinInvalidData));
663
677
678
+ addTests ({&CgltfImporterTest::skinInvalidBufferNotFound});
679
+
664
680
addInstancedTests ({&CgltfImporterTest::skinOutOfBounds},
665
681
Containers::arraySize (SkinOutOfBoundsData));
666
682
@@ -689,6 +705,8 @@ CgltfImporterTest::CgltfImporterTest() {
689
705
addInstancedTests ({&CgltfImporterTest::meshInvalid},
690
706
Containers::arraySize (MeshInvalidData));
691
707
708
+ addTests ({&CgltfImporterTest::meshInvalidIndicesBufferNotFound});
709
+
692
710
addInstancedTests ({&CgltfImporterTest::meshInvalidSkinAttributes},
693
711
Containers::arraySize (MeshInvalidSkinAttributesData));
694
712
@@ -1200,6 +1218,27 @@ void CgltfImporterTest::animationInvalid() {
1200
1218
CORRADE_COMPARE (out.str (), Utility::formatString (" Trade::CgltfImporter::animation(): {}\n " , data.message ));
1201
1219
}
1202
1220
1221
+ void CgltfImporterTest::animationInvalidBufferNotFound () {
1222
+ auto && data = AnimationInvalidBufferNotFoundData[testCaseInstanceId ()];
1223
+ setTestCaseDescription (data.name );
1224
+
1225
+ /* These tests have to be separate from TinyGltfImporter because it errors
1226
+ out during import trying to load the buffer */
1227
+
1228
+ Containers::Pointer<AbstractImporter> importer = _manager.instantiate (" CgltfImporter" );
1229
+
1230
+ CORRADE_VERIFY (importer->openFile (Utility::Directory::join (CGLTFIMPORTER_TEST_DIR,
1231
+ " animation-buffer-notfound.gltf" )));
1232
+
1233
+ /* Check we didn't forget to test anything */
1234
+ CORRADE_COMPARE (importer->animationCount (), Containers::arraySize (AnimationInvalidBufferNotFoundData));
1235
+
1236
+ std::ostringstream out;
1237
+ Error redirectError{&out};
1238
+ CORRADE_VERIFY (!importer->animation (data.name ));
1239
+ CORRADE_COMPARE (out.str (), Utility::formatString (" Trade::CgltfImporter::animation(): {}\n " , data.message ));
1240
+ }
1241
+
1203
1242
void CgltfImporterTest::animationInvalidInterpolation () {
1204
1243
Containers::Pointer<AbstractImporter> importer = _manager.instantiate (" CgltfImporter" );
1205
1244
@@ -2285,6 +2324,23 @@ void CgltfImporterTest::skinInvalid() {
2285
2324
CORRADE_COMPARE (out.str (), Utility::formatString (" Trade::CgltfImporter::skin3D(): {}\n " , data.message ));
2286
2325
}
2287
2326
2327
+ void CgltfImporterTest::skinInvalidBufferNotFound () {
2328
+ /* This test has to be separate from TinyGltfImporter because it errors
2329
+ out during import trying to load the buffer */
2330
+
2331
+ Containers::Pointer<AbstractImporter> importer = _manager.instantiate (" CgltfImporter" );
2332
+
2333
+ CORRADE_VERIFY (importer->openFile (Utility::Directory::join (CGLTFIMPORTER_TEST_DIR,
2334
+ " skin-buffer-notfound.gltf" )));
2335
+
2336
+ CORRADE_COMPARE (importer->skin3DCount (), 1 );
2337
+
2338
+ std::ostringstream out;
2339
+ Error redirectError{&out};
2340
+ CORRADE_VERIFY (!importer->skin3D (" buffer not found" ));
2341
+ CORRADE_COMPARE (out.str (), " Trade::CgltfImporter::skin3D(): error opening file: /nonexistent.bin : file not found\n " );
2342
+ }
2343
+
2288
2344
void CgltfImporterTest::skinNoJointsProperty () {
2289
2345
Containers::Pointer<AbstractImporter> importer = _manager.instantiate (" CgltfImporter" );
2290
2346
@@ -3117,6 +3173,26 @@ void CgltfImporterTest::meshInvalid() {
3117
3173
CORRADE_COMPARE (out.str (), Utility::formatString (" Trade::CgltfImporter::mesh(): {}\n " , data.message ));
3118
3174
}
3119
3175
3176
+ void CgltfImporterTest::meshInvalidIndicesBufferNotFound () {
3177
+ /* This test has to be separate from TinyGltfImporter because it errors
3178
+ out during import trying to load the buffer.
3179
+
3180
+ Not testing this for the attribute buffer since that's already done by
3181
+ openExternalDataNotFound(). */
3182
+
3183
+ Containers::Pointer<AbstractImporter> importer = _manager.instantiate (" CgltfImporter" );
3184
+
3185
+ CORRADE_VERIFY (importer->openFile (Utility::Directory::join (CGLTFIMPORTER_TEST_DIR,
3186
+ " mesh-indices-buffer-notfound.gltf" )));
3187
+
3188
+ CORRADE_COMPARE (importer->meshCount (), 1 );
3189
+
3190
+ std::ostringstream out;
3191
+ Error redirectError{&out};
3192
+ CORRADE_VERIFY (!importer->mesh (" indices buffer not found" ));
3193
+ CORRADE_COMPARE (out.str (), " Trade::CgltfImporter::mesh(): error opening file: /nonexistent.bin : file not found\n " );
3194
+ }
3195
+
3120
3196
void CgltfImporterTest::meshInvalidSkinAttributes () {
3121
3197
auto && data = MeshInvalidSkinAttributesData[testCaseInstanceId ()];
3122
3198
setTestCaseDescription (data.name );
0 commit comments