0

port some parts of webkit/glue/plugins/test to Linux

these are not all parts (about a half), but still something

BUG=1949

Patch from Paweł Hajdan jr <phajdan.jr@gmail.com>.


git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2534 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
evanm@google.com
2008-09-24 00:11:25 +00:00
parent f9d44aa6e5
commit e614262b18
11 changed files with 123 additions and 77 deletions

@ -23,6 +23,11 @@ namespace base {
// are listed below. These functions are then implemented as inline calls
// to the platform-specific equivalents in the platform-specific headers.
// Compare the two strings s1 and s2 without regard to case using
// the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if
// s2 > s1 according to a lexicographic comparison.
int strcasecmp(const char* s1, const char* s2);
// Compare up to count characters of s1 and s2 without regard to case using
// the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if
// s2 > s1 according to a lexicographic comparison.

@ -14,6 +14,10 @@
namespace base {
inline int strcasecmp(const char* string1, const char* string2) {
return ::strcasecmp(string1, string2);
}
inline int strncasecmp(const char* string1, const char* string2, size_t count) {
return ::strncasecmp(string1, string2, count);
}

@ -14,6 +14,10 @@
namespace base {
inline int strcasecmp(const char* s1, const char* s2) {
return _stricmp(s1, s2);
}
inline int strncasecmp(const char* s1, const char* s2, size_t count) {
return _strnicmp(s1, s2, count);
}

@ -153,6 +153,7 @@ sconscript_dirs = [
'build/V8Bindings/SConscript',
'default_plugin/SConscript',
'glue/SConscript',
'glue/plugins/test/SConscript',
]
if env['PLATFORM'] == 'win32':
# These extra dirs aren't win32-specific, they're just the dirs that
@ -164,7 +165,6 @@ if env['PLATFORM'] == 'win32':
'build/WebCore/SConscript', # This almost works on linux. It requires
# some changes to WebKit that we'll get
# in the merge.
'glue/plugins/test/SConscript',
'tools/npapi_layout_test_plugin/SConscript',
'tools/test_shell/SConscript',
'tools/test_shell/resources/fonts/SConscript',

@ -10,62 +10,74 @@ env_res = env_res.Clone()
input_files = [
'npapi_constants.cc',
'npapi_test.cc',
env_res.RES('npapi_test.rc'),
'plugin_arguments_test.cc',
'plugin_client.cc',
'plugin_delete_plugin_in_stream_test.cc',
'plugin_execute_script_delete_test.cc',
'plugin_get_javascript_url_test.cc',
'plugin_geturl_test.cc',
'plugin_new_fails_test.cc',
'plugin_npobject_lifetime_test.cc',
'plugin_npobject_proxy_test.cc',
'plugin_test.cc',
'plugin_window_size_test.cc',
'npapi_test.def',
'plugin_test.cc'
]
if env['PLATFORM'] == 'win32':
# TODO(port): Port these.
input_files.extend([
'plugin_arguments_test.cc',
'plugin_execute_script_delete_test.cc',
'plugin_geturl_test.cc',
'plugin_client.cc', # Includes not ported headers.
'plugin_npobject_lifetime_test.cc', # Has win32-isms (HWND, CALLBACK).
'plugin_window_size_test.cc' # Has w32-isms including HWND.
])
env.Append(
LIBS = [
'base',
],
)
env.Append(
CCFLAGS = [
'/TP',
'/wd4800',
],
if env['PLATFORM'] == 'win32':
input_files.extend([
env_res.RES('npapi_test.rc'),
'npapi_test.def'
])
LIBS = [
'comctl32.lib',
'rpcrt4.lib',
'shlwapi.lib',
'winmm.lib',
],
env.Append(
CCFLAGS = [
'/TP',
'/wd4800',
],
LINKFLAGS = [
'/INCREMENTAL',
'/DELAYLOAD:"dwmapi.dll"',
'/DELAYLOAD:"uxtheme.dll"',
'/FIXED:No',
'/SUBSYSTEM:CONSOLE',
'/MACHINE:X86',
'/safeseh',
'/dynamicbase',
'/ignore:4199',
'/nxcompat',
],
)
LIBS = [
'comctl32.lib',
'rpcrt4.lib',
'shlwapi.lib',
'winmm.lib',
],
dll = env.ChromeSharedLibrary(['npapi_test_plugin',
'npapi_test_plugin.lib',
'npapi_test_plugin.ilk',
'npapi_test_plugin.pdb'],
input_files)
LINKFLAGS = [
'/INCREMENTAL',
'/DELAYLOAD:"dwmapi.dll"',
'/DELAYLOAD:"uxtheme.dll"',
'/FIXED:No',
'/SUBSYSTEM:CONSOLE',
'/MACHINE:X86',
'/safeseh',
'/dynamicbase',
'/ignore:4199',
'/nxcompat',
],
)
# TODO(sgk): goes away once ChromeSharedLibrary does this for us.
env.Install('$LIBS_DIR', dll[1])
dll = env.ChromeSharedLibrary([
'npapi_test_plugin',
'npapi_test_plugin.lib',
'npapi_test_plugin.ilk',
'npapi_test_plugin.pdb'
], input_files)
# TODO(sgk): goes away once ChromeSharedLibrary does this for us.
env.Install('$LIBS_DIR', dll[1])
else:
dll = env.ChromeSharedLibrary(['npapi_test_plugin'], input_files)
i = env.Install('$TARGET_ROOT', dll)
env.Alias('webkit', i)

@ -41,23 +41,30 @@
//
//
#include "base/basictypes.h"
#if defined(OS_WIN)
#include <windows.h>
#endif
#include "webkit/glue/plugins/test/plugin_client.h"
BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) {
#if defined(OS_WIN)
BOOL API_CALL DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) {
return TRUE;
}
#endif
extern "C" {
NPError WINAPI NP_GetEntryPoints(NPPluginFuncs* pFuncs) {
NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* pFuncs) {
return NPAPIClient::PluginClient::GetEntryPoints(pFuncs);
}
NPError WINAPI NP_Initialize(NPNetscapeFuncs* pFuncs) {
NPError API_CALL NP_Initialize(NPNetscapeFuncs* pFuncs) {
return NPAPIClient::PluginClient::Initialize(pFuncs);
}
NPError WINAPI NP_Shutdown() {
NPError API_CALL NP_Shutdown() {
return NPAPIClient::PluginClient::Shutdown();
}
} // extern "C"

@ -2,8 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/basictypes.h"
#if defined(OS_WIN)
#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
#endif
#include "webkit/glue/plugins/test/plugin_arguments_test.h"
namespace NPAPIClient {

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/string_util.h"
#include "webkit/glue/plugins/test/plugin_client.h"
#include "webkit/glue/plugins/test/plugin_arguments_test.h"
#include "webkit/glue/plugins/test/plugin_delete_plugin_in_stream_test.h"
@ -40,7 +41,7 @@ NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) {
pFuncs->urlnotify = NPP_URLNotify;
pFuncs->getvalue = NPP_GetValue;
pFuncs->setvalue = NPP_SetValue;
pFuncs->javaClass = NPP_GetJavaClass;
pFuncs->javaClass = static_cast<JRIGlobalRef>(NPP_GetJavaClass);
return NPERR_NO_ERROR;
}
@ -50,7 +51,8 @@ NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) {
return NPERR_INVALID_FUNCTABLE_ERROR;
}
if (HIBYTE(pFuncs->version) > NP_VERSION_MAJOR) {
if (static_cast<unsigned char>((pFuncs->version >> 8) & 0xff) >
NP_VERSION_MAJOR) {
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
@ -77,7 +79,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
// lookup the name parameter
int name_index = 0;
for (name_index = 0; name_index < argc; name_index++)
if (_stricmp(argn[name_index], "name") == 0)
if (base::strcasecmp(argn[name_index], "name") == 0)
break;
if (name_index >= argc)
@ -87,40 +89,43 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
bool windowless_plugin = false;
NPAPIClient::PluginTest *new_test = NULL;
if (_stricmp(argv[name_index], "arguments") == 0) {
if (base::strcasecmp(argv[name_index], "arguments") == 0) {
new_test = new NPAPIClient::PluginArgumentsTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "geturl") == 0) {
} else if (base::strcasecmp(argv[name_index], "geturl") == 0) {
new_test = new NPAPIClient::PluginGetURLTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "npobject_proxy") == 0) {
} else if (base::strcasecmp(argv[name_index], "npobject_proxy") == 0) {
new_test = new NPAPIClient::NPObjectProxyTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "execute_script_delete_in_paint") == 0) {
} else if (base::strcasecmp(argv[name_index],
"execute_script_delete_in_paint") == 0) {
new_test = new NPAPIClient::ExecuteScriptDeleteTest(instance,
NPAPIClient::PluginClient::HostFunctions());
windowless_plugin = true;
} else if (_stricmp(argv[name_index], "getjavascripturl") == 0) {
} else if (base::strcasecmp(argv[name_index], "getjavascripturl") == 0) {
new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "checkwindowrect") == 0) {
} else if (base::strcasecmp(argv[name_index], "checkwindowrect") == 0) {
new_test = new NPAPIClient::PluginWindowSizeTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "self_delete_plugin_stream") == 0) {
} else if (base::strcasecmp(argv[name_index],
"self_delete_plugin_stream") == 0) {
new_test = new NPAPIClient::DeletePluginInStreamTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "npobject_lifetime_test") == 0) {
} else if (base::strcasecmp(argv[name_index],
"npobject_lifetime_test") == 0) {
new_test = new NPAPIClient::NPObjectLifetimeTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index],
"npobject_lifetime_test_second_instance") == 0) {
} else if (base::strcasecmp(argv[name_index],
"npobject_lifetime_test_second_instance") == 0) {
new_test = new NPAPIClient::NPObjectLifetimeTestInstance2(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index], "new_fails") == 0) {
} else if (base::strcasecmp(argv[name_index], "new_fails") == 0) {
new_test = new NPAPIClient::NewFailsTest(instance,
NPAPIClient::PluginClient::HostFunctions());
} else if (_stricmp(argv[name_index],
"npobject_delete_plugin_in_evaluate") == 0) {
} else if (base::strcasecmp(argv[name_index],
"npobject_delete_plugin_in_evaluate") == 0) {
new_test = new NPAPIClient::NPObjectDeletePluginInNPN_Evaluate(instance,
NPAPIClient::PluginClient::HostFunctions());
} else {
@ -270,7 +275,3 @@ void* NPP_GetJavaClass(void) {
}
} // extern "C"

