2 * Copyright © 2013 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #include "elmtestharness.h"
30 class WindowFullscreenTest : public ElmTestHarness
33 WindowFullscreenTest()
34 : ElmTestHarness::ElmTestHarness()
35 , window_("WindowFullscreenTest", "Window Fullscreen Test")
37 , fullscreenDone_(false)
38 , unfullscreenDone_(false)
39 , configureDone_(false)
48 evas_event_callback_add(evas_object_evas_get(window_), EVAS_CALLBACK_RENDER_POST, onPostRender, this);
49 evas_object_event_callback_add(window_, EVAS_CALLBACK_RESIZE, &onResize, this);
50 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE, onConfigure, this);
52 evas_object_smart_callback_add(window_, "fullscreen", onFullscreen, this);
53 evas_object_smart_callback_add(window_, "unfullscreen", onUnFullscreen, this);
57 for(unsigned i(0); i < 5; ++i) {
58 queueStep(boost::bind(&WindowFullscreenTest::test, boost::ref(*this)));
64 static bool initial(true);
66 fullscreenDone_ = false;
67 configureDone_ = false;
69 unfullscreenDone_ = false;
71 YIELD_UNTIL(rendered_);
74 geometry_ = getSurfaceGeometry(window_.get_wl_surface());
76 std::cout << "...initial server geometry is: "
79 << geometry_.width << "x"
80 << geometry_.height << std::endl;
84 std::cout << "...asserting client geometry == server geometry == initial server geometry" << std::endl;
85 ASSERT(isInitialGeometry());
87 ASSERT(not fullscreenDone_);
88 ASSERT(not configureDone_);
89 ASSERT(not resizeDone_);
91 std::cout << "...setting fullscreen" << std::endl;
92 window_.fullscreen(EINA_TRUE);
94 std::cout << "...checking for fullscreen events" << std::endl;
95 YIELD_UNTIL(fullscreenDone_ and configureDone_ and resizeDone_);
97 window_.checkFullscreen(EINA_TRUE);
99 std::cout << "...checking client geometry == server geometry == screen geometry" << std::endl;
100 YIELD_UNTIL(isScreenGeometry());
102 configureDone_ = false;
105 ASSERT(not unfullscreenDone_);
107 std::cout << "...setting unfullscreen" << std::endl;
108 window_.fullscreen(EINA_FALSE);
110 std::cout << "...checking for unfullscreen events" << std::endl;
111 YIELD_UNTIL(unfullscreenDone_ and configureDone_ and resizeDone_);
113 window_.checkFullscreen(EINA_FALSE);
115 std::cout << "...checking client geometry == server geometry == initial server geometry" << std::endl;
116 YIELD_UNTIL(isInitialGeometry());
119 bool isInitialGeometry()
121 const Geometry sg(getSurfaceGeometry(window_.get_wl_surface()));
122 const Geometry fg(window_.getFramespaceGeometry());
124 return sg.x == geometry_.x
125 and sg.y == geometry_.y
126 and sg.width == geometry_.width
127 and sg.height == geometry_.height
128 and window_.getWidth() + fg.width == geometry_.width
129 and window_.getHeight() + fg.height == geometry_.height
131 // NOTE: server does not support client side positioning
134 bool isScreenGeometry()
137 elm_win_screen_size_get(window_, &sx, &sy, &sw, &sh);
138 const Geometry g(getSurfaceGeometry(window_.get_wl_surface()));
144 and window_.getX() == sx
145 and window_.getY() == sy
146 and window_.getWidth() == sw
147 and window_.getHeight() == sh
151 static void onPostRender(void *data, Evas *e, void *info)
153 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, onPostRender);
155 WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
156 test->rendered_ = true;
157 std::cout << "...got post render event" << std::endl;
160 static Eina_Bool onConfigure(void *data, int type, void *event)
162 WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
163 Ecore_Wl_Event_Window_Configure *ev = static_cast<Ecore_Wl_Event_Window_Configure *>(event);
164 test->configureDone_ = true;
165 std::cout << "...got configure event: "
169 << ev->h << std::endl;
170 return ECORE_CALLBACK_PASS_ON;
173 static void onResize(void *data, Evas*, Evas_Object*, void*)
175 WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
176 test->resizeDone_ = true;
177 std::cout << "...got resize event" << std::endl;
180 static void onFullscreen(void* data, Evas_Object *obj, void* event_info)
182 WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
183 test->fullscreenDone_ = true;
184 std::cout << "...got fullscreen event" << std::endl;
187 static void onUnFullscreen(void *data, Evas_Object*, void*)
189 WindowFullscreenTest *test = static_cast<WindowFullscreenTest*>(data);
190 test->unfullscreenDone_ = true;
191 std::cout << "...got unfullscreen event" << std::endl;
197 bool fullscreenDone_;
198 bool unfullscreenDone_;
204 WAYLAND_ELM_HARNESS_TEST_CASE(WindowFullscreenTest, "Window")