efl: improve window fullscreen test
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Thu, 21 Mar 2013 21:11:36 +0000 (14:11 -0700)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Thu, 21 Mar 2013 21:11:36 +0000 (14:11 -0700)
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
src/efl/Makefile.am
src/efl/test_window.cpp
src/efl/test_window_fullscreen.cpp [new file with mode: 0644]

index 7938286..44e6d38 100644 (file)
@@ -47,6 +47,7 @@ libwfits_efl_la_SOURCES = \
        test_window_resize.cpp          \
        test_window_move.cpp            \
        test_window_maximize.cpp        \
+       test_window_fullscreen.cpp      \
        $(top_srcdir)/src/extensions/protocol/wayland-fits-protocol.c
 
 libwfits_efl_la_LIBADD = \
index 2d29a58..762157d 100644 (file)
@@ -5,30 +5,6 @@
 
 using std::vector;
 
-class WindowFullscreenTest : public ElmTestHarness
-{
-public:
-       WindowFullscreenTest()
-               : ElmTestHarness::ElmTestHarness()
-               , window_("WindowFullscreenTest", "Window Fullscreen Test")
-       {
-               return;
-       }
-
-       void setup()
-       {
-               window_.show();
-
-               queueStep(boost::bind(&Window::fullscreen, boost::ref(window_), EINA_TRUE));
-               queueStep(boost::bind(&Window::checkFullscreen, boost::ref(window_), EINA_TRUE));
-               queueStep(boost::bind(&Window::fullscreen, boost::ref(window_), EINA_FALSE));
-               queueStep(boost::bind(&Window::checkFullscreen, boost::ref(window_), EINA_FALSE));
-       }
-
-private:
-       Window  window_;
-};
-
 class WindowIconifyTest : public ElmTestHarness
 {
 public:
@@ -262,7 +238,6 @@ private:
 };
 
 WAYLAND_ELM_HARNESS_TEST_CASE(WindowIconifyTest, "Window")
-WAYLAND_ELM_HARNESS_TEST_CASE(WindowFullscreenTest, "Window")
 WAYLAND_ELM_HARNESS_TEST_CASE(WindowStickyTest, "Window")
 WAYLAND_ELM_HARNESS_TEST_CASE(WindowWithdrawnTest, "Window")
 WAYLAND_ELM_HARNESS_TEST_CASE(WindowRotationTest, "Window")
