use namespaces
[test/generic/wayland-fits.git] / src / test / efl / elmtestharness.h
1 /*
2  * Copyright © 2013 Intel Corporation
3  *
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.
13  *
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.
21  */
22
23 #ifndef __WFITS_EFL_ELMTESTHARNESS_H__
24 #define __WFITS_EFL_ELMTESTHARNESS_H__
25
26 #include <Ecore.h>
27 #include <Ecore_Wayland.h>
28 #include <Elementary.h>
29 #include "test/harness.h"
30 #include "application.h"
31
32 namespace wfits {
33 namespace test {
34 namespace efl {
35
36 class ElmTestHarness : public test::Harness
37 {
38 public:
39         typedef ::boost::function<bool (void)> Condition;
40
41         using test::Harness::queueStep;
42
43         /**
44          * Construct the test harness.
45          **/
46         ElmTestHarness();
47
48         void run();
49
50         void queueStep(TestStep, const std::string&);
51
52         /*virtual*/ void yield(const unsigned time = 0.01 * 1e6) const;
53         /*virtual*/ const test::Client& client() const;
54
55         void stepUntilCondition(Condition condition);
56         void assertCondition(Condition condition);
57         void assertCondition(Condition condition, const std::string&);
58
59 private:
60         static Eina_Bool idleStep(void*);
61         static Eina_Bool doStep(void*, int, void*);
62
63         int                     eventType_; /// custom event type
64         Ecore_Event_Handler*    handler_;
65 };
66
67 #define WAYLAND_ELM_HARNESS_EGL_TEST_CASE(Harness, suite) \
68 namespace egl { \
69         TEST(Harness, "EFL/Egl/" suite) \
70         { \
71                 Application app; \
72                 app.setEngine(Application::ENGINE_EGL); \
73                 Harness().run(); \
74         } \
75 } // namespace egl
76
77 #define WAYLAND_ELM_HARNESS_SHM_TEST_CASE(Harness, suite) \
78 namespace shm { \
79         TEST(Harness, "EFL/Shm/" suite) \
80         { \
81                 Application app; \
82                 app.setEngine(Application::ENGINE_SHM); \
83                 Harness().run(); \
84         } \
85 } // namespace shm
86
87 #define WAYLAND_ELM_HARNESS_TEST_CASE(Harness, suite) \
88         WAYLAND_ELM_HARNESS_SHM_TEST_CASE(Harness, suite) \
89         WAYLAND_ELM_HARNESS_EGL_TEST_CASE(Harness, suite)
90
91 } // namespace efl
92 } // namespace test
93 } // namespace wfits
94
95 #endif
96