diff options
Diffstat (limited to 'WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp')
-rw-r--r-- | WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp index 9bec373..f650d7f 100644 --- a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp +++ b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp @@ -27,14 +27,67 @@ #include <fcntl.h> #include <io.h> +#include <shlwapi.h> +#include <string> #include <WebKit2/WKStringCF.h> +#include <wtf/RetainPtr.h> +#include <wtf/Vector.h> + +using namespace std; namespace WTR { +#if !defined(NDEBUG) && (!defined(DEBUG_INTERNAL) || defined(DEBUG_ALL)) +const LPWSTR testPluginDirectoryName = L"TestNetscapePlugin_Debug"; +#else +const LPWSTR testPluginDirectoryName = L"TestNetscapePlugin"; +#endif + +static void addQTDirToPATH() +{ + static LPCWSTR pathEnvironmentVariable = L"PATH"; + static LPCWSTR quickTimeKeyName = L"Software\\Apple Computer, Inc.\\QuickTime"; + static LPCWSTR quickTimeSysDir = L"QTSysDir"; + static bool initialized; + + if (initialized) + return; + initialized = true; + + // Get the QuickTime dll directory from the registry. The key can be in either HKLM or HKCU. + WCHAR qtPath[MAX_PATH]; + DWORD qtPathBufferLen = sizeof(qtPath); + DWORD keyType; + HRESULT result = ::SHGetValueW(HKEY_LOCAL_MACHINE, quickTimeKeyName, quickTimeSysDir, &keyType, (LPVOID)qtPath, &qtPathBufferLen); + if (result != ERROR_SUCCESS || !qtPathBufferLen || keyType != REG_SZ) { + qtPathBufferLen = sizeof(qtPath); + result = ::SHGetValueW(HKEY_CURRENT_USER, quickTimeKeyName, quickTimeSysDir, &keyType, (LPVOID)qtPath, &qtPathBufferLen); + if (result != ERROR_SUCCESS || !qtPathBufferLen || keyType != REG_SZ) + return; + } + + // Read the current PATH. + DWORD pathSize = ::GetEnvironmentVariableW(pathEnvironmentVariable, 0, 0); + Vector<WCHAR> oldPath(pathSize); + if (!::GetEnvironmentVariableW(pathEnvironmentVariable, oldPath.data(), oldPath.size())) + return; + + // And add the QuickTime dll. + wstring newPath; + newPath.append(qtPath); + newPath.append(L";"); + newPath.append(oldPath.data(), oldPath.size()); + ::SetEnvironmentVariableW(pathEnvironmentVariable, newPath.data()); +} + void TestController::platformInitialize() { _setmode(1, _O_BINARY); _setmode(2, _O_BINARY); + + // Add the QuickTime dll directory to PATH or QT 7.6 will fail to initialize on systems + // linked with older versions of qtmlclientlib.dll. + addQTDirToPATH(); } void TestController::initializeInjectedBundlePath() @@ -52,9 +105,12 @@ void TestController::initializeInjectedBundlePath() void TestController::initializeTestPluginDirectory() { - CFStringRef exeContainerPath = CFURLCopyFileSystemPath(CFURLCreateCopyDeletingLastPathComponent(0, CFBundleCopyExecutableURL(CFBundleGetMainBundle())), kCFURLWindowsPathStyle); - CFMutableStringRef bundlePath = CFStringCreateMutableCopy(0, 0, exeContainerPath); - m_testPluginDirectory.adopt(WKStringCreateWithCFString(bundlePath)); + RetainPtr<CFURLRef> bundleURL(AdoptCF, CFBundleCopyExecutableURL(CFBundleGetMainBundle())); + RetainPtr<CFURLRef> bundleDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, bundleURL.get())); + RetainPtr<CFStringRef> testPluginDirectoryNameString(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(testPluginDirectoryName), wcslen(testPluginDirectoryName))); + RetainPtr<CFURLRef> testPluginDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, bundleDirectoryURL.get(), testPluginDirectoryNameString.get(), true)); + RetainPtr<CFStringRef> testPluginDirectoryPath(AdoptCF, CFURLCopyFileSystemPath(testPluginDirectoryURL.get(), kCFURLWindowsPathStyle)); + m_testPluginDirectory.adopt(WKStringCreateWithCFString(testPluginDirectoryPath.get())); } } // namespace WTR |