[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_context_inspector_server_start_func.cpp
1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "utc_blink_ewk_base.h"
6
7 class utc_blink_ewk_context_inspector_server_start : public utc_blink_ewk_base
8 {
9   void LoadFinished(Evas_Object* webview) override { EventLoopStop(Success); }
10 };
11
12 /* @brief Negative test case of ewk_context_inspector_server_start */
13 TEST_F(utc_blink_ewk_context_inspector_server_start, NullArg)
14 {
15   ASSERT_NE(EINA_TRUE, ewk_context_inspector_server_start(NULL,0));
16 }
17
18 /* @brief Try start inspector of context on specified TCP port*/
19 TEST_F(utc_blink_ewk_context_inspector_server_start, Start)
20 {
21   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://localhost:11111"));
22   ASSERT_NE(Success, EventLoopStart()) << "http://localhost:11111";
23
24   ASSERT_EQ(11111, ewk_context_inspector_server_start(ewk_context_default_get(), 11111));
25   EventLoopWait(1);
26
27   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://localhost:11111"));
28   ASSERT_EQ(Success, EventLoopStart()) << "http://localhost:11111";
29
30   // need to stop server before next testcase, as context will be shared between tests
31   ASSERT_EQ(EINA_TRUE, ewk_context_inspector_server_stop(ewk_context_default_get()));
32   EventLoopWait(1);
33 }
34
35 /* @brief Try start inspector of context on unspecified TCP port*/
36 TEST_F(utc_blink_ewk_context_inspector_server_start, DefaultPort)
37 {
38   int port=ewk_context_inspector_server_start(ewk_context_default_get(), 0);
39   ASSERT_NE(0, port) << "ewk_context_inspector_server_start(0)";
40   EventLoopWait(1);
41
42   char url[32]; sprintf(url, "http://localhost:%u", port);
43   ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), url));
44   ASSERT_EQ(Success, EventLoopStart()) << url;
45
46   // need to stop server before next testcase, as context will be shared between tests
47   ASSERT_EQ(EINA_TRUE, ewk_context_inspector_server_stop(ewk_context_default_get()));
48   EventLoopWait(1);
49 }
50
51 /* @brief Negative test case of ewk_context_inspector_server_start on used port*/
52 TEST_F(utc_blink_ewk_context_inspector_server_start, UsedPort)
53 {
54   ASSERT_EQ(11111, ewk_view_inspector_server_start(GetEwkWebView(),11111));
55   EventLoopWait(1);
56   ASSERT_NE(11111, ewk_context_inspector_server_start(ewk_context_default_get(),11111));
57
58   // need to stop server before next testcase, as context will be shared between tests
59   ASSERT_EQ(EINA_TRUE, ewk_view_inspector_server_stop(GetEwkWebView()));
60   EventLoopWait(1);
61 }