efl: more aggressive window move test
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Thu, 7 Feb 2013 23:10:24 +0000 (15:10 -0800)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Thu, 7 Feb 2013 23:10:24 +0000 (15:10 -0800)
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
src/efl/evasobject.cpp
src/efl/test_window.cpp

index 46fc92b..11efa08 100644 (file)
@@ -85,14 +85,20 @@ const Eina_Bool EvasObject::isVisible()
 
 void EvasObject::checkSize(const int width, const int height)
 {
-       FAIL_UNLESS_EQUAL(this->getWidth(), width);
-       FAIL_UNLESS_EQUAL(this->getHeight(), height);
+       ASSERT_MSG(getWidth() == width, "width: " << getWidth() << " != " << width);
+       ASSERT_MSG(getHeight() == height, "height: " << getHeight() << " != " << height);
+
+//     FAIL_UNLESS_EQUAL(this->getWidth(), width);
+//     FAIL_UNLESS_EQUAL(this->getHeight(), height);
 }
 
 void EvasObject::checkPosition(const int xcoord, const int ycoord)
 {
-       FAIL_UNLESS_EQUAL(this->getX(), xcoord);
-       FAIL_UNLESS_EQUAL(this->getY(), ycoord);
+       ASSERT_MSG(getX() == xcoord, "x: " << getX() << " != " << xcoord);
+       ASSERT_MSG(getY() == ycoord, "y: " << getY() << " != " << ycoord);
+
+//     FAIL_UNLESS_EQUAL(this->getX(), xcoord);
+//     FAIL_UNLESS_EQUAL(this->getY(), ycoord);
 }
 
 void EvasObject::checkVisible(const Eina_Bool isVisible)
index dc4f7fb..5a67d01 100644 (file)
@@ -108,6 +108,8 @@ public:
        WindowMoveTest()
                : ElmTestHarness::ElmTestHarness()
                , window_("WindowMoveTest", "Window Move Test")
+               , positions_()
+               , moveDone_(false)
        {
                return;
        }
@@ -116,14 +118,74 @@ public:
        {
                window_.show();
 
-               queueStep(boost::bind(&Window::setPosition, boost::ref(window_), 10, 20));
-               queueStep(boost::bind(&Window::checkPosition, boost::ref(window_), 10, 20));
-               queueStep(boost::bind(&Window::setPosition, boost::ref(window_), 15, 25));
-               queueStep(boost::bind(&Window::checkPosition, boost::ref(window_), 15, 25));
+               positions_.push_back(Position(10, 20));
+               positions_.push_back(Position(15, 25));
+
+               evas_object_event_callback_add(window_, EVAS_CALLBACK_MOVE, &onMove, this);
+
+               nextPosition();
+       }
+
+       static void onMove(void *data, Evas*, Evas_Object*, void*)
+       {
+               WindowMoveTest *test = static_cast<WindowMoveTest*>(data);
+               test->moveDone_ = true;
+       }
+
+       void nextPosition() {
+               moveDone_ = false;
+               if (not positions_.empty()) {
+                       Position position(positions_.front());
+                       positions_.pop_front();
+                       queueStep(boost::bind(&Window::setPosition, boost::ref(window_), position.first, position.second));
+                       queueStep(boost::bind(&WindowMoveTest::checkPosition, boost::ref(*this), position.first, position.second, 20));
+               }
+       }
+
+       void checkPosition(int x, int y, unsigned tries)
+       {
+               if (not moveDone_) {
+                       ASSERT_MSG(tries != 0,
+                               "failed to get EVAS_CALLBACK_MOVE event ("
+                               << x << ","
+                               << y << ")"
+                       );
+                       queueStep(boost::bind(&WindowMoveTest::checkPosition, boost::ref(*this), x, y, --tries));
+               } else {
+                       window_.checkPosition(x, y);
+                       checkServerPosition(Geometry(), 2);
+               }
+       }
+
+       void checkServerPosition(Geometry geometry, unsigned tries) {
+               bool positionMatch(
+                       window_.getX() == geometry.x
+                       and window_.getY() == geometry.y);
+
+               if (not positionMatch) {
+                       ASSERT_MSG(tries != 0, ""
+                               << "client position ("
+                               << window_.getX() << ","
+                               << window_.getY() << ") != "
+                               << "server position ("
+                               << geometry.x << ","
+                               << geometry.y << ")"
+                       );
+                       GeometryCallback cb = boost::bind(&WindowMoveTest::checkServerPosition, boost::ref(*this), _1, --tries);
+                       getSurfaceGeometry(elm_win_wl_window_get(window_)->surface, cb);
+               } else {
+                       FAIL_UNLESS(positionMatch);
+                       nextPosition();
+               }
        }
 
 private:
-       Window  window_;
+       typedef std::pair<int, int> Position;
+       typedef std::deque<Position> Positions;
+
+       Window          window_;
+       Positions       positions_;
+       bool            moveDone_;
 };
 
 class WindowIconifyTest : public ElmTestHarness