1 // Copyright 2016 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 #include "utc_blink_ewk_base.h"
7 class utc_blink_ewk_view_bg_color_get : public utc_blink_ewk_base {
9 utc_blink_ewk_view_bg_color_get()
10 : utc_blink_ewk_base(),
14 bgcolor_a_value_(2) {}
16 void LoadFinished(Evas_Object* webview) override { EventLoopStop(Success); }
18 static void BackgroundColorGetCallback(Evas_Object* o,
24 ASSERT_TRUE(user_data != NULL);
26 utc_blink_ewk_view_bg_color_get* const owner =
27 static_cast<utc_blink_ewk_view_bg_color_get*>(user_data);
30 owner->bgcolor_r_value_ == r && owner->bgcolor_g_value_ == g &&
31 owner->bgcolor_b_value_ == b && owner->bgcolor_a_value_ == a
36 static Eina_Bool GetBackgroundColorOnTimer(void* user_data) {
38 utc_blink_ewk_view_bg_color_get* const owner =
39 static_cast<utc_blink_ewk_view_bg_color_get*>(user_data);
41 if (!ewk_view_bg_color_get(owner->GetEwkWebView(),
42 BackgroundColorGetCallback, owner)) {
43 owner->EventLoopStop(Failure);
46 return ECORE_CALLBACK_CANCEL;
50 unsigned int bgcolor_r_value_;
51 unsigned int bgcolor_g_value_;
52 unsigned int bgcolor_b_value_;
53 unsigned int bgcolor_a_value_;
57 * @brief Tests if setting and getting the background color is fetched
58 * from webkit properly.
60 TEST_F(utc_blink_ewk_view_bg_color_get, POS_TEST) {
61 ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(),
62 GetResourceUrl("/common/sample.html").c_str()));
64 ASSERT_EQ(EventLoopStart(), Success);
66 ewk_view_bg_color_set(GetEwkWebView(), bgcolor_r_value_, bgcolor_g_value_,
67 bgcolor_b_value_, bgcolor_a_value_);
69 ASSERT_TRUE(ecore_timer_add(1, GetBackgroundColorOnTimer, this) != NULL);
71 ASSERT_EQ(EventLoopStart(), Success);
75 * @brief Tests if getter returns false when callback function is NULL
78 TEST_F(utc_blink_ewk_view_bg_color_get, NEG_TEST) {
79 EXPECT_FALSE(ewk_view_bg_color_get(NULL, BackgroundColorGetCallback, this));
80 EXPECT_FALSE(ewk_view_bg_color_get(GetEwkWebView(), NULL, this));