TextInputProperty.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <catch2/catch_test_macros.hpp>
  2. #include "WallpaperEngine/Data/Model/Property.h"
  3. #include "WallpaperEngine/Data/Parsers/PropertyParser.h"
  4. using WallpaperEngine::Data::JSON::JSON;
  5. using WallpaperEngine::Data::Model::DynamicValue;
  6. using WallpaperEngine::Data::Parsers::PropertyParser;
  7. TEST_CASE ("Text input properties keep their string value without JSON quotes") {
  8. const JSON propertyData = {
  9. { "type", "textinput" },
  10. { "text", "Format" },
  11. { "value", "HH:mm" },
  12. };
  13. const auto property = PropertyParser::parse (propertyData, "format");
  14. REQUIRE (property != nullptr);
  15. CHECK (property->getType () == DynamicValue::String);
  16. CHECK (property->getString () == "HH:mm");
  17. }
  18. TEST_CASE ("Text input properties without a value default to an empty string") {
  19. const JSON propertyData = {
  20. { "type", "textinput" },
  21. { "text", "ui_font" },
  22. { "condition", "weather_show.value" },
  23. { "order", 9090 },
  24. };
  25. const auto property = PropertyParser::parse (propertyData, "ui_font");
  26. REQUIRE (property != nullptr);
  27. CHECK (property->getType () == DynamicValue::String);
  28. CHECK (property->getString ().empty ());
  29. }