diff --git a/src/efl/test_window_fullscreen.cpp b/src/efl/test_window_fullscreen.cpp
new file mode 100644 (file)
index 0000000..0a9c850
--- /dev/null
@@ -0,0 +1,250 @@
+#include "window.h"
+#include "elmtestharness.h"
+
+class WindowFullscreenTest : public ElmTestHarness
+{
+public:
+       WindowFullscreenTest()
+               : ElmTestHarness::ElmTestHarness()
+               , window_("WindowFullscreenTest", "Window Fullscreen Test")
+               , initialGeometry_()
+               , fullscreenDone_(EINA_FALSE)
+               , unfullscreenDone_(EINA_FALSE)
+               , configureDone_(EINA_FALSE)
+               , resizeDone_(EINA_FALSE)
+       {
+               return;
+       }
+
+       void setup()
+       {
+               window_.show();
+
+               Application::yield(0.01*1e6);
+               initialGeometry_ = getSurfaceGeometry(window_.get_wl_surface());
+               std::cout << "...initial server geometry is: "
+                       << initialGeometry_.x << " "
+                       << initialGeometry_.y << " "
+                       << initialGeometry_.width << " "
+                       << initialGeometry_.height << std::endl;
+
+               evas_object_smart_callback_add(window_, "fullscreen", onFullscreen, this);
+               evas_object_smart_callback_add(window_, "unfullscreen", onUnFullscreen, this);
+               evas_object_event_callback_add(window_, EVAS_CALLBACK_RESIZE, &onResize, this);
+               ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE, onConfigure, this);
+
+               for(unsigned i(0); i < 5; ++i)
+                       addFullscreenTest();
+       }
+
+       void addFullscreenTest()
+       {
+               // Set Window Fullscreen
+               queueStep(
+                       boost::lambda::bind(
+                               &WindowFullscreenTest::fullscreenDone_,
+                               boost::ref(*this)
+                       ) = EINA_FALSE
+               );
+               queueStep(
+                       boost::lambda::bind(
+                               &WindowFullscreenTest::configureDone_,
+                               boost::ref(*this)
+                       ) = EINA_FALSE
+               );
+               queueStep(
+                       boost::lambda::bind(
+                               &WindowFullscreenTest::resizeDone_,
+                               boost::ref(*this)
+                       ) = EINA_FALSE
+               );
+               queueStep(
+                       boost::bind(
+                               &Window::fullscreen, boost::ref(window_),
+                               EINA_TRUE
+                       ),
+                       "set fullscreen"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::fullscreenDone_, boost::ref(*this)) == EINA_TRUE
+                       ),
+                       "checking fullscreen event"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::configureDone_, boost::ref(*this)) == EINA_TRUE
+                       ),
+                       "checking configure event"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::resizeDone_, boost::ref(*this)) == EINA_TRUE
+                       ),
+                       "checking resize event"
+               );
+               queueStep(
+                       boost::bind(
+                               &Window::checkFullscreen, boost::ref(window_),
+                               EINA_TRUE
+                       ),
+                       "checking client is fullscreen"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::isScreenGeometry, boost::ref(*this))
+                       ),
+                       "checking client geometry == server geometry == screen geometry"
+               );
+
+               // Unfullscreen/Restore Window
+               queueStep(
+                       boost::lambda::bind(
+                               &WindowFullscreenTest::unfullscreenDone_,
+                               boost::ref(*this)
+                       ) = EINA_FALSE
+               );
+               queueStep(
+                       boost::lambda::bind(
+                               &WindowFullscreenTest::configureDone_,
+                               boost::ref(*this)
+                       ) = EINA_FALSE
+               );
+               queueStep(
+                       boost::lambda::bind(
+                               &WindowFullscreenTest::resizeDone_,
+                               boost::ref(*this)
+                       ) = EINA_FALSE
+               );
+               queueStep(
+                       boost::bind(
+                               &Window::fullscreen, boost::ref(window_),
+                               EINA_FALSE
+                       ),
+                       "set unfullscreen"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::configureDone_, boost::ref(*this)) == EINA_TRUE
+                       ),
+                       "checking configure event"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::unfullscreenDone_, boost::ref(*this)) == EINA_TRUE
+                       ),
+                       "checking unfullscreen event"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::resizeDone_, boost::ref(*this)) == EINA_TRUE
+                       ),
+                       "checking resize event"
+               );
+                       queueStep(
+                       boost::bind(
+                               &Window::checkFullscreen, boost::ref(window_),
+                               EINA_FALSE
+                       ),
+                       "checking client is not fullscreen"
+               );
+               queueStep(
+                       boost::bind(
+                               &WindowFullscreenTest::stepUntilCondition,
+                               boost::ref(*this),
+                               boost::lambda::bind(&WindowFullscreenTest::isInitialGeometry, boost::ref(*this))
+                       ),
+                       "checking client geometry == initial server geometry"
+               );
+       }
+
+       bool isInitialGeometry()
+       {
+               const Geometry g(getSurfaceGeometry(window_.get_wl_surface()));
+
+               return g.x == initialGeometry_.x
+                       and g.y == initialGeometry_.y
+                       and g.width == initialGeometry_.width
+                       and g.height == initialGeometry_.height
+                       and window_.getWidth() == initialGeometry_.width
+                       and window_.getHeight() == initialGeometry_.height
+               ;
+               // NOTE: server does not support client side positioning
+       }
+
+       bool isScreenGeometry()
+       {
+               int sx, sy, sw, sh;
+               elm_win_screen_size_get(window_, &sx, &sy, &sw, &sh);
+               const Geometry g(getSurfaceGeometry(window_.get_wl_surface()));
+
+               return g.x == sx
+                       and g.y == sy
+                       and g.width == sw
+                       and g.height == sh
+                       and window_.getX() == sx
+                       and window_.getY() == sy
+                       and window_.getWidth() == sw
+                       and window_.getHeight() == sh
+               ;
+       }
+
+       static Eina_Bool onConfigure(void *data, int type, void *event)
+       {
+               WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
+               test->configureDone_ = true;
+               Ecore_Wl_Event_Window_Configure *ev = static_cast<Ecore_Wl_Event_Window_Configure *>(event);
+
+               std::cout << "...got configure event: "
+                       << ev->x << " "
+                       << ev->y << " "
+                       << ev->w << " "
+                       << ev->h << std::endl;
+               return ECORE_CALLBACK_PASS_ON;
+       }
+
+       static void onResize(void *data, Evas*, Evas_Object*, void*)
+       {
+               WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
+               std::cout << "...got resize event" << std::endl;
+               test->resizeDone_ = true;
+       }
+
+       static void onFullscreen(void* data, Evas_Object *obj, void* event_info)
+       {
+               WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
+               std::cout << "...got fullscreen event" << std::endl;
+               test->fullscreenDone_ = EINA_TRUE;
+       }
+
+       static void onUnFullscreen(void *data, Evas_Object*, void*)
+       {
+               WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
+               std::cout << "...got unfullscreen event" << std::endl;
+               test->unfullscreenDone_ = EINA_TRUE;
+       }
+       
+private:
+       Window          window_;
+       Geometry        initialGeometry_;
+       Eina_Bool       fullscreenDone_;
+       Eina_Bool       unfullscreenDone_;
+       Eina_Bool       configureDone_;
+       Eina_Bool       resizeDone_;
+};
+
+WAYLAND_ELM_HARNESS_TEST_CASE(WindowFullscreenTest, "Window")