upload tizen1.0 source
[platform/framework/web/wrt-plugins-common.git] / src / standards / W3C / Widget / Test.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    Test.h
18  * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
19  * @version 1.0
20  * @date    09/13/2011 08:24:44 AM
21  * @brief
22  */
23
24 #ifndef WRTPLUGINS_W3C_TEST_H_
25 #define WRTPLUGINS_W3C_TEST_H_
26
27 #include <string>
28 #include <dpl/generic_event.h>
29 #include <dpl/event/controller.h>
30 #include <dpl/type_list.h>
31 #include <JavaScriptCore/JavaScript.h>
32
33 namespace WrtPlugins {
34 namespace W3C {
35
36 DECLARE_GENERIC_EVENT_0(FinishEvent)
37
38 class Test : public DPL::Event::Controller<DPL::TypeListDecl<FinishEvent>::Type> {
39   public:
40     Test();
41
42     void run(double timeout = 0.0);
43     void setEvaluator(JSObjectRef evaluator);
44     void setContext(JSContextRef context);
45
46   protected:
47     void OnEventReceived(const FinishEvent& event);
48
49   private:
50     enum class Result {
51         Success,
52         Fail,
53         Exception
54     };
55
56   private:
57     std::string resultToString(Result result);
58
59   private:
60     JSContextRef m_context;
61     JSObjectRef m_evaluator;
62 };
63
64 }
65 }
66 #endif