@ -4,6 +4,7 @@
#include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h"
#include "base/basictypes.h"
// url for "self".
#define SELF_URL "javascript:window.location+\"\""
@ -38,7 +39,9 @@ NPError ExecuteGetJavascriptUrlTest::NewStream(NPMIMEType type, NPStream* stream
if (stream == NULL)
SetError("NewStream got null stream");
unsigned long stream_id = PtrToUlong(stream->notifyData);
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
switch (stream_id) {
case SELF_URL_STREAM_ID:
break;
@ -60,7 +63,9 @@ int32 ExecuteGetJavascriptUrlTest::Write(NPStream *stream, int32 offset, int32 l
if (len < 0 || len > STREAM_CHUNK)
SetError("Write got bogus stream chunk size");
unsigned long stream_id = PtrToUlong(stream->notifyData);
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
switch (stream_id) {
case SELF_URL_STREAM_ID:
self_url_.append(static_cast<char*>(buffer), len);
@ -78,7 +83,9 @@ NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, NPError rea
if (stream == NULL)
SetError("NewStream got null stream");
unsigned long stream_id = PtrToUlong(stream->notifyData);
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
switch (stream_id) {
case SELF_URL_STREAM_ID:
// don't care
@ -91,7 +98,9 @@ NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, NPError rea
}
void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, void* data) {
unsigned long stream_id = PtrToUlong(data);
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(data),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(data);
switch (stream_id) {
case SELF_URL_STREAM_ID:
if (strcmp(url, SELF_URL) != 0)

@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "webkit/glue/plugins/test/plugin_test.h"
#include "base/string_util.h"
#include "webkit/glue/plugins/test/npapi_constants.h"
namespace NPAPIClient {
@ -32,8 +34,8 @@ NPError PluginTest::SetWindow(NPWindow* pNPWindow) {
// end up using libicu, which is a string of dependencies we don't
// want.
inline BYTE toHex(const BYTE &x) {
return x > 9 ? x + 55: x + 48;
inline unsigned char toHex(const unsigned char x) {
return x > 9 ? (x + 'A' - 10) : (x + '0');
}
std::string URLEncode(const std::string &sIn) {
@ -88,7 +90,7 @@ void PluginTest::SignalTestCompleted() {
const char *PluginTest::GetArgValue(const char *name, const int16 argc,
const char *argn[], const char *argv[]) {
for (int idx = 0; idx < argc; idx++)
if (_stricmp(argn[idx], name) == 0)
if (base::strcasecmp(argn[idx], name) == 0)
return argv[idx];
return NULL;
}

@ -77,13 +77,10 @@ class PluginTest {
void ExpectIntegerEqual(int val1, int val2) {
if (val1 != val2) {
std::string err;
char buf[64]; // what's the right size?
err = "Expected Equal for '";
sprintf_s(buf, "%d", val1);
err.append(buf);
err.append(IntToString(val1));
err.append("' and '");
sprintf_s(buf, "%d", val2);
err.append(buf);
err.append(IntToString(val2));
err.append("'");
SetError(err);
}