test_parallax_2d.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**************************************************************************/
  2. /* test_parallax_2d.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef TEST_PARALLAX_2D_H
  31. #define TEST_PARALLAX_2D_H
  32. #include "scene/2d/parallax_2d.h"
  33. #include "tests/test_macros.h"
  34. namespace TestParallax2D {
  35. // Test cases for the Parallax2D class to ensure its properties are set and retrieved correctly.
  36. TEST_CASE("[SceneTree][Parallax2D] Scroll Scale") {
  37. // Test setting and getting the scroll scale.
  38. Parallax2D *parallax = memnew(Parallax2D);
  39. Size2 scale(2, 2);
  40. parallax->set_scroll_scale(scale);
  41. CHECK(parallax->get_scroll_scale() == scale);
  42. memdelete(parallax);
  43. }
  44. TEST_CASE("[SceneTree][Parallax2D] Repeat Size") {
  45. // Test setting and getting the repeat size.
  46. Parallax2D *parallax = memnew(Parallax2D);
  47. Size2 size(100, 100);
  48. parallax->set_repeat_size(size);
  49. CHECK(parallax->get_repeat_size() == size);
  50. memdelete(parallax);
  51. }
  52. TEST_CASE("[SceneTree][Parallax2D] Repeat Times") {
  53. // Test setting and getting the repeat times.
  54. Parallax2D *parallax = memnew(Parallax2D);
  55. int times = 5;
  56. parallax->set_repeat_times(times);
  57. CHECK(parallax->get_repeat_times() == times);
  58. memdelete(parallax);
  59. }
  60. TEST_CASE("[SceneTree][Parallax2D] Autoscroll") {
  61. // Test setting and getting the autoscroll values.
  62. Parallax2D *parallax = memnew(Parallax2D);
  63. Point2 autoscroll(1, 1);
  64. parallax->set_autoscroll(autoscroll);
  65. CHECK(parallax->get_autoscroll() == autoscroll);
  66. memdelete(parallax);
  67. }
  68. TEST_CASE("[SceneTree][Parallax2D] Scroll Offset") {
  69. // Test setting and getting the scroll offset.
  70. Parallax2D *parallax = memnew(Parallax2D);
  71. Point2 offset(10, 10);
  72. parallax->set_scroll_offset(offset);
  73. CHECK(parallax->get_scroll_offset() == offset);
  74. memdelete(parallax);
  75. }
  76. TEST_CASE("[SceneTree][Parallax2D] Screen Offset") {
  77. // Test setting and getting the screen offset.
  78. Parallax2D *parallax = memnew(Parallax2D);
  79. Point2 offset(20, 20);
  80. parallax->set_screen_offset(offset);
  81. CHECK(parallax->get_screen_offset() == offset);
  82. memdelete(parallax);
  83. }
  84. TEST_CASE("[SceneTree][Parallax2D] Limit Begin") {
  85. // Test setting and getting the limit begin values.
  86. Parallax2D *parallax = memnew(Parallax2D);
  87. Point2 limit_begin(-100, -100);
  88. parallax->set_limit_begin(limit_begin);
  89. CHECK(parallax->get_limit_begin() == limit_begin);
  90. memdelete(parallax);
  91. }
  92. TEST_CASE("[SceneTree][Parallax2D] Limit End") {
  93. // Test setting and getting the limit end values.
  94. Parallax2D *parallax = memnew(Parallax2D);
  95. Point2 limit_end(100, 100);
  96. parallax->set_limit_end(limit_end);
  97. CHECK(parallax->get_limit_end() == limit_end);
  98. memdelete(parallax);
  99. }
  100. TEST_CASE("[SceneTree][Parallax2D] Follow Viewport") {
  101. // Test setting and getting the follow viewport flag.
  102. Parallax2D *parallax = memnew(Parallax2D);
  103. parallax->set_follow_viewport(false);
  104. CHECK_FALSE(parallax->get_follow_viewport());
  105. memdelete(parallax);
  106. }
  107. TEST_CASE("[SceneTree][Parallax2D] Ignore Camera Scroll") {
  108. // Test setting and getting the ignore camera scroll flag.
  109. Parallax2D *parallax = memnew(Parallax2D);
  110. parallax->set_ignore_camera_scroll(true);
  111. CHECK(parallax->is_ignore_camera_scroll());
  112. memdelete(parallax);
  113. }
  114. } // namespace TestParallax2D
  115. #endif // TEST_PARALLAX_2D_H