Browse Source

Trade,SceneTools: use lowercase in custom field / attribute name tests.

Custom material attributes are enforced to start with a lowercase
letter, so I think it makes sense to be consistent and use the same for
custom scene fields and mesh attributes as well. It's not enforced in
any way but the tests should reflect that choice so new code that gets
written based on these inherits that practice.
pull/620/head
Vladimír Vondruš 3 years ago
parent
commit
eabba4f155
  1. 4
      src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp
  2. 2
      src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-meshes-bounds.txt
  3. 2
      src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-scenes-no-default.txt
  4. 6
      src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-scenes-objects.txt
  5. 2
      src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-scenes.txt
  6. 8
      src/Magnum/SceneTools/Test/SceneConverterTest.cpp
  7. 8
      src/Magnum/Trade/Test/AbstractImporterTest.cpp
  8. 24
      src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp

4
src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp

@ -225,7 +225,7 @@ void SceneConverterImplementationTest::infoScenesObjects() {
return "";
}
Containers::String doSceneFieldName(Trade::SceneField name) override {
if(name == Trade::sceneFieldCustom(1337)) return "DirectionVector";
if(name == Trade::sceneFieldCustom(1337)) return "directionVector";
return "";
}
Containers::Optional<Trade::SceneData> doScene(UnsignedInt id) override {
@ -757,7 +757,7 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
Containers::String doMeshAttributeName(Trade::MeshAttribute name) override {
if(name == Trade::meshAttributeCustom(25))
return "NormalButCustomSoNoBoundsPrinted";
return "normalButCustomSoNoBoundsPrinted";
return "";
}

2
src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-meshes-bounds.txt

@ -10,7 +10,7 @@ Mesh 0:
Bounds: (12, 155)
Normal @ Vector3bNormalized, offset 76, stride 3
Bounds: ({-1, 0, 0}, {0, 1, 1})
Custom(25:NormalButCustomSoNoBoundsPrinted) @ Vector3b, offset 76, stride 3
Custom(25:normalButCustomSoNoBoundsPrinted) @ Vector3b, offset 76, stride 3
TextureCoordinates @ Vector2, offset 84, stride 8
Bounds: ({0.5, 0.5}, {1.5, 0.5})
Color @ Vector4, offset 100, stride 16

2
src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-scenes-no-default.txt

@ -7,5 +7,5 @@ Scene 1:
Bound: 8 objects @ UnsignedByte (0.0 kB, ExternallyOwned|Mutable)
Fields:
Custom(42:) @ Double, 2 entries
Custom(1337:DirectionVector) @ Short[3], 3 entries
Custom(1337:directionVector) @ Short[3], 3 entries
Total scene data size: 0.1 kB

6
src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-scenes-objects.txt

@ -8,18 +8,18 @@ Scene 1:
Bound: 8 objects @ UnsignedByte (0.0 kB, ExternallyOwned|Mutable)
Fields:
Custom(42:) @ Double, 2 entries
Custom(1337:DirectionVector) @ Short[3], 3 entries
Custom(1337:directionVector) @ Short[3], 3 entries
Total scene data size: 0.1 kB
Object 0 (referenced by 1 scenes): Parent-less mesh
Fields: Mesh
Object 1 (referenced by 1 scenes):
Fields: Parent, Mesh
Object 2 (referenced by 2 scenes): Two meshes, shared among two scenes
Fields: Parent, Mesh[2], Custom(1337:DirectionVector)
Fields: Parent, Mesh[2], Custom(1337:directionVector)
Object 3 (referenced by 2 scenes):
Fields: Parent, Custom(42:)
Object 4 (referenced by 1 scenes): Two custom arrays
Fields: Custom(1337:DirectionVector)[2]
Fields: Custom(1337:directionVector)[2]
Object 6 (referenced by 0 scenes): Only in the second scene, but no fields, thus same as unreferenced
Object 7 (referenced by 1 scenes):
Fields: Custom(42:)

2
src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-scenes.txt

@ -8,5 +8,5 @@ Scene 1:
Bound: 8 objects @ UnsignedByte (0.0 kB, ExternallyOwned|Mutable)
Fields:
Custom(42:) @ Double, 2 entries
Custom(1337:DirectionVector) @ Short[3], 3 entries
Custom(1337:directionVector) @ Short[3], 3 entries
Total scene data size: 0.1 kB

8
src/Magnum/SceneTools/Test/SceneConverterTest.cpp

@ -688,8 +688,8 @@ const struct {
"materials-pbr.gltf", nullptr,
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute, skipping\n"
/** @todo remove this once GltfSceneConverter supports bit fields */
"Trade::GltfSceneConverter::add(): custom scene field Visibility has unsupported type Trade::SceneFieldType::Bit, skipping\n"
"Trade::GltfSceneConverter::add(): custom scene field GeometryTransformHelper has unsupported type Trade::SceneFieldType::Bit, skipping\n"},
"Trade::GltfSceneConverter::add(): custom scene field visibility has unsupported type Trade::SceneFieldType::Bit, skipping\n"
"Trade::GltfSceneConverter::add(): custom scene field geometryTransformHelper has unsupported type Trade::SceneFieldType::Bit, skipping\n"},
{"Phong to PBR, verbose", {InPlaceInit, {
/* Same as above, just with -v added */
"-I", "UfbxImporter", "-C", "GltfSceneConverter", "--phong-to-pbr",
@ -711,8 +711,8 @@ const struct {
"Trade::AbstractSceneConverter::addImporterContents(): adding mesh 1 out of 2\n"
"Trade::AbstractSceneConverter::addImporterContents(): adding scene 0 out of 1\n"
/** @todo remove this once GltfSceneConverter supports bit fields */
"Trade::GltfSceneConverter::add(): custom scene field Visibility has unsupported type Trade::SceneFieldType::Bit, skipping\n"
"Trade::GltfSceneConverter::add(): custom scene field GeometryTransformHelper has unsupported type Trade::SceneFieldType::Bit, skipping\n"},
"Trade::GltfSceneConverter::add(): custom scene field visibility has unsupported type Trade::SceneFieldType::Bit, skipping\n"
"Trade::GltfSceneConverter::add(): custom scene field geometryTransformHelper has unsupported type Trade::SceneFieldType::Bit, skipping\n"},
{"data unsupported by the converter", {InPlaceInit, {
"-I", "GltfImporter", "-i", "experimentalKhrTextureKtx",
"-C", "StanfordSceneConverter",

8
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -3767,18 +3767,18 @@ void AbstractImporterTest::sceneFieldName() {
void doClose() override {}
SceneField doSceneFieldForName(Containers::StringView name) override {
if(name == "OctreeCell") return sceneFieldCustom(100037);
if(name == "octreeCell") return sceneFieldCustom(100037);
return SceneField{};
}
Containers::String doSceneFieldName(SceneField id) override {
if(id == sceneFieldCustom(100037)) return "OctreeCell";
if(id == sceneFieldCustom(100037)) return "octreeCell";
return "";
}
} importer;
CORRADE_COMPARE(importer.sceneFieldForName("OctreeCell"), sceneFieldCustom(100037));
CORRADE_COMPARE(importer.sceneFieldName(sceneFieldCustom(100037)), "OctreeCell");
CORRADE_COMPARE(importer.sceneFieldForName("octreeCell"), sceneFieldCustom(100037));
CORRADE_COMPARE(importer.sceneFieldName(sceneFieldCustom(100037)), "octreeCell");
}
void AbstractImporterTest::sceneFieldNameNotImplemented() {

24
src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp

@ -6216,8 +6216,8 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() {
return SceneData{SceneMappingType::UnsignedInt, 0, nullptr, {}};
}
Containers::String doSceneFieldName(SceneField name) override {
if(name == sceneFieldCustom(34977)) return "OffsetSmall";
if(name == sceneFieldCustom(5266)) return "ValueData";
if(name == sceneFieldCustom(34977)) return "offsetSmall";
if(name == sceneFieldCustom(5266)) return "valueData";
CORRADE_FAIL("This should not be reached");
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
}
@ -6250,11 +6250,11 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() {
CORRADE_COMPARE(out.str(),
"Adding scene\n"
/** @todo cache the names to avoid querying repeatedly */
"Setting field 34977 name to OffsetSmall\n"
"Setting field 5266 name to ValueData\n"
"Setting field 34977 name to offsetSmall\n"
"Setting field 5266 name to valueData\n"
"Adding scene\n"
"Setting field 34977 name to OffsetSmall\n"
"Setting field 5266 name to ValueData\n"
"Setting field 34977 name to offsetSmall\n"
"Setting field 5266 name to valueData\n"
"Adding scene\n");
}
@ -6281,8 +6281,8 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() {
return MeshData{MeshPrimitive::Points, 0};
}
Containers::String doMeshAttributeName(MeshAttribute name) override {
if(name == meshAttributeCustom(31977)) return "OffsetSmall";
if(name == meshAttributeCustom(5266)) return "ValueData";
if(name == meshAttributeCustom(31977)) return "offsetSmall";
if(name == meshAttributeCustom(5266)) return "valueData";
CORRADE_FAIL("This should not be reached");
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
}
@ -6316,10 +6316,10 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() {
CORRADE_COMPARE(out.str(),
"Adding mesh levels\n"
/** @todo cache the names to avoid querying repeatedly */
"Setting attribute 31977 name to OffsetSmall\n"
"Setting attribute 5266 name to ValueData\n"
"Setting attribute 31977 name to OffsetSmall\n"
"Setting attribute 5266 name to ValueData\n"
"Setting attribute 31977 name to offsetSmall\n"
"Setting attribute 5266 name to valueData\n"
"Setting attribute 31977 name to offsetSmall\n"
"Setting attribute 5266 name to valueData\n"
"Adding mesh levels\n");
}

Loading…
Cancel
Save