1 // Copyright 2015 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 // See README.md how to run this test in DESKTOP mode.
7 #include "utc_blink_ewk_base.h"
9 class utc_blink_ewk_context_new_with_injected_bundle_path_func
10 : public utc_blink_ewk_base {
12 utc_blink_ewk_context_new_with_injected_bundle_path_func()
13 : timer(NULL), webview(NULL) {}
17 static const std::string injectedBundlePath;
19 static void getPlainText(Evas_Object* webview,
20 const char* plainText,
23 utc_blink_ewk_context_new_with_injected_bundle_path_func* owner =
24 static_cast<utc_blink_ewk_context_new_with_injected_bundle_path_func*>(
26 owner->EventLoopStop(Success);
27 ASSERT_TRUE(plainText);
29 ASSERT_STREQ("DynamicPluginStartSession", plainText);
31 static Eina_Bool timerCallback(void* data) {
32 utc_blink_ewk_context_new_with_injected_bundle_path_func* owner =
33 static_cast<utc_blink_ewk_context_new_with_injected_bundle_path_func*>(
35 ewk_view_plain_text_get(owner->webview, getPlainText, owner);
36 return ECORE_CALLBACK_CANCEL;
38 void runWithTimer() { timer = ecore_timer_add(1, timerCallback, this); }
40 Evas_Object* CreateWindow() {
41 Evas_Object* window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
42 return ewk_view_add_with_context(
43 evas_object_evas_get(window),
44 ewk_context_new_with_injected_bundle_path(
45 GetResourcePath(injectedBundlePath.c_str()).c_str()));
49 const std::string utc_blink_ewk_context_new_with_injected_bundle_path_func::
51 "ewk_context/injected_bundle/chromium/libbundle_sample.so";
54 * @brief Checking whether context with injected bundle path is returned
56 TEST_F(utc_blink_ewk_context_new_with_injected_bundle_path_func, POS_TEST) {
57 ASSERT_TRUE(ewk_context_new_with_injected_bundle_path(
58 GetResourcePath(injectedBundlePath.c_str()).c_str()));
61 TEST_F(utc_blink_ewk_context_new_with_injected_bundle_path_func, POS_TEST1) {
62 webview = CreateWindow();
63 const char simpleHTML[] =
64 "<html><body><script>document.write(\"\");</script></body></html>";
65 ewk_context_tizen_app_id_set(ewk_view_context_get(webview), "1");
66 ASSERT_TRUE(ewk_view_html_string_load(webview, simpleHTML, NULL, NULL));
68 ASSERT_EQ(Success, EventLoopStart());
71 TEST_F(utc_blink_ewk_context_new_with_injected_bundle_path_func, NEG_TEST) {
72 Ewk_Context* context = ewk_context_new_with_injected_bundle_path(0);
73 ASSERT_TRUE(!context);