summaryrefslogtreecommitdiffstats
path: root/webkit/glue/cpp_variant_unittest.cc
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 04:42:57 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 04:42:57 +0000
commit870b2878217f1b48579b7e0baf1b2fc5e8e6d086 (patch)
tree58e68d023049740d4a116609115d62d4e176e8a3 /webkit/glue/cpp_variant_unittest.cc
parent99ddfd29900cc4caa1f1ffd979cc09be3f104336 (diff)
downloadchromium_src-870b2878217f1b48579b7e0baf1b2fc5e8e6d086.zip
chromium_src-870b2878217f1b48579b7e0baf1b2fc5e8e6d086.tar.gz
chromium_src-870b2878217f1b48579b7e0baf1b2fc5e8e6d086.tar.bz2
Remove all direct calls to NPN_ functions in WebCore. The replacement for these is the WebKit::WebBindings API.
This will be a 2 sided commit with https://bugs.webkit.org/show_bug.cgi?id=28089 TEST=none BUG=none Review URL: http://codereview.chromium.org/164214 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/cpp_variant_unittest.cc')
-rw-r--r--webkit/glue/cpp_variant_unittest.cc52
1 files changed, 26 insertions, 26 deletions
diff --git a/webkit/glue/cpp_variant_unittest.cc b/webkit/glue/cpp_variant_unittest.cc
index 46747a2..a2d9f3d 100644
--- a/webkit/glue/cpp_variant_unittest.cc
+++ b/webkit/glue/cpp_variant_unittest.cc
@@ -6,6 +6,7 @@
#include "base/compiler_specific.h"
+#include "webkit/api/public/WebBindings.h"
#include "webkit/glue/cpp_variant.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,9 +14,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "npruntime_priv.h" // for NPN_InitializeVariantWithStringCopy
MSVC_POP_WARNING();
-#if USE(JSC)
-#define _NPN_InitializeVariantWithStringCopy NPN_InitializeVariantWithStringCopy
-#endif
+using WebKit::WebBindings;
// Creates a std::string from an NPVariant of string type. If the NPVariant
// is not a string, empties the std::string.
@@ -60,7 +59,7 @@ void CheckObject(const NPVariant& actual) {
NPObject* MockNPAllocate(NPP npp, NPClass* aClass) {
// This is a mock allocate method that mimics the behavior
- // of NPN_CreateObject when allocate() is NULL
+ // of WebBindings::createObject when allocate() is NULL
++g_allocate_call_count;
// Ignore npp and NPClass
@@ -83,7 +82,7 @@ static NPClass void_class = { NP_CLASS_STRUCT_VERSION,
NPObject* MakeVoidObject() {
g_allocate_call_count = 0;
g_deallocate_call_count = 0;
- return NPN_CreateObject(NULL, &void_class);
+ return WebBindings::createObject(NULL, &void_class);
}
TEST(CppVariantTest, NewVariantHasNullType) {
@@ -122,7 +121,7 @@ TEST(CppVariantTest, CopyConstructorIncrementsRefCount) {
CppVariant dest = source;
EXPECT_EQ(3U, dest.value.objectValue->referenceCount);
EXPECT_EQ(1, g_allocate_call_count);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
source.SetNull();
CheckObject(dest);
}
@@ -154,7 +153,7 @@ TEST(CppVariantTest, AssignmentIncrementsRefCount) {
EXPECT_EQ(3U, dest.value.objectValue->referenceCount);
EXPECT_EQ(1, g_allocate_call_count);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
source.SetNull();
CheckObject(dest);
}
@@ -174,7 +173,7 @@ TEST(CppVariantTest, DestroyingCopyDoesNotCorruptSource) {
{
CppVariant dest2 = source;
}
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
CheckObject(source);
}
@@ -186,37 +185,37 @@ TEST(CppVariantTest, CopiesTypeAndValueToNPVariant) {
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
EXPECT_EQ(cpp.value.boolValue, np.value.boolValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.Set(17);
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
EXPECT_EQ(cpp.value.intValue, np.value.intValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.Set(3.1415);
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
EXPECT_EQ(cpp.value.doubleValue, np.value.doubleValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.Set("test value");
cpp.CopyToNPVariant(&np);
CheckString("test value", np);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
cpp.SetNull();
cpp.CopyToNPVariant(&np);
EXPECT_EQ(cpp.type, np.type);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NPObject *object = MakeVoidObject();
cpp.Set(object);
cpp.CopyToNPVariant(&np);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
cpp.SetNull();
CheckObject(np);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
}
TEST(CppVariantTest, SetsTypeAndValueFromNPVariant) {
@@ -226,37 +225,37 @@ TEST(CppVariantTest, SetsTypeAndValueFromNPVariant) {
VOID_TO_NPVARIANT(np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NULL_TO_NPVARIANT(np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
BOOLEAN_TO_NPVARIANT(true, np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
EXPECT_EQ(np.value.boolValue, cpp.value.boolValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
INT32_TO_NPVARIANT(15, np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
EXPECT_EQ(np.value.intValue, cpp.value.intValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
DOUBLE_TO_NPVARIANT(2.71828, np);
cpp.Set(np);
EXPECT_EQ(np.type, cpp.type);
EXPECT_EQ(np.value.doubleValue, cpp.value.doubleValue);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NPString np_ascii_str = { "1st test value",
static_cast<uint32_t>(strlen("1st test value")) };
_NPN_InitializeVariantWithStringCopy(&np, &np_ascii_str);
cpp.Set(np);
CheckString("1st test value", cpp);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
// Test characters represented in 2/3/4 bytes in UTF-8
// Greek alpha, Chinese number 1 (horizontal bar),
@@ -267,12 +266,13 @@ TEST(CppVariantTest, SetsTypeAndValueFromNPVariant) {
_NPN_InitializeVariantWithStringCopy(&np, &np_intl_str);
cpp.Set(np);
CheckString("\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84", cpp);
- NPN_ReleaseVariantValue(&np);
+ WebBindings::releaseVariantValue(&np);
NPObject *obj = MakeVoidObject();
OBJECT_TO_NPVARIANT(obj, np); // Doesn't make a copy.
cpp.Set(np);
- NPN_ReleaseVariantValue(&np); // or NPN_ReleaseObject but NOT both
+ // Use this or WebBindings::releaseObject but NOT both.
+ WebBindings::releaseVariantValue(&np);
CheckObject(cpp);
}
@@ -318,7 +318,7 @@ TEST(CppVariantTest, SetsSimpleTypesAndValues) {
NPObject* obj = MakeVoidObject();
cpp.Set(obj);
- NPN_ReleaseObject(obj);
+ WebBindings::releaseObject(obj);
CheckObject(cpp);
}
@@ -341,7 +341,7 @@ TEST(CppVariantTest, FreeDataReleasesObject) {
EXPECT_EQ(0, g_deallocate_call_count);
cpp.Set(object);
- NPN_ReleaseObject(object);
+ WebBindings::releaseObject(object);
EXPECT_EQ(0, g_deallocate_call_count);
cpp.FreeData();
EXPECT_EQ(1, g_deallocate_call_count);
@@ -428,6 +428,6 @@ TEST(CppVariantTest, IsTypeFunctionsWork) {
EXPECT_FALSE(cpp.isNull());
EXPECT_FALSE(cpp.isEmpty());
EXPECT_TRUE(cpp.isObject());
- NPN_ReleaseObject(obj);
+ WebBindings::releaseObject(obj);
CheckObject(cpp);
}