refactor: more foreach; flipselector: add more selection check
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Wed, 1 Aug 2012 23:33:11 +0000 (16:33 -0700)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Wed, 1 Aug 2012 23:33:11 +0000 (16:33 -0700)
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
src/efl/templates.h
src/efl/test_fileselector_button.cpp
src/efl/test_fileselector_entry.cpp
src/efl/test_flip.cpp
src/efl/test_flipselector.cpp
src/test.h

index 33d07bb..2acdd98 100644 (file)
@@ -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(
index d93bf89..b1d69bd 100644 (file)
@@ -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<Eina_Bool>::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<Eina_Bool>::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<Eina_Bool>::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)
                                )
                        );
                }
index 86ab2dc..5eea57b 100644 (file)
@@ -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<Eina_Bool>::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<Eina_Bool>::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<Eina_Bool>::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<Eina_Bool>::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)
                                )
                        );
                }
index ab69387..e8c2d5a 100644 (file)
@@ -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<Elm_Flip_Mode>::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)
                                )
                        );
index 3510312..eff7689 100644 (file)
@@ -43,14 +43,23 @@ public:
 
        void setup()
        {
-               vector<string>::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<Elm_Object_Item*>(NULL));
+               
+               vector<Elm_Object_Item*> 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<Elm_Object_Item*>(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<Elm_Object_Item*>::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<string>                  strings_;
-       vector<Elm_Object_Item*>        items_;
-       
+       Window                  window_;
+       Flipselector    control_;
+       vector<string>  strings_;
 };
 
 typedef ResizeObjectTest<Flipselector> FlipSelectorResizeTest;
@@ -92,7 +111,7 @@ typedef VisibleObjectTest<Flipselector> 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)
index 09767cf..7fb53bd 100644 (file)
@@ -6,5 +6,6 @@
 #include <boost/foreach.hpp>
 
 #define foreach BOOST_FOREACH
+#define foreach_reverse BOOST_REVERSE_FOREACH
 
 #endif