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.
5 #if BUILDFLAG(IS_TIZEN)
6 #include "ecore_x_wayland_wrapper.h"
7 // using scim to simulate keyboard typing
9 #include <scim_event.h>
10 #include <scim_attribute.h>
11 #include <scim_lookup_table.h>
12 #include <scim_socket.h>
13 #include <scim_property.h>
14 #include <scim_transaction.h>
15 #include <scim_helper.h>
16 #include <scim_helper_manager.h>
19 #include "utc_blink_ewk_base.h"
22 #undef Success // conflicts with utc_blink_ewk_base enum
24 class utc_blink_cb_editorclient_candidate_opened : public utc_blink_ewk_base
29 const char* default_context_id = ecore_imf_context_default_id_get();
30 ASSERT_TRUE(default_context_id) << "This TC can't be run without default imf context - it will fail anyway";
33 void LoadFinished(Evas_Object*)
35 EventLoopStop(utc_blink_ewk_base::Success);
38 static void editorclient_candidate_opened_cb(utc_blink_cb_editorclient_candidate_opened* owner, Evas_Object*, void*)
41 owner->EventLoopStop(utc_blink_ewk_base::Success);
46 * @brief Tests "editorclient,candidate,opened" callback
48 * We use Tizen ISF API to open candidate window on current input method panel
50 TEST_F(utc_blink_cb_editorclient_candidate_opened, callback)
52 char htmlBuffer[] = "<html>"
55 "<input id=\"e\" type=\"text\"><a id=\"b\" onclick=\"document.getElementById('e').focus();\">Button</a>"
60 ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
61 // This TC will timeout on desktop as there is no input method context
62 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart());
64 // We need to focus on window
65 elm_object_focus_set(GetEwkWebView(), EINA_TRUE);
67 // We scope this callback as it is only needed once
69 evas_object_smart_callback_auto ime(GetEwkWebView(), "editorclient,ime,opened", ToSmartCallback(editorclient_candidate_opened_cb), this);
70 // This script execute should produce user gesture and should show software keyboard on mobile
71 ASSERT_EQ(EINA_TRUE, ewk_view_script_execute(GetEwkWebView(), "document.getElementById('b').click();", NULL, NULL));
73 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart()) << "editorclient,ime,opened smart callback timeout";
76 #if BUILDFLAG(IS_TIZEN)
78 Display* display = static_cast<Display*>(ecore_x_display_get());
79 ASSERT_TRUE(display) << "No X11 display available!";
81 evas_object_smart_callback_auto candidate(GetEwkWebView(), "editorclient,candidate,opened", ToSmartCallback(editorclient_candidate_opened_cb), this);
83 scim::HelperAgent agent;
84 scim::HelperManager manager;
86 int count = manager.number_of_helpers();
88 scim::HelperInfo info;
90 for (int i = 0; i < count; ++i) {
91 if (manager.get_helper_info(i, info)) {
92 agent.open_connection(info, XDisplayString(display));
96 ASSERT_TRUE(agent.is_connected()) << "Could not connect to SCIM - can't send proper events to virtual keyboard";
98 scim::WideString content = scim::utf8_mbstowcs("a");
99 agent.commit_string(-1, scim::String(), content);
100 agent.show_candidate_string();
102 agent.close_connection();
104 // wait for candidate to show
105 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart()) << "editorclient,candidate,opened smart callback timeout";
108 ASSERT_TRUE(false) << "This TC won't work outside Tizen OS";