TextAttributesTest.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #include <memory>
  8. #include <assert.h>
  9. #include <gtest/gtest.h>
  10. #include <react/attributedstring/TextAttributes.h>
  11. #include <react/attributedstring/conversions.h>
  12. #include <react/attributedstring/primitives.h>
  13. #include <react/graphics/conversions.h>
  14. namespace facebook {
  15. namespace react {
  16. #ifdef ANDROID
  17. TEST(TextAttributesTest, testToDynamic) {
  18. auto text = TextAttributes();
  19. text.foregroundColor = {
  20. colorFromComponents({200 / 255.0, 153 / 255.0, 100 / 255.0, 1.0})};
  21. text.opacity = 0.5;
  22. text.fontStyle = FontStyle::Italic;
  23. text.fontWeight = FontWeight::Thin;
  24. text.fontVariant = FontVariant::TabularNums;
  25. auto result = toDynamic(text);
  26. assert(result["foregroundColor"] == toDynamic(text.foregroundColor));
  27. assert(result["opacity"] == text.opacity);
  28. assert(result["fontStyle"] == toString(*text.fontStyle));
  29. assert(result["fontWeight"] == toString(*text.fontWeight));
  30. }
  31. #endif
  32. } // namespace react
  33. } // namespace facebook