-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate MuscleColorSourceScaling into OpenSimDecorationOptions (#933)
- Loading branch information
1 parent
4eb2233
commit a872b84
Showing
5 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
39 changes: 39 additions & 0 deletions
39
tests/TestOpenSimCreator/Graphics/TestOpenSimDecorationOptions.cpp
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,39 @@ | ||
#include <OpenSimCreator/Graphics/OpenSimDecorationOptions.h> | ||
|
||
#include <oscar/Utils/Conversion.h> | ||
#include <oscar/Utils/StringHelpers.h> | ||
#include <oscar/Variant.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <string_view> | ||
#include <unordered_map> | ||
|
||
using namespace osc; | ||
|
||
TEST(OpenSimDecorationOptions, RemembersColorScaling) | ||
{ | ||
OpenSimDecorationOptions opts; | ||
opts.setMuscleColorSourceScaling(MuscleColorSourceScaling::ModelWide); | ||
bool emitted = false; | ||
opts.forEachOptionAsAppSettingValue([&emitted](std::string_view k, const Variant& v) | ||
{ | ||
// Yep, this is hard-coded: it's just here as a sanity check: change/remove | ||
// it if it's causing trouble. | ||
if (k == "muscle_color_scaling" and to<std::string>(v) == "model_wide") { | ||
emitted = true; | ||
} | ||
}); | ||
ASSERT_TRUE(emitted); | ||
} | ||
|
||
TEST(OpenSimDecorationOptions, ReadsColorScalingFromDict) | ||
{ | ||
const std::unordered_map<std::string, Variant> lookup = { | ||
{"muscle_color_scaling", "model_wide"}, | ||
}; | ||
|
||
OpenSimDecorationOptions opts; | ||
ASSERT_NE(opts.getMuscleColorSourceScaling(), MuscleColorSourceScaling::ModelWide); | ||
opts.tryUpdFromValues("", lookup); | ||
ASSERT_EQ(opts.getMuscleColorSourceScaling(), MuscleColorSourceScaling::ModelWide); | ||
} |