Пример #1
0
TEST_FIXTURE(SDL_fixture, WidgetChildren)
{
	UNITTEST_TIME_CONSTRAINT(50);

	CHECK(SDL_init_ok);
	if(SDL_init_ok)
	{
		Widget* w = new Widget();
		Widget* w2 = new Widget();
		w->AddChild(w2);
		CHECK(std::find(w->GetChildren().begin(), w->GetChildren().end(), w2) != w->GetChildren().end());
		Widget::ClearRoot();
	}
}
Пример #2
0
/**
*  @brief
*    Get next sibling widget
*/
Widget *Widget::GetNextSibling() const
{
	// Get parent widget
	Widget *pParent = GetParent();
	if (pParent) {
		// Get index of this widget
		int nIndex = pParent->GetChildren().GetIndex(const_cast<Widget*>(this));

		// Return sibling
		return pParent->GetChildren().Get(nIndex+1);
	}

	// Could not find a sibling
	return nullptr;
}
Пример #3
0
TEST_FIXTURE(SDL_fixture, AddAndRemove)
{
	UNITTEST_TIME_CONSTRAINT(50);

	CHECK(SDL_init_ok);
	if(SDL_init_ok)
	{
		Widget* w = new Widget();
		Widget* w2 = new Widget();
		Widget* w3 = new Widget();
		w->AddChild(w2);
		w->AddChild(w3);
		CHECK_EQUAL(2, w->GetChildren().size());
		w->RemoveChild(w2);
		CHECK_EQUAL(1, w->GetChildren().size());
		Widget::ClearRoot();
	}
}