67 lines
3.4 KiB
C++
67 lines
3.4 KiB
C++
|
/**************************************************************************/
|
||
|
/* test_control.h */
|
||
|
/**************************************************************************/
|
||
|
/* This file is part of: */
|
||
|
/* GODOT ENGINE */
|
||
|
/* https://godotengine.org */
|
||
|
/**************************************************************************/
|
||
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||
|
/* */
|
||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||
|
/* a copy of this software and associated documentation files (the */
|
||
|
/* "Software"), to deal in the Software without restriction, including */
|
||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||
|
/* the following conditions: */
|
||
|
/* */
|
||
|
/* The above copyright notice and this permission notice shall be */
|
||
|
/* included in all copies or substantial portions of the Software. */
|
||
|
/* */
|
||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||
|
/**************************************************************************/
|
||
|
|
||
|
#ifndef TEST_CONTROL_H
|
||
|
#define TEST_CONTROL_H
|
||
|
|
||
|
#include "scene/gui/control.h"
|
||
|
|
||
|
#include "tests/test_macros.h"
|
||
|
|
||
|
namespace TestControl {
|
||
|
|
||
|
TEST_CASE("[SceneTree][Control]") {
|
||
|
SUBCASE("[Control][Global Transform] Global Transform should be accessible while not in SceneTree.") { // GH-79453
|
||
|
Control *test_node = memnew(Control);
|
||
|
Control *test_child = memnew(Control);
|
||
|
test_node->add_child(test_child);
|
||
|
|
||
|
test_node->set_global_position(Point2(1, 1));
|
||
|
CHECK_EQ(test_node->get_global_position(), Point2(1, 1));
|
||
|
CHECK_EQ(test_child->get_global_position(), Point2(1, 1));
|
||
|
test_node->set_global_position(Point2(2, 2));
|
||
|
CHECK_EQ(test_node->get_global_position(), Point2(2, 2));
|
||
|
test_node->set_scale(Vector2(4, 4));
|
||
|
CHECK_EQ(test_node->get_global_transform(), Transform2D(0, Size2(4, 4), 0, Vector2(2, 2)));
|
||
|
test_node->set_scale(Vector2(1, 1));
|
||
|
test_node->set_rotation_degrees(90);
|
||
|
CHECK_EQ(test_node->get_global_transform(), Transform2D(Math_PI / 2, Vector2(2, 2)));
|
||
|
test_node->set_pivot_offset(Vector2(1, 0));
|
||
|
CHECK_EQ(test_node->get_global_transform(), Transform2D(Math_PI / 2, Vector2(3, 1)));
|
||
|
|
||
|
memdelete(test_child);
|
||
|
memdelete(test_node);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} // namespace TestControl
|
||
|
|
||
|
#endif // TEST_CONTROL_H
|