2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 University of Szeged. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "TestController.h"
30 #include "WKStringQt.h"
33 #include <QCoreApplication>
39 #include <wtf/Platform.h>
40 #include <wtf/text/WTFString.h>
44 class TestControllerRunLoop : public QObject {
47 static TestControllerRunLoop* instance()
49 static TestControllerRunLoop* result = new TestControllerRunLoop;
55 m_timerID = startTimer(msec);
57 m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
66 TestControllerRunLoop() {}
68 void timerEvent(QTimerEvent*)
70 fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
74 QEventLoop m_eventLoop;
78 void TestController::notifyDone()
80 TestControllerRunLoop::instance()->stop();
83 void TestController::platformInitialize()
87 void TestController::platformRunUntil(bool&, double timeout)
89 TestControllerRunLoop::instance()->start(static_cast<int>(timeout * 1000));
92 static bool isExistingLibrary(const QString& path)
94 #if OS(WINDOWS) || OS(SYMBIAN)
95 const char* librarySuffixes[] = { ".dll" };
97 const char* librarySuffixes[] = { ".bundle", ".dylib", ".so" };
99 const char* librarySuffixes[] = { ".so" };
101 #error Library path suffix should be specified for this platform
103 for (unsigned i = 0; i < sizeof(librarySuffixes) / sizeof(const char*); ++i) {
104 if (QLibrary::isLibrary(path + librarySuffixes[i]))
111 void TestController::initializeInjectedBundlePath()
113 QString path = QLatin1String(getenv("WTR_INJECTEDBUNDLE_PATH"));
115 path = QFileInfo(QCoreApplication::applicationDirPath() + "/../lib/libWTRInjectedBundle").absoluteFilePath();
116 if (!isExistingLibrary(path))
117 qFatal("Cannot find the injected bundle at %s\n", qPrintable(path));
119 m_injectedBundlePath = WKStringCreateWithQString(path);
122 void TestController::initializeTestPluginDirectory()
124 m_testPluginDirectory = WKStringCreateWithUTF8CString(qgetenv("QTWEBKIT_PLUGIN_PATH").constData());
127 void TestController::platformInitializeContext()
131 void TestController::runModal(PlatformWebView*)
133 // FIXME: Need to implement this to test showModalDialog.
136 const char* TestController::platformLibraryPathForTesting()
141 #include "TestControllerQt.moc"