Title: [128610] trunk/Source/WebKit2
Revision
128610
Author
kenn...@webkit.org
Date
2012-09-14 07:30:58 -0700 (Fri, 14 Sep 2012)

Log Message

[EFL] Add unit test for RefPtr<Evas_Object>
https://bugs.webkit.org/show_bug.cgi?id=96776

Reviewed by Simon Hausmann.

Basic testing of the new EFL specific RefPtr type.

* PlatformEfl.cmake:
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
(EWK2UnitTest::EWK2UnitTestBase::backingStore):
(EWK2UnitTest::EWK2UnitTestBase::canvas):

    Add some new accessors for Ecore_Evas and Evas*.

* UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp: Added.
(TEST_F):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (128609 => 128610)


--- trunk/Source/WebKit2/ChangeLog	2012-09-14 14:08:27 UTC (rev 128609)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-14 14:30:58 UTC (rev 128610)
@@ -1,3 +1,22 @@
+2012-09-14  Kenneth Rohde Christiansen  <kenn...@webkit.org>
+
+        [EFL] Add unit test for RefPtr<Evas_Object>
+        https://bugs.webkit.org/show_bug.cgi?id=96776
+
+        Reviewed by Simon Hausmann.
+
+        Basic testing of the new EFL specific RefPtr type.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
+        (EWK2UnitTest::EWK2UnitTestBase::backingStore):
+        (EWK2UnitTest::EWK2UnitTestBase::canvas):
+
+            Add some new accessors for Ecore_Evas and Evas*.
+
+        * UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp: Added.
+        (TEST_F):
+
 2012-09-14  Tor Arne Vestbø  <tor.arne.ves...@nokia.com>
 
         [Qt] Move .mm file to OBJECTIVE_SOURCES

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (128609 => 128610)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-09-14 14:08:27 UTC (rev 128609)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-09-14 14:30:58 UTC (rev 128610)
@@ -286,6 +286,7 @@
     test_ewk2_cookie_manager
     test_ewk2_download_job
     test_ewk2_eina_shared_string
+    test_ewk2_refptr_evas_object
     test_ewk2_intents
     test_ewk2_settings
     test_ewk2_view

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h (128609 => 128610)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h	2012-09-14 14:08:27 UTC (rev 128609)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h	2012-09-14 14:30:58 UTC (rev 128610)
@@ -29,6 +29,8 @@
 
 class EWK2UnitTestBase : public ::testing::Test {
 public:
+    Ecore_Evas* backingStore() { return m_ecoreEvas; }
+    Evas* canvas() { ecore_evas_get(m_ecoreEvas); }
     Evas_Object* webView() { return m_webView; }
     Ewk_View_Smart_Class* ewkViewClass() { return &m_ewkViewClass; }
 

Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp (0 => 128610)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp	2012-09-14 14:30:58 UTC (rev 128610)
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "UnitTestUtils/EWK2UnitTestBase.h"
+#include "UnitTestUtils/EWK2UnitTestEnvironment.h"
+#include <EWebKit2.h>
+#include <Ecore_Evas.h>
+#include <Evas.h>
+#include <gtest/gtest.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/efl/RefPtrEfl.h>
+
+using namespace EWK2UnitTest;
+
+extern EWK2UnitTestEnvironment* environment;
+
+TEST_F(EWK2UnitTestBase, construction)
+{
+    RefPtr<Evas_Object> nullObject = 0;
+    ASSERT_FALSE(nullObject);
+
+    RefPtr<Evas_Object> object;
+    ASSERT_FALSE(object);
+
+    object = adoptRef(evas_object_box_add(canvas()));
+    ASSERT_TRUE(object);
+
+    object = 0;
+    ASSERT_FALSE(object);
+
+    object = adoptRef(evas_object_box_add(canvas()));
+    ASSERT_TRUE(object);
+
+    object.clear();
+    ASSERT_FALSE(object);
+}
+
+TEST_F(EWK2UnitTestBase, reffing)
+{
+    RefPtr<Evas_Object> object = adoptRef(evas_object_box_add(canvas()));
+    ASSERT_TRUE(object);
+    // Evas_Objec external ref count is not as you would expect.
+    ASSERT_EQ(evas_object_ref_get(object.get()), 0);
+
+    {
+        RefPtr<Evas_Object> aRef = object;
+        ASSERT_TRUE(object);
+        ASSERT_TRUE(aRef);
+        ASSERT_EQ(evas_object_ref_get(object.get()), 1);
+        ASSERT_EQ(evas_object_ref_get(aRef.get()), 1);
+
+        {
+            RefPtr<Evas_Object> bRef = object;
+
+            ASSERT_TRUE(object);
+            ASSERT_TRUE(aRef);
+            ASSERT_TRUE(bRef);
+
+            ASSERT_EQ(evas_object_ref_get(object.get()), 2);
+            ASSERT_EQ(evas_object_ref_get(aRef.get()), 2);
+
+            RefPtr<Evas_Object> cRef = bRef;
+            ASSERT_TRUE(cRef);
+
+            ASSERT_EQ(evas_object_ref_get(object.get()), 3);
+            ASSERT_EQ(evas_object_ref_get(aRef.get()), 3);
+            ASSERT_EQ(evas_object_ref_get(bRef.get()), 3);
+            ASSERT_EQ(evas_object_ref_get(cRef.get()), 3);
+
+            bRef.clear();
+            ASSERT_EQ(evas_object_ref_get(object.get()), 2);
+            ASSERT_EQ(evas_object_ref_get(aRef.get()), 2);
+            ASSERT_EQ(evas_object_ref_get(cRef.get()), 2);
+        }
+        ASSERT_EQ(evas_object_ref_get(object.get()), 1);
+        ASSERT_EQ(evas_object_ref_get(aRef.get()), 1);
+    }
+    ASSERT_EQ(evas_object_ref_get(object.get()), 0);
+}
+
+TEST_F(EWK2UnitTestBase, destruction)
+{
+    RefPtr<Evas_Object> object = adoptRef(evas_object_box_add(canvas()));
+    ASSERT_TRUE(object);
+    ASSERT_EQ(evas_object_ref_get(object.get()), 0);
+
+    RefPtr<Evas_Object> aRef = object;
+    ASSERT_TRUE(object);
+    ASSERT_TRUE(aRef);
+    ASSERT_EQ(evas_object_ref_get(object.get()), 1);
+    ASSERT_EQ(evas_object_ref_get(aRef.get()), 1);
+
+    object = nullptr;
+    ASSERT_EQ(evas_object_ref_get(object.get()), 0);
+    ASSERT_EQ(evas_object_ref_get(aRef.get()), 0);
+
+    object = aRef;
+    ASSERT_EQ(evas_object_ref_get(object.get()), 1);
+    ASSERT_EQ(evas_object_ref_get(aRef.get()), 1);
+
+    object = 0;
+    ASSERT_EQ(evas_object_ref_get(object.get()), 0);
+    ASSERT_EQ(evas_object_ref_get(aRef.get()), 0);
+
+    aRef.clear();
+    ASSERT_FALSE(aRef);
+    ASSERT_FALSE(object);
+}
+
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to