Debian Codegraph @

tests/scene/test_parallax_2d.h

raw symbols SCIP
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
31 #pragma once
32
33 #include "scene/2d/parallax_2d.h"
34 #include "tests/test_macros.h"
35
36 namespace TestParallax2D {
37
38 // Test cases for the Parallax2D class to ensure its properties are set and retrieved correctly.
39
40 TEST_CASE("[SceneTree][Parallax2D] Scroll Scale") {
41 // Test setting and getting the scroll scale.
42 Parallax2D *parallax = memnew(Parallax2D);
43 Size2 scale(2, 2);
44 parallax->set_scroll_scale(scale);
45 CHECK(parallax->get_scroll_scale() == scale);
46 memdelete(parallax);
47 }
48
49 TEST_CASE("[SceneTree][Parallax2D] Repeat Size") {
50 // Test setting and getting the repeat size.
51 Parallax2D *parallax = memnew(Parallax2D);
52 Size2 size(100, 100);
53 parallax->set_repeat_size(size);
54 CHECK(parallax->get_repeat_size() == size);
55 memdelete(parallax);
56 }
57
58 TEST_CASE("[SceneTree][Parallax2D] Repeat Times") {
59 // Test setting and getting the repeat times.
60 Parallax2D *parallax = memnew(Parallax2D);
61 int times = 5;
62 parallax->set_repeat_times(times);
63 CHECK(parallax->get_repeat_times() == times);
64 memdelete(parallax);
65 }
66
67 TEST_CASE("[SceneTree][Parallax2D] Autoscroll") {
68 // Test setting and getting the autoscroll values.
69 Parallax2D *parallax = memnew(Parallax2D);
70 Point2 autoscroll(1, 1);
71 parallax->set_autoscroll(autoscroll);
72 CHECK(parallax->get_autoscroll() == autoscroll);
73 memdelete(parallax);
74 }
75
76 TEST_CASE("[SceneTree][Parallax2D] Scroll Offset") {
77 // Test setting and getting the scroll offset.
78 Parallax2D *parallax = memnew(Parallax2D);
79 Point2 offset(10, 10);
80 parallax->set_scroll_offset(offset);
81 CHECK(parallax->get_scroll_offset() == offset);
82 memdelete(parallax);
83 }
84
85 TEST_CASE("[SceneTree][Parallax2D] Screen Offset") {
86 // Test setting and getting the screen offset.
87 Parallax2D *parallax = memnew(Parallax2D);
88 Point2 offset(20, 20);
89 parallax->set_screen_offset(offset);
90 CHECK(parallax->get_screen_offset() == offset);
91 memdelete(parallax);
92 }
93
94 TEST_CASE("[SceneTree][Parallax2D] Limit Begin") {
95 // Test setting and getting the limit begin values.
96 Parallax2D *parallax = memnew(Parallax2D);
97 Point2 limit_begin(-100, -100);
98 parallax->set_limit_begin(limit_begin);
99 CHECK(parallax->get_limit_begin() == limit_begin);
100 memdelete(parallax);
101 }
102
103 TEST_CASE("[SceneTree][Parallax2D] Limit End") {
104 // Test setting and getting the limit end values.
105 Parallax2D *parallax = memnew(Parallax2D);
106 Point2 limit_end(100, 100);
107 parallax->set_limit_end(limit_end);
108 CHECK(parallax->get_limit_end() == limit_end);
109 memdelete(parallax);
110 }
111
112 TEST_CASE("[SceneTree][Parallax2D] Follow Viewport") {
113 // Test setting and getting the follow viewport flag.
114 Parallax2D *parallax = memnew(Parallax2D);
115 parallax->set_follow_viewport(false);
116 CHECK_FALSE(parallax->get_follow_viewport());
117 memdelete(parallax);
118 }
119
120 TEST_CASE("[SceneTree][Parallax2D] Ignore Camera Scroll") {
121 // Test setting and getting the ignore camera scroll flag.
122 Parallax2D *parallax = memnew(Parallax2D);
123 parallax->set_ignore_camera_scroll(true);
124 CHECK(parallax->is_ignore_camera_scroll());
125 memdelete(parallax);
126 }
127
128 } // namespace TestParallax2D