TEST_F(TextContextTest, EmptySpaceTest) { Handler<TextDrawableObject> aa = r->create("a", nullptr, 1); Handler<TextDrawableObject> ab = r->create("b", nullptr, 1); Handler<TextDrawableObject> cmd = r->create("ab", nullptr, 1); ASSERT_FLOAT_EQ(aa->width()+ab->width(), cmd->width()); ASSERT_FLOAT_EQ(geom::max(aa->height(), ab->height()), cmd->height()); }
TEST_F(DrawableTest, StretchDrawableTest) { Handler<Drawable> dr = dmanager->queryDrawable("stretch:color:red", geom::Box(100,100)); ASSERT_TRUE(dynamic_cast<StretchDrawable*>(dr.get())); ASSERT_FLOAT_EQ(100, dr->width()); ASSERT_FLOAT_EQ(100, dr->height()); }
void BlockSession::extendInline(Handler<RenderObject> obj) { if(obj->width() > this->calcBlockLimit() - this->inlinePosX_ ){ this->newInline(); } if(this->dir_ == BlockNode::Direction::Left){ obj->area(geom::Area(this->inlinePosX_, this->inlineConsumedHeight_+this->consumedHeight_, obj->width(), obj->height())); this->inlinePosX_ += obj->width(); this->inlineHeight_ = std::max( this->inlineHeight_, obj->height() ); this->inlineObjects_.push_back(obj); }else{ obj->area(geom::Area(this->blockPosX_+this->inlinePosX_, this->inlineConsumedHeight_+this->consumedHeight_, obj->width(), obj->height())); this->inlinePosX_ += obj->width(); this->inlineHeight_ = std::max( this->inlineHeight_, obj->height() ); this->inlineObjects_.push_back(obj); } }
TEST_F(DrawableTest, ColorDrawableTest) { Handler<Drawable> dr = dmanager->queryDrawable("color:red", geom::Box(100,100)); ASSERT_TRUE(dynamic_cast<ColorDrawable*>(dr.get())); ASSERT_FLOAT_EQ(100, dr->width()); ASSERT_FLOAT_EQ(100, dr->height()); ASSERT_TRUE(dr->size().near(geom::Box(100, 100), 1)); ASSERT_EQ(Red, dr.cast<ColorDrawable>()->color()); }
TEST_F(DrawableTest, ImageDrawableWithoutSizeTest) { Handler<Drawable> dr = dmanager->queryDrawable("image:" MATERIAL_DIR "/img/test.png", geom::Box()); ASSERT_TRUE(dynamic_cast<ImageDrawable*>(dr.get())); ASSERT_FLOAT_EQ(360, dr->width()); ASSERT_FLOAT_EQ(480, dr->height()); ASSERT_TRUE(dr->size().near(geom::Box(360, 480), 1)); Handler<ImageDrawable> img(dr.cast<ImageDrawable>()); ASSERT_EQ(360, img->sprite()->width()); ASSERT_EQ(480, img->sprite()->height()); }