Path: blob/master/tests/scene/test_style_box_empty.cpp
45991 views
/**************************************************************************/1/* test_style_box_empty.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_style_box_empty)3334#include "scene/resources/style_box.h"3536namespace TestStyleBoxEmpty {3738TEST_CASE("[StyleBoxEmpty] Constructor") {39Ref<StyleBoxEmpty> style_box_empty = memnew(StyleBoxEmpty);4041CHECK(style_box_empty->get_offset() == Point2(0, 0));42CHECK(style_box_empty->get_current_item_drawn() == nullptr);43}4445TEST_CASE("[StyleBoxEmpty] set_content_margin, set_content_margin_all, set_content_margin_individual, get_content_margin, get_margin") {46Ref<StyleBoxEmpty> style_box_empty = memnew(StyleBoxEmpty);4748SUBCASE("set_content_margin, get_content_margin") {49style_box_empty->set_content_margin(SIDE_LEFT, 2);50style_box_empty->set_content_margin(SIDE_TOP, 3);51style_box_empty->set_content_margin(SIDE_RIGHT, 4);52style_box_empty->set_content_margin(SIDE_BOTTOM, 5);5354CHECK(style_box_empty->get_content_margin(SIDE_LEFT) == 2);55CHECK(style_box_empty->get_content_margin(SIDE_TOP) == 3);56CHECK(style_box_empty->get_content_margin(SIDE_RIGHT) == 4);57CHECK(style_box_empty->get_content_margin(SIDE_BOTTOM) == 5);58}5960SUBCASE("set_content_margin_all, get_content_margin") {61style_box_empty->set_content_margin_all(10);6263CHECK(style_box_empty->get_content_margin(SIDE_LEFT) == 10);64CHECK(style_box_empty->get_content_margin(SIDE_TOP) == 10);65CHECK(style_box_empty->get_content_margin(SIDE_RIGHT) == 10);66CHECK(style_box_empty->get_content_margin(SIDE_BOTTOM) == 10);67}6869SUBCASE("set_content_margin, get_margin") {70style_box_empty->set_content_margin(SIDE_LEFT, -1);71style_box_empty->set_content_margin(SIDE_RIGHT, -2);72style_box_empty->set_content_margin(SIDE_TOP, 3);73style_box_empty->set_content_margin(SIDE_BOTTOM, 4);7475CHECK_MESSAGE(style_box_empty->get_margin(SIDE_LEFT) == 0,76"Value is lesser than zero, so it returns 0");77CHECK_MESSAGE(style_box_empty->get_margin(SIDE_RIGHT) == 0,78"Value is lesser than zero, so it returns 0");79CHECK_MESSAGE(style_box_empty->get_margin(SIDE_TOP) == 3,80"Value is higher than zero, so it returns value");81CHECK_MESSAGE(style_box_empty->get_margin(SIDE_BOTTOM) == 4,82"Value is higher than zero, so it returns value");83}8485SUBCASE("set_content_margin_individual, get_minimum_size") {86style_box_empty->set_content_margin_individual(-1, 2, 5, 15);8788CHECK(style_box_empty->get_minimum_size() == Size2(5, 17));89}9091SUBCASE("set_content_margin_individual, get_offset") {92style_box_empty->set_content_margin_individual(-3, 5, 1, 2);9394CHECK_MESSAGE(style_box_empty->get_offset() == Point2(0, 5),95"Returns Point2 with get_margin of SIDE_LEFT and SIDE_TOP");96}97}9899} // namespace TestStyleBoxEmpty100101102