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