From: Joe Konno Date: Thu, 19 Jul 2012 20:56:54 +0000 (-0700) Subject: EFL: moderate refactor of background tests X-Git-Tag: upstream/0.2.1~295 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=babb7c8a1c30bdc2a5a320272de6140e37858090;p=test%2Fgeneric%2Fwayland-fits.git EFL: moderate refactor of background tests Added some setup checking, more consistent naming. Signed-off-by: Joe Konno --- diff --git a/src/efl/test_background.cpp b/src/efl/test_background.cpp index 8a693fd..26165af 100644 --- a/src/efl/test_background.cpp +++ b/src/efl/test_background.cpp @@ -1,6 +1,8 @@ #include #include +#include + #include "application.h" #include "window.h" #include "background.h" @@ -8,6 +10,7 @@ #include "elmtestharness.h" using boost::filesystem::path; +using std::vector; class BackgroundColorTest : public ElmTestHarness { @@ -16,16 +19,16 @@ public: BackgroundColorTest() : ElmTestHarness::ElmTestHarness() , window_("BackgroundColorTest", "Background Color Test") - , bg_(window_) + , control_(window_) { - evas_object_size_hint_weight_set(bg_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(window_, bg_); + evas_object_size_hint_weight_set(control_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(window_, control_); return; } void setup() { - bg_.show(); + control_.show(); window_.show(); int r, g, b; @@ -35,24 +38,26 @@ public: { queueCallback( ModifyCheckCallback( - boost::bind(&Background::setColor, boost::ref(bg_), r, g, b), + boost::bind(&Background::setColor, boost::ref(control_), r, g, b), boost::bind(&BackgroundColorTest::checkColor, boost::ref(*this), r, g, b) ) ); } } - void checkColor(int r, int g, int b) + void checkColor(int r_expected, int g_expected, int b_expected) { - int r_, g_, b_; - bg_.getColor(&r_, &g_, &b_); + int r_actual, g_actual, b_actual; + control_.getColor(&r_actual, &g_actual, &b_actual); - BOOST_CHECK(r_ == r && g_ == g && b_ == b); + BOOST_CHECK_EQUAL(r_actual, r_expected); + BOOST_CHECK_EQUAL(g_actual, g_expected); + BOOST_CHECK_EQUAL(b_actual, b_expected); } private: Window window_; - Background bg_; + Background control_; }; class BackgroundImageTest : public ElmTestHarness @@ -62,65 +67,77 @@ public: BackgroundImageTest() : ElmTestHarness::ElmTestHarness() , window_("BackgroundImageTest", "Background Image Test") - , bg_(window_) + , control_(window_) { - evas_object_size_hint_weight_set(bg_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(window_, bg_); + evas_object_size_hint_weight_set(control_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(window_, control_); + window_.maximize(EINA_TRUE); + + options_.push_back(ELM_BG_OPTION_SCALE); + options_.push_back(ELM_BG_OPTION_CENTER); + options_.push_back(ELM_BG_OPTION_STRETCH); + options_.push_back(ELM_BG_OPTION_CENTER); + options_.push_back(ELM_BG_OPTION_TILE); + options_.push_back(ELM_BG_OPTION_CENTER); + return; } void setup() { - bg_.show(); + control_.show(); window_.show(); path p(MEDIA_PATH"/bridge_of_the_gods.png"); queueCallback( ModifyCheckCallback( - boost::bind(&Background::setImage, boost::ref(bg_), p), + boost::bind(&Background::setImage, boost::ref(control_), p), boost::bind(&BackgroundImageTest::checkImage, boost::ref(*this), p) ) ); - Elm_Bg_Option option[] = { ELM_BG_OPTION_SCALE, - ELM_BG_OPTION_CENTER, - ELM_BG_OPTION_STRETCH, - ELM_BG_OPTION_CENTER, - ELM_BG_OPTION_TILE, - ELM_BG_OPTION_CENTER - }; - - window_.maximize(EINA_TRUE); + queueCallback( + ModifyCheckCallback( + boost::bind(&Window::maximize, boost::ref(window_), EINA_TRUE), + boost::bind(&BackgroundImageTest::checkMax, boost::ref(*this), EINA_TRUE) + ) + ); - unsigned int o; - for (o = 0; o < (sizeof(option) / sizeof(Elm_Bg_Option)); o++) + vector::iterator it; + for (it = options_.begin(); it != options_.end(); it++) { queueCallback( ModifyCheckCallback( - boost::bind(&Background::setImageOpt, boost::ref(bg_), option[o]), - boost::bind(&BackgroundImageTest::checkImageOpt, boost::ref(*this), option[o]) + boost::bind(&Background::setImageOpt, boost::ref(control_), *it), + boost::bind(&BackgroundImageTest::checkImageOpt, boost::ref(*this), *it) ) ); } } - void checkImage(path& p) + void checkMax(const Eina_Bool expected) { - path ret; - bg_.getImage(ret); + BOOST_CHECK_EQUAL(window_.isMaximized(), expected); + } - BOOST_CHECK_EQUAL(ret, p); + void checkImage(path& expected) + { + path actual; + control_.getImage(actual); + + BOOST_CHECK_EQUAL(actual, expected); } - void checkImageOpt(Elm_Bg_Option option) + void checkImageOpt(Elm_Bg_Option expected) { - BOOST_CHECK_EQUAL(option, bg_.getImageOpt()); + BOOST_CHECK_EQUAL(control_.getImageOpt(), expected); } private: - Window window_; - Background bg_; + Window window_; + Background control_; + vector options_; }; BOOST_AUTO_TEST_SUITE(EFL)