2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Igalia S.L.
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"
31 #include <wtf/Platform.h>
32 #include <wtf/gobject/GUniquePtr.h>
33 #include <wtf/text/WTFString.h>
37 static guint gTimeoutSourceId = 0;
39 static void cancelTimeout()
41 if (!gTimeoutSourceId)
43 g_source_remove(gTimeoutSourceId);
47 void TestController::notifyDone()
53 void TestController::platformInitialize()
57 void TestController::platformDestroy()
61 static gboolean timeoutCallback(gpointer)
63 fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
68 void TestController::platformWillRunTest(const TestInvocation&)
72 void TestController::platformRunUntil(bool&, double timeout)
75 if (timeout != m_noTimeout) {
76 gTimeoutSourceId = g_timeout_add(timeout * 1000, timeoutCallback, 0);
77 g_source_set_name_by_id(gTimeoutSourceId, "[WebKit] timeoutCallback");
82 static char* getEnvironmentVariableAsUTF8String(const char* variableName)
84 const char* value = g_getenv(variableName);
86 fprintf(stderr, "%s environment variable not found\n", variableName);
90 return g_filename_to_utf8(value, -1, 0, &bytesWritten, 0);
93 void TestController::initializeInjectedBundlePath()
95 GUniquePtr<char> utf8BundlePath(getEnvironmentVariableAsUTF8String("TEST_RUNNER_INJECTED_BUNDLE_FILENAME"));
96 m_injectedBundlePath.adopt(WKStringCreateWithUTF8CString(utf8BundlePath.get()));
99 void TestController::initializeTestPluginDirectory()
101 GUniquePtr<char> testPluginPath(getEnvironmentVariableAsUTF8String("TEST_RUNNER_TEST_PLUGIN_PATH"));
102 m_testPluginDirectory.adopt(WKStringCreateWithUTF8CString(testPluginPath.get()));
105 void TestController::platformInitializeContext()
109 void TestController::setHidden(bool)
111 // FIXME: Need to implement this to test visibilityState.
114 void TestController::runModal(PlatformWebView*)
116 // FIXME: Need to implement this to test showModalDialog.
119 const char* TestController::platformLibraryPathForTesting()