From: U. Artie Eoff Date: Wed, 1 Aug 2012 23:33:11 +0000 (-0700) Subject: refactor: more foreach; flipselector: add more selection check X-Git-Tag: upstream/0.2.1~254 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79c50c3d1a254adfbeb3faa346c2c4f8ea5cc572;p=test%2Fgeneric%2Fwayland-fits.git refactor: more foreach; flipselector: add more selection check Signed-off-by: U. Artie Eoff --- diff --git a/src/efl/templates.h b/src/efl/templates.h index 33d07bb..2acdd98 100644 --- a/src/efl/templates.h +++ b/src/efl/templates.h @@ -35,9 +35,9 @@ public: window_.show(); object_.show(); - foreach (const int& w, widths_) + foreach (const int w, widths_) { - foreach (const int& h, heights_) + foreach (const int h, heights_) { queueCallback( ModifyCheckCallback( diff --git a/src/efl/test_fileselector_button.cpp b/src/efl/test_fileselector_button.cpp index d93bf89..b1d69bd 100644 --- a/src/efl/test_fileselector_button.cpp +++ b/src/efl/test_fileselector_button.cpp @@ -35,8 +35,6 @@ public: states_.push_back(EINA_TRUE); states_.push_back(EINA_FALSE); states_.push_back(EINA_TRUE); - - return; } void setup() @@ -83,8 +81,6 @@ public: states_.push_back(EINA_TRUE); states_.push_back(EINA_FALSE); states_.push_back(EINA_TRUE); - - return; } void setup() @@ -92,13 +88,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_button_folder_only_set, boost::ref(control_), *it), - boost::bind(&FileselectorButtonFolderOnlyTest::checkFolderOnly, boost::ref(*this), *it) + boost::bind(elm_fileselector_button_folder_only_set, boost::ref(control_), state), + boost::bind(&FileselectorButtonFolderOnlyTest::checkFolderOnly, boost::ref(*this), state) ) ); } @@ -130,8 +125,6 @@ public: states_.push_back(EINA_TRUE); states_.push_back(EINA_FALSE); states_.push_back(EINA_TRUE); - - return; } void setup() @@ -139,13 +132,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_button_is_save_set, boost::ref(control_), *it), - boost::bind(&FileselectorButtonIsSaveTest::checkIsSave, boost::ref(*this), *it) + boost::bind(elm_fileselector_button_is_save_set, boost::ref(control_), state), + boost::bind(&FileselectorButtonIsSaveTest::checkIsSave, boost::ref(*this), state) ) ); } @@ -174,8 +166,6 @@ public: states_.push_back(EINA_TRUE); states_.push_back(EINA_FALSE); states_.push_back(EINA_TRUE); - - return; } void setup() @@ -186,13 +176,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_button_inwin_mode_set, boost::ref(control_), *it), - boost::bind(&FileselectorButtonInwinTest::checkInwin, boost::ref(*this), *it) + boost::bind(elm_fileselector_button_inwin_mode_set, boost::ref(control_), state), + boost::bind(&FileselectorButtonInwinTest::checkInwin, boost::ref(*this), state) ) ); } diff --git a/src/efl/test_fileselector_entry.cpp b/src/efl/test_fileselector_entry.cpp index 86ab2dc..5eea57b 100644 --- a/src/efl/test_fileselector_entry.cpp +++ b/src/efl/test_fileselector_entry.cpp @@ -38,8 +38,6 @@ public: states_.push_back(EINA_TRUE); states_.push_back(EINA_FALSE); states_.push_back(EINA_TRUE); - - return; } void setup() @@ -47,13 +45,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_entry_expandable_set, boost::ref(control_), *it), - boost::bind(&FileselectorEntryExpandableTest::checkExpandable, boost::ref(*this), *it) + boost::bind(elm_fileselector_entry_expandable_set, boost::ref(control_), state), + boost::bind(&FileselectorEntryExpandableTest::checkExpandable, boost::ref(*this), state) ) ); } @@ -85,8 +82,6 @@ public: states_.push_back(EINA_TRUE); states_.push_back(EINA_FALSE); states_.push_back(EINA_TRUE); - - return; } void setup() @@ -94,13 +89,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_entry_folder_only_set, boost::ref(control_), *it), - boost::bind(&FileselectorEntryFolderOnlyTest::checkFolderOnly, boost::ref(*this), *it) + boost::bind(elm_fileselector_entry_folder_only_set, boost::ref(control_), state), + boost::bind(&FileselectorEntryFolderOnlyTest::checkFolderOnly, boost::ref(*this), state) ) ); } @@ -141,13 +135,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_entry_is_save_set, boost::ref(control_), *it), - boost::bind(&FileselectorEntryIsSaveTest::checkIsSave, boost::ref(*this), *it) + boost::bind(elm_fileselector_entry_is_save_set, boost::ref(control_), state), + boost::bind(&FileselectorEntryIsSaveTest::checkIsSave, boost::ref(*this), state) ) ); } @@ -188,13 +181,12 @@ public: window_.show(); control_.show(); - vector::iterator it; - for (it = states_.begin(); it != states_.end(); it++) + foreach (Eina_Bool state, states_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_fileselector_entry_inwin_mode_set, boost::ref(control_), *it), - boost::bind(&FileselectorEntryInwinTest::checkInwin, boost::ref(*this), *it) + boost::bind(elm_fileselector_entry_inwin_mode_set, boost::ref(control_), state), + boost::bind(&FileselectorEntryInwinTest::checkInwin, boost::ref(*this), state) ) ); } diff --git a/src/efl/test_flip.cpp b/src/efl/test_flip.cpp index ab69387..e8c2d5a 100644 --- a/src/efl/test_flip.cpp +++ b/src/efl/test_flip.cpp @@ -54,8 +54,6 @@ public: options_.push_back(ELM_FLIP_PAGE_RIGHT); options_.push_back(ELM_FLIP_PAGE_UP); options_.push_back(ELM_FLIP_PAGE_DOWN); - - return; } void setup() @@ -65,19 +63,18 @@ public: second_.show(); window_.show(); - vector::iterator it; - for (it = options_.begin(); it != options_.end(); it++) + foreach (Elm_Flip_Mode option, options_) { queueCallback( ModifyCheckCallback( - boost::bind(elm_flip_go, boost::ref(control_), *it), + boost::bind(elm_flip_go, boost::ref(control_), option), boost::bind(&FlipGoTest::checkFront, boost::ref(*this), EINA_TRUE) ) ); queueCallback( ModifyCheckCallback( - boost::bind(elm_flip_go, boost::ref(control_), *it), + boost::bind(elm_flip_go, boost::ref(control_), option), boost::bind(&FlipGoTest::checkFront, boost::ref(*this), EINA_FALSE) ) ); diff --git a/src/efl/test_flipselector.cpp b/src/efl/test_flipselector.cpp index 3510312..eff7689 100644 --- a/src/efl/test_flipselector.cpp +++ b/src/efl/test_flipselector.cpp @@ -43,14 +43,23 @@ public: void setup() { - vector::iterator string_it; - for (string_it = strings_.begin(); string_it != strings_.end(); string_it++) + Elm_Object_Item* pivot( + elm_flipselector_item_append( + control_, "PIVOT", NULL, NULL + ) + ); + + BOOST_CHECK_NE(pivot, static_cast(NULL)); + + vector items; + + foreach (const std::string& label, strings_) { - Elm_Object_Item* item = elm_flipselector_item_append(control_, string_it->c_str(), NULL, NULL); - BOOST_CHECK_NE(item, (Elm_Object_Item*)NULL); + Elm_Object_Item* item = elm_flipselector_item_append(control_, label.c_str(), NULL, NULL); + BOOST_CHECK_NE(item, static_cast(NULL)); if (item != NULL) { - items_.push_back(item); + items.push_back(item); } } @@ -60,30 +69,40 @@ public: control_.setSize(200, 200); control_.setPosition(50, 10); - vector::reverse_iterator item_it; - for (item_it = items_.rbegin(); item_it != items_.rend(); item_it++) + foreach_reverse (Elm_Object_Item* item, items) { queueCallback( ModifyCheckCallback( - boost::bind(elm_flipselector_item_selected_set, boost::ref(*item_it), EINA_TRUE), - boost::bind(&FlipSelectorItemTest::checkItem, boost::ref(*this), *item_it) + boost::bind(elm_flipselector_item_selected_set, item, EINA_TRUE), + boost::bind(&FlipSelectorItemTest::checkItem, boost::ref(*this), item, pivot, EINA_TRUE) + ) + ); + queueCallback( + ModifyCheckCallback( + boost::bind(elm_flipselector_item_selected_set, pivot, EINA_TRUE), + boost::bind(&FlipSelectorItemTest::checkItem, boost::ref(*this), item, pivot, EINA_FALSE) + ) + ); + queueCallback( + ModifyCheckCallback( + boost::bind(elm_flipselector_item_selected_set, item, EINA_TRUE), + boost::bind(&FlipSelectorItemTest::checkItem, boost::ref(*this), item, pivot, EINA_TRUE) ) ); } } - void checkItem(const Elm_Object_Item* expected) + void checkItem(const Elm_Object_Item* item, const Elm_Object_Item* pivot, Eina_Bool expected) { - BOOST_CHECK_EQUAL(elm_flipselector_item_selected_get(expected), EINA_TRUE); + BOOST_CHECK_EQUAL(elm_flipselector_item_selected_get(item), expected); + BOOST_CHECK_EQUAL(elm_flipselector_item_selected_get(pivot), not expected); } private: - Window window_; - Flipselector control_; - vector strings_; - vector items_; - + Window window_; + Flipselector control_; + vector strings_; }; typedef ResizeObjectTest FlipSelectorResizeTest; @@ -92,7 +111,7 @@ typedef VisibleObjectTest FlipSelectorVisibilityTest; BOOST_AUTO_TEST_SUITE(EFL) - BOOST_AUTO_TEST_SUITE(FlipSelectorSuite) + BOOST_AUTO_TEST_SUITE(FlipSelector) WAYLAND_ELM_HARNESS_TEST_CASE(FlipSelectorItemTest) WAYLAND_ELM_HARNESS_TEST_CASE(FlipSelectorResizeTest) diff --git a/src/test.h b/src/test.h index 09767cf..7fb53bd 100644 --- a/src/test.h +++ b/src/test.h @@ -6,5 +6,6 @@ #include #define foreach BOOST_FOREACH +#define foreach_reverse BOOST_REVERSE_FOREACH #endif