[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
weinig at apple.com
weinig at apple.com
Wed Dec 22 14:02:24 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 2ec0c438308498c1f10d6eb8e67253c03740665b
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Oct 1 19:07:40 2010 +0000
Add simple API tester for WebKit2
https://bugs.webkit.org/show_bug.cgi?id=46953
Reviewed by Adam Roben.
This adds a very simple testing infrastructure for testing APIs exposed
through the WebKit project. It consists of two parts: 1) a project that
builds the all the tests 2) a script that searches the tests directory and
calls the tester once for each test.
This adds the infrastructure and two tests:
- Tests/WTF/Vector1.cpp - A proof of concept test of WTF data-structures.
- Tests/WebKit2/BasicTest1.cpp - A proof of concept test of WebKit2 API.
This currently only works on the mac, but is designed to be easily ported
to any platform.
* Scripts/run-api-tests: Added.
* Scripts/build-api-tests: Added.
Scripts to build/run the tests.
* TestWebKitAPI: Added.
* TestWebKitAPI/Configurations: Added.
* TestWebKitAPI/Configurations/Base.xcconfig: Added.
* TestWebKitAPI/Configurations/DebugRelease.xcconfig: Added.
* TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig: Added.
* TestWebKitAPI/ForwardingHeaders: Added.
* TestWebKitAPI/ForwardingHeaders/wtf: Added.
* TestWebKitAPI/PlatformUtilities.h: Added.
* TestWebKitAPI/PlatformWebView.h: Added.
(TestWebKitAPI::PlatformWebView::platformView):
* TestWebKitAPI/StringFunctions.h: Added.
* TestWebKitAPI/Test.h: Added.
(TestWebKitAPI::Test::~Test):
(TestWebKitAPI::Test::name):
(TestWebKitAPI::Test::Register::Register):
(TestWebKitAPI::Test::Register::create):
(TestWebKitAPI::Test::Test):
* TestWebKitAPI/TestWebKitAPI.xcodeproj: Added.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added.
* TestWebKitAPI/TestWebKitAPIPrefix.h: Added.
* TestWebKitAPI/TestsController.cpp: Added.
(TestWebKitAPI::TestsController::shared):
(TestWebKitAPI::TestsController::TestsController):
(TestWebKitAPI::TestsController::runTestNamed):
(TestWebKitAPI::TestsController::testFailed):
(TestWebKitAPI::TestsController::registerCreateTestFunction):
* TestWebKitAPI/TestsController.h: Added.
* TestWebKitAPI/mac: Added.
* TestWebKitAPI/mac/PlatformUtilitiesMac.mm: Added.
(TestWebKitAPI::Util::run):
(TestWebKitAPI::Util::createURLForResource):
* TestWebKitAPI/mac/PlatformWebViewMac.mm: Added.
(TestWebKitAPI::PlatformWebView::PlatformWebView):
(TestWebKitAPI::PlatformWebView::resizeTo):
(TestWebKitAPI::PlatformWebView::~PlatformWebView):
(TestWebKitAPI::PlatformWebView::page):
(TestWebKitAPI::PlatformWebView::focus):
* TestWebKitAPI/mac/main.mm: Added.
Infrastructure.
* TestWebKitAPI/Tests: Added.
* TestWebKitAPI/Tests/WTF: Added.
* TestWebKitAPI/Tests/WTF/Vector1.cpp: Added.
* TestWebKitAPI/Tests/WebKit2: Added.
* TestWebKitAPI/Tests/WebKit2/BasicTest1.cpp: Added.
(TestWebKitAPI::State::State):
* TestWebKitAPI/Tests/WebKit2/basic-1.html: Added.
Proof of concept tests.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68910 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index d33bccd..62670dc 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,75 @@
+2010-10-01 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Adam Roben.
+
+ Add simple API tester for WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=46953
+
+ This adds a very simple testing infrastructure for testing APIs exposed
+ through the WebKit project. It consists of two parts: 1) a project that
+ builds the all the tests 2) a script that searches the tests directory and
+ calls the tester once for each test.
+
+ This adds the infrastructure and two tests:
+ - Tests/WTF/Vector1.cpp - A proof of concept test of WTF data-structures.
+ - Tests/WebKit2/BasicTest1.cpp - A proof of concept test of WebKit2 API.
+
+ This currently only works on the mac, but is designed to be easily ported
+ to any platform.
+
+ * Scripts/run-api-tests: Added.
+ * Scripts/build-api-tests: Added.
+ Scripts to build/run the tests.
+
+ * TestWebKitAPI: Added.
+ * TestWebKitAPI/Configurations: Added.
+ * TestWebKitAPI/Configurations/Base.xcconfig: Added.
+ * TestWebKitAPI/Configurations/DebugRelease.xcconfig: Added.
+ * TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig: Added.
+ * TestWebKitAPI/ForwardingHeaders: Added.
+ * TestWebKitAPI/ForwardingHeaders/wtf: Added.
+ * TestWebKitAPI/PlatformUtilities.h: Added.
+ * TestWebKitAPI/PlatformWebView.h: Added.
+ (TestWebKitAPI::PlatformWebView::platformView):
+ * TestWebKitAPI/StringFunctions.h: Added.
+ * TestWebKitAPI/Test.h: Added.
+ (TestWebKitAPI::Test::~Test):
+ (TestWebKitAPI::Test::name):
+ (TestWebKitAPI::Test::Register::Register):
+ (TestWebKitAPI::Test::Register::create):
+ (TestWebKitAPI::Test::Test):
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj: Added.
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added.
+ * TestWebKitAPI/TestWebKitAPIPrefix.h: Added.
+ * TestWebKitAPI/TestsController.cpp: Added.
+ (TestWebKitAPI::TestsController::shared):
+ (TestWebKitAPI::TestsController::TestsController):
+ (TestWebKitAPI::TestsController::runTestNamed):
+ (TestWebKitAPI::TestsController::testFailed):
+ (TestWebKitAPI::TestsController::registerCreateTestFunction):
+ * TestWebKitAPI/TestsController.h: Added.
+ * TestWebKitAPI/mac: Added.
+ * TestWebKitAPI/mac/PlatformUtilitiesMac.mm: Added.
+ (TestWebKitAPI::Util::run):
+ (TestWebKitAPI::Util::createURLForResource):
+ * TestWebKitAPI/mac/PlatformWebViewMac.mm: Added.
+ (TestWebKitAPI::PlatformWebView::PlatformWebView):
+ (TestWebKitAPI::PlatformWebView::resizeTo):
+ (TestWebKitAPI::PlatformWebView::~PlatformWebView):
+ (TestWebKitAPI::PlatformWebView::page):
+ (TestWebKitAPI::PlatformWebView::focus):
+ * TestWebKitAPI/mac/main.mm: Added.
+ Infrastructure.
+
+ * TestWebKitAPI/Tests: Added.
+ * TestWebKitAPI/Tests/WTF: Added.
+ * TestWebKitAPI/Tests/WTF/Vector1.cpp: Added.
+ * TestWebKitAPI/Tests/WebKit2: Added.
+ * TestWebKitAPI/Tests/WebKit2/BasicTest1.cpp: Added.
+ (TestWebKitAPI::State::State):
+ * TestWebKitAPI/Tests/WebKit2/basic-1.html: Added.
+ Proof of concept tests.
+
2010-10-01 Adam Roben <aroben at apple.com>
Don't assume AccessibleObjectFromEvent succeeds
diff --git a/WebKitTools/Scripts/build-api-tests b/WebKitTools/Scripts/build-api-tests
new file mode 100755
index 0000000..c02c17f
--- /dev/null
+++ b/WebKitTools/Scripts/build-api-tests
@@ -0,0 +1,68 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use File::Basename;
+use FindBin;
+use Getopt::Long qw(:config pass_through);
+use lib $FindBin::Bin;
+use webkitdirs;
+use POSIX;
+
+my $showHelp = 0;
+my $clean = 0;
+
+my $programName = basename($0);
+my $usage = <<EOF;
+Usage: $programName [options] [options to pass to build system]
+ --help Show this help message
+ --clean Clean up the build directory
+EOF
+
+GetOptions(
+ 'help' => \$showHelp,
+ 'clean' => \$clean,
+);
+
+if ($showHelp) {
+ print STDERR $usage;
+ exit 1;
+}
+
+checkRequiredSystemConfig();
+setConfiguration();
+chdirWebKit();
+
+# Build
+chdir "WebKitTools/TestWebKitAPI" or die;
+
+my $result;
+if (isAppleMacWebKit()) {
+ $result = buildXCodeProject("TestWebKitAPI", $clean, XcodeOptions(), @ARGV);
+} else {
+ die "TestWebKitAPI is not supported on this platform.\n";
+}
+
+exit exitStatus($result);
diff --git a/WebKitTools/Scripts/run-api-tests b/WebKitTools/Scripts/run-api-tests
new file mode 100755
index 0000000..a045631
--- /dev/null
+++ b/WebKitTools/Scripts/run-api-tests
@@ -0,0 +1,216 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+# Features to add:
+# - Ability to run a single test.
+# - Ability to run all tests under one directory.
+
+use strict;
+use warnings;
+
+use File::Basename;
+use File::Find;
+use File::Spec::Functions;
+use File::Spec;
+use FindBin;
+use Getopt::Long qw(:config pass_through);
+use IPC::Open3;
+use lib $FindBin::Bin;
+use webkitdirs;
+
+sub splitpath($);
+sub numericcmp($$);
+sub pathcmp($$);
+sub findTestsToRun();
+sub runTest($);
+sub buildTestTool();
+
+my $showHelp = 0;
+my $quiet = 0;
+
+my $programName = basename($0);
+my $usage = <<EOF;
+Usage: $programName [options]
+ --help Show this help message
+ -q|--quite Less verbose output
+EOF
+
+GetOptions(
+ 'help' => \$showHelp,
+ 'quiet|q' => \$quiet,
+);
+
+if ($showHelp) {
+ print STDERR $usage;
+ exit 1;
+}
+
+setConfiguration();
+buildTestTool();
+my @testsToRun = findTestsToRun();
+
+my $anyFailures = 0;
+for my $testPath (@testsToRun) {
+ my $failed = runTest($testPath);
+ if ($failed) {
+ $anyFailures = 1;
+ }
+}
+exit $anyFailures;
+
+
+sub splitpath($)
+{
+ my ($path) = @_;
+
+ my $pathSeparator = "/";
+ my $dirname = dirname($path) . $pathSeparator;
+ $dirname = "" if $dirname eq "." . $pathSeparator;
+
+ return ($dirname, basename($path));
+}
+
+sub numericcmp($$)
+{
+ my ($aa, $bb) = @_;
+
+ my @a = split /(\d+)/, $aa;
+ my @b = split /(\d+)/, $bb;
+
+ # Compare one chunk at a time.
+ # Each chunk is either all numeric digits, or all not numeric digits.
+ while (@a && @b) {
+ my $a = shift @a;
+ my $b = shift @b;
+
+ # Use numeric comparison if chunks are non-equal numbers.
+ return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b;
+
+ # Use string comparison if chunks are any other kind of non-equal string.
+ return $a cmp $b if $a ne $b;
+ }
+
+ # One of the two is now empty; compare lengths for result in this case.
+ return @a <=> @b;
+}
+
+sub pathcmp($$)
+{
+ my ($patha, $pathb) = @_;
+
+ my ($dira, $namea) = splitpath($patha);
+ my ($dirb, $nameb) = splitpath($pathb);
+
+ return numericcmp($dira, $dirb) if $dira ne $dirb;
+ return numericcmp($namea, $nameb);
+}
+
+sub findTestsToRun()
+{
+ our %ignoredLocalDirectories = map { $_ => 1 } qw(.svn _svn);
+ our %supportedFileExtensions = map { $_ => 1 } qw(cpp);
+ our $testsDirectory = File::Spec->catfile(sourceDir(), qw(WebKitTools TestWebKitAPI Tests));
+ our @testsFound = ();
+
+ sub directoryFilter
+ {
+ return () if exists $ignoredLocalDirectories{basename($File::Find::dir)};
+ return @_;
+ }
+
+ sub fileFilter
+ {
+ my $filename = $_;
+ if ($filename =~ /\.([^.]+)$/) {
+
+ if (exists $supportedFileExtensions{$1}) {
+ my $path = File::Spec->abs2rel(catfile($File::Find::dir, $filename), $testsDirectory);
+ push @testsFound, $path;
+ }
+ }
+ }
+
+ chdirWebKit();
+
+ find({ preprocess => \&directoryFilter, wanted => \&fileFilter }, $testsDirectory);
+ return sort pathcmp @testsFound;
+}
+
+sub runTest($)
+{
+ my ($testPath) = @_;
+
+ my ($dir, $testFile) = splitpath($testPath);
+ my $test = substr($testFile, 0, rindex($testFile, "."));
+
+ print "Running " . $dir . $test . "\n";
+
+ if (isAppleMacWebKit()) {
+ my $productDir = productDir();
+ $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
+ $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
+ my $apiTesterPath = "$productDir/TestWebKitAPI";
+ if (!isTiger() && architecture()) {
+ return system "arch", "-" . architecture(), $apiTesterPath, $test, @ARGV;
+ } else {
+ return system $apiTesterPath, $test, @ARGV;
+ }
+ }
+}
+
+sub buildTestTool()
+{
+ chdirWebKit();
+
+ my $buildTestTool = "build-api-tests";
+ print STDERR "Running $buildTestTool\n";
+
+ local *DEVNULL;
+ my ($childIn, $childOut, $childErr);
+ if ($quiet) {
+ open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null";
+ $childOut = ">&DEVNULL";
+ $childErr = ">&DEVNULL";
+ } else {
+ # When not quiet, let the child use our stdout/stderr.
+ $childOut = ">&STDOUT";
+ $childErr = ">&STDERR";
+ }
+
+ my @args = argumentsForConfiguration();
+ my $buildProcess = open3($childIn, $childOut, $childErr, "WebKitTools/Scripts/$buildTestTool", @args) or die "Failed to run " . $buildTestTool;
+ close($childIn);
+ waitpid $buildProcess, 0;
+ my $buildResult = $?;
+ close($childOut);
+ close($childErr);
+
+ close DEVNULL if ($quiet);
+
+ if ($buildResult) {
+ print STDERR "Compiling TestWebKitAPI failed!\n";
+ exit exitStatus($buildResult);
+ }
+}
diff --git a/WebKitTools/WebKitTestRunner/Configurations/Base.xcconfig b/WebKitTools/TestWebKitAPI/Configurations/Base.xcconfig
similarity index 100%
copy from WebKitTools/WebKitTestRunner/Configurations/Base.xcconfig
copy to WebKitTools/TestWebKitAPI/Configurations/Base.xcconfig
diff --git a/WebKitTools/WebKitTestRunner/Configurations/DebugRelease.xcconfig b/WebKitTools/TestWebKitAPI/Configurations/DebugRelease.xcconfig
similarity index 100%
copy from WebKitTools/WebKitTestRunner/Configurations/DebugRelease.xcconfig
copy to WebKitTools/TestWebKitAPI/Configurations/DebugRelease.xcconfig
diff --git a/WebKitTools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig b/WebKitTools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig
new file mode 100644
index 0000000..5e69d0e
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig
@@ -0,0 +1,26 @@
+// Copyright (C) 2010 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+PRODUCT_NAME = TestWebKitAPI
+GCC_ENABLE_OBJC_EXCEPTIONS = YES
+GCC_PREFIX_HEADER = TestWebKitAPIPrefix.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/ASCIICType.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/ASCIICType.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/ASCIICType.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/ASCIICType.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Assertions.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Assertions.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Assertions.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Assertions.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Atomics.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Atomics.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Atomics.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Atomics.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/FastMalloc.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/FastMalloc.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/FastMalloc.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/FastMalloc.h
diff --git a/WebKitTools/WebKitTestRunner/ForwardingHeaders/wtf/GetPtr.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/GetPtr.h
similarity index 100%
copy from WebKitTools/WebKitTestRunner/ForwardingHeaders/wtf/GetPtr.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/GetPtr.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/HashMap.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/HashMap.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/HashMap.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/HashMap.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/HashSet.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/HashSet.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/HashSet.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/HashSet.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/HashTraits.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/HashTraits.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/HashTraits.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/HashTraits.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Locker.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Locker.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Locker.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Locker.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/MainThread.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/MainThread.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/MainThread.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/MainThread.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/MathExtras.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/MathExtras.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/MathExtras.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/MathExtras.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Noncopyable.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Noncopyable.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Noncopyable.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Noncopyable.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/OwnPtr.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/OwnPtr.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/OwnPtr.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/OwnPtr.h
diff --git a/WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/OwnPtrCommon.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/OwnPtrCommon.h
similarity index 100%
copy from WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/OwnPtrCommon.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/OwnPtrCommon.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/PassOwnPtr.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/PassOwnPtr.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/PassOwnPtr.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/PassOwnPtr.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/PassRefPtr.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/PassRefPtr.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/PassRefPtr.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/PassRefPtr.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Platform.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Platform.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Platform.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Platform.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/RefCounted.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/RefCounted.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/RefCounted.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/RefCounted.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/RefPtr.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/RefPtr.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/RefPtr.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/RefPtr.h
diff --git a/WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/RetainPtr.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/RetainPtr.h
similarity index 100%
copy from WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/RetainPtr.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/RetainPtr.h
diff --git a/WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/StringExtras.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/StringExtras.h
similarity index 100%
copy from WebKitTools/DumpRenderTree/ForwardingHeaders/wtf/StringExtras.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/StringExtras.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/ThreadSafeShared.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/ThreadSafeShared.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/ThreadSafeShared.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/ThreadSafeShared.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Threading.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Threading.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Threading.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Threading.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/ThreadingPrimitives.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/ThreadingPrimitives.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/ThreadingPrimitives.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/ThreadingPrimitives.h
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/Vector.h b/WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Vector.h
similarity index 100%
copy from JavaScriptGlue/ForwardingHeaders/wtf/Vector.h
copy to WebKitTools/TestWebKitAPI/ForwardingHeaders/wtf/Vector.h
diff --git a/WebKitTools/TestWebKitAPI/PlatformUtilities.h b/WebKitTools/TestWebKitAPI/PlatformUtilities.h
new file mode 100644
index 0000000..1b9e94b
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/PlatformUtilities.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformUtilities_h
+#define PlatformUtilities_h
+
+namespace TestWebKitAPI {
+namespace Util {
+
+// Runs a platform runloop until the 'done' is true.
+void run(bool* done);
+
+WKURLRef createURLForResource(const char* file);
+
+} // namespace Util
+} // namespace TestWebKitAPI
+
+#endif // PlatformUtilities_h
diff --git a/WebKitTools/TestWebKitAPI/PlatformWebView.h b/WebKitTools/TestWebKitAPI/PlatformWebView.h
new file mode 100644
index 0000000..de8e1ce
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/PlatformWebView.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformWebView_h
+#define PlatformWebView_h
+
+#ifdef __APPLE__
+#ifdef __OBJC__
+ at class WKView;
+ at class NSWindow;
+#else
+class WKView;
+class NSWindow;
+#endif
+typedef WKView *PlatformWKView;
+typedef NSWindow *PlatformWindow;
+#elif defined(WIN32) || defined(_WIN32)
+typedef WKViewRef PlatformWKView;
+typedef HWND PlatformWindow;
+#endif
+
+namespace TestWebKitAPI {
+
+class PlatformWebView {
+public:
+ PlatformWebView(WKPageNamespaceRef);
+ ~PlatformWebView();
+
+ WKPageRef page();
+ PlatformWKView platformView() const { return m_view; }
+ void resizeTo(unsigned width, unsigned height);
+ void focus();
+
+private:
+ PlatformWKView m_view;
+ PlatformWindow m_window;
+};
+
+} // namespace TestWebKitAPI
+
+#endif // PlatformWebView_h
diff --git a/WebKitTools/TestWebKitAPI/Test.h b/WebKitTools/TestWebKitAPI/Test.h
new file mode 100644
index 0000000..6a76b9c
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Test.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Test_h
+#define Test_h
+
+#include "TestsController.h"
+
+namespace TestWebKitAPI {
+
+// Abstract base class that all tests inherit from.
+class Test {
+public:
+ virtual ~Test() { }
+
+ virtual void run() = 0;
+ std::string name() const { return m_identifier; }
+
+ template<typename TestClassTy> class Register {
+ public:
+ Register(const std::string& identifier)
+ {
+ TestsController::shared().registerCreateTestFunction(identifier, Register::create);
+ }
+
+ private:
+ static Test* create(const std::string& identifier)
+ {
+ return new TestClassTy(identifier);
+ }
+ };
+
+protected:
+ Test(const std::string& identifier)
+ : m_identifier(identifier)
+ {
+ }
+
+ std::string m_identifier;
+};
+
+#define TEST_CLASS_NAME(testCaseName) testCaseName##_Test
+#define TEST_REGISTRAR_NAME(testCaseName) testCaseName##_Registrar
+
+// Use this to define a new test.
+#define TEST(testCaseName) \
+ class TEST_CLASS_NAME(testCaseName) : public Test { \
+ public: \
+ TEST_CLASS_NAME(testCaseName)(const std::string& identifier) \
+ : Test(identifier) \
+ { \
+ } \
+ virtual void run(); \
+ }; \
+ \
+ static Test::Register<TEST_CLASS_NAME(testCaseName)> TEST_REGISTRAR_NAME(testCaseName)(#testCaseName); \
+ \
+ void TEST_CLASS_NAME(testCaseName)::run()
+
+#define TEST_ASSERT(expression) do { if (!(expression)) { TestsController::shared().testFailed(__FILE__, __LINE__, #expression); return; } } while (0)
+
+} // namespace TestWebKitAPI
+
+#endif // Test_h
diff --git a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..2c5de14
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -0,0 +1,296 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */; };
+ BC131A9B1171316900B69727 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131A9A1171316900B69727 /* main.mm */; };
+ BC131AA9117131FC00B69727 /* TestsController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC131AA8117131FC00B69727 /* TestsController.cpp */; };
+ BC90955D125548AA00083756 /* PlatformWebViewMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC90955C125548AA00083756 /* PlatformWebViewMac.mm */; };
+ BC90964C125561BF00083756 /* VectorBasic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC90964B125561BF00083756 /* VectorBasic.cpp */; };
+ BC90964E1255620C00083756 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC90964D1255620C00083756 /* JavaScriptCore.framework */; };
+ BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC909779125571AB00083756 /* PageLoadBasic.cpp */; };
+ BC909784125571CF00083756 /* basic-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BC909778125571AB00083756 /* basic-1.html */; };
+ BCA61DB511700EFD00460D1E /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA61DB411700EFD00460D1E /* WebKit2.framework */; };
+ BCB9E9F111235BDE00A137E0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCB9E9F011235BDE00A137E0 /* Cocoa.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 8;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+ BCB9F4FB112384C000A137E0 /* Copy Resources */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 7;
+ files = (
+ BC909784125571CF00083756 /* basic-1.html in Copy Resources */,
+ );
+ name = "Copy Resources";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
+ BC131883117114A800B69727 /* PlatformUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformUtilities.h; sourceTree = "<group>"; };
+ BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformUtilitiesMac.mm; sourceTree = "<group>"; };
+ BC131A9A1171316900B69727 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
+ BC131A9E1171317C00B69727 /* TestWebKitAPIPrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestWebKitAPIPrefix.h; sourceTree = "<group>"; };
+ BC131AA8117131FC00B69727 /* TestsController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = TestsController.cpp; sourceTree = "<group>"; };
+ BC90951B125533D700083756 /* PlatformWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformWebView.h; sourceTree = "<group>"; };
+ BC90955C125548AA00083756 /* PlatformWebViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformWebViewMac.mm; sourceTree = "<group>"; };
+ BC90957E12554CF900083756 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
+ BC90957F12554CF900083756 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
+ BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = TestWebKitAPI.xcconfig; sourceTree = "<group>"; };
+ BC90964B125561BF00083756 /* VectorBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VectorBasic.cpp; path = WTF/VectorBasic.cpp; sourceTree = "<group>"; };
+ BC90964D1255620C00083756 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = ../../WebKitBuild/Debug/JavaScriptCore.framework; sourceTree = SOURCE_ROOT; };
+ BC909778125571AB00083756 /* basic-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "basic-1.html"; sourceTree = "<group>"; };
+ BC909779125571AB00083756 /* PageLoadBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageLoadBasic.cpp; sourceTree = "<group>"; };
+ BCA61DB411700EFD00460D1E /* WebKit2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ BCB9E7C711234E3A00A137E0 /* TestsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestsController.h; sourceTree = "<group>"; };
+ BCB9E7FA112359A300A137E0 /* Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test.h; sourceTree = "<group>"; };
+ BCB9E9F011235BDE00A137E0 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ BCB9E9F111235BDE00A137E0 /* Cocoa.framework in Frameworks */,
+ BCA61DB511700EFD00460D1E /* WebKit2.framework in Frameworks */,
+ BC90964E1255620C00083756 /* JavaScriptCore.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 08FB7794FE84155DC02AAC07 /* TestWebKitAPI */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB7795FE84155DC02AAC07 /* Source */,
+ BCB9EB66112366D800A137E0 /* Tests */,
+ BC90957D12554CEA00083756 /* Configurations */,
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
+ 1AB674ADFE9D54B511CA2CBB /* Products */,
+ );
+ name = TestWebKitAPI;
+ sourceTree = "<group>";
+ };
+ 08FB7795FE84155DC02AAC07 /* Source */ = {
+ isa = PBXGroup;
+ children = (
+ BCA61C3A11700B9400460D1E /* mac */,
+ BC131A9E1171317C00B69727 /* TestWebKitAPIPrefix.h */,
+ BC131883117114A800B69727 /* PlatformUtilities.h */,
+ BC90951B125533D700083756 /* PlatformWebView.h */,
+ BCB9E7FA112359A300A137E0 /* Test.h */,
+ BC131AA8117131FC00B69727 /* TestsController.cpp */,
+ BCB9E7C711234E3A00A137E0 /* TestsController.h */,
+ );
+ name = Source;
+ sourceTree = "<group>";
+ };
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
+ isa = PBXGroup;
+ children = (
+ BCB9E9F011235BDE00A137E0 /* Cocoa.framework */,
+ BC90964D1255620C00083756 /* JavaScriptCore.framework */,
+ BCA61DB411700EFD00460D1E /* WebKit2.framework */,
+ );
+ name = "External Frameworks and Libraries";
+ sourceTree = "<group>";
+ };
+ 1AB674ADFE9D54B511CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8DD76FA10486AA7600D96B5E /* TestWebKitAPI */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ BC90957D12554CEA00083756 /* Configurations */ = {
+ isa = PBXGroup;
+ children = (
+ BC90957E12554CF900083756 /* Base.xcconfig */,
+ BC90957F12554CF900083756 /* DebugRelease.xcconfig */,
+ BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */,
+ );
+ path = Configurations;
+ sourceTree = "<group>";
+ };
+ BC9096411255616000083756 /* WebKit2 */ = {
+ isa = PBXGroup;
+ children = (
+ BC90977B125571AE00083756 /* Resources */,
+ BC909779125571AB00083756 /* PageLoadBasic.cpp */,
+ );
+ path = WebKit2;
+ sourceTree = "<group>";
+ };
+ BC9096461255618900083756 /* WTF */ = {
+ isa = PBXGroup;
+ children = (
+ BC90964B125561BF00083756 /* VectorBasic.cpp */,
+ );
+ name = WTF;
+ sourceTree = "<group>";
+ };
+ BC90977B125571AE00083756 /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ BC909778125571AB00083756 /* basic-1.html */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ BCA61C3A11700B9400460D1E /* mac */ = {
+ isa = PBXGroup;
+ children = (
+ BC131A9A1171316900B69727 /* main.mm */,
+ BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */,
+ BC90955C125548AA00083756 /* PlatformWebViewMac.mm */,
+ );
+ path = mac;
+ sourceTree = "<group>";
+ };
+ BCB9EB66112366D800A137E0 /* Tests */ = {
+ isa = PBXGroup;
+ children = (
+ BC9096411255616000083756 /* WebKit2 */,
+ BC9096461255618900083756 /* WTF */,
+ );
+ path = Tests;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8DD76F960486AA7600D96B5E /* TestWebKitAPI */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "TestWebKitAPI" */;
+ buildPhases = (
+ 8DD76F990486AA7600D96B5E /* Sources */,
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */,
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */,
+ BCB9F4FB112384C000A137E0 /* Copy Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = TestWebKitAPI;
+ productInstallPath = "$(HOME)/bin";
+ productName = TestWebKitAPI;
+ productReference = 8DD76FA10486AA7600D96B5E /* TestWebKitAPI */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 08FB7793FE84155DC02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "TestWebKitAPI" */;
+ compatibilityVersion = "Xcode 3.1";
+ hasScannedForEncodings = 1;
+ mainGroup = 08FB7794FE84155DC02AAC07 /* TestWebKitAPI */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8DD76F960486AA7600D96B5E /* TestWebKitAPI */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8DD76F990486AA7600D96B5E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */,
+ BC131A9B1171316900B69727 /* main.mm in Sources */,
+ BC131AA9117131FC00B69727 /* TestsController.cpp in Sources */,
+ BC90955D125548AA00083756 /* PlatformWebViewMac.mm in Sources */,
+ BC90964C125561BF00083756 /* VectorBasic.cpp in Sources */,
+ BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB927508733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../WebKitBuild/Debug\"",
+ );
+ };
+ name = Debug;
+ };
+ 1DEB927608733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../WebKitBuild/Debug\"",
+ );
+ };
+ name = Release;
+ };
+ 1DEB927908733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = BC90957F12554CF900083756 /* DebugRelease.xcconfig */;
+ buildSettings = {
+ GCC_OPTIMIZATION_LEVEL = 0;
+ };
+ name = Debug;
+ };
+ 1DEB927A08733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = BC90957F12554CF900083756 /* DebugRelease.xcconfig */;
+ buildSettings = {
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "TestWebKitAPI" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927508733DD40010E9CD /* Debug */,
+ 1DEB927608733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "TestWebKitAPI" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927908733DD40010E9CD /* Debug */,
+ 1DEB927A08733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
diff --git a/WebKitTools/TestWebKitAPI/TestWebKitAPIPrefix.h b/WebKitTools/TestWebKitAPI/TestWebKitAPIPrefix.h
new file mode 100644
index 0000000..32181ba
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/TestWebKitAPIPrefix.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <stdint.h>
+
+#include <WebKit2/WebKit2.h>
+
+#if __APPLE__
+
+#ifdef __OBJC__
+#import <Cocoa/Cocoa.h>
+#endif
+
+#endif
diff --git a/WebKitTools/TestWebKitAPI/Tests/WTF/VectorBasic.cpp b/WebKitTools/TestWebKitAPI/Tests/WTF/VectorBasic.cpp
new file mode 100644
index 0000000..dedd1ff
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WTF/VectorBasic.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Test.h"
+
+#include <JavaScriptCore/Vector.h>
+
+namespace TestWebKitAPI {
+
+TEST(VectorBasic)
+{
+ Vector<int> intVector;
+ TEST_ASSERT(intVector.isEmpty());
+ TEST_ASSERT(intVector.size() == 0);
+ TEST_ASSERT(intVector.capacity() == 0);
+}
+
+} // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp
new file mode 100644
index 0000000..820d29b
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Test.h"
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <WebKit2/WebKit2.h>
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool test1Done;
+
+struct State {
+ State()
+ : didDecidePolicyForNavigationAction(false)
+ , didStartProvisionalLoadForFrame(false)
+ , didCommitLoadForFrame(false)
+ {
+ }
+
+ bool didDecidePolicyForNavigationAction;
+ bool didStartProvisionalLoadForFrame;
+ bool didCommitLoadForFrame;
+};
+
+static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo));
+ TEST_ASSERT(state->didDecidePolicyForNavigationAction);
+ TEST_ASSERT(!state->didCommitLoadForFrame);
+ TEST_ASSERT(!state->didStartProvisionalLoadForFrame);
+
+ state->didStartProvisionalLoadForFrame = true;
+}
+
+static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo));
+ TEST_ASSERT(state->didDecidePolicyForNavigationAction);
+ TEST_ASSERT(state->didStartProvisionalLoadForFrame);
+
+ state->didCommitLoadForFrame = true;
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo));
+ TEST_ASSERT(state->didDecidePolicyForNavigationAction);
+ TEST_ASSERT(state->didStartProvisionalLoadForFrame);
+ TEST_ASSERT(state->didCommitLoadForFrame);
+
+ test1Done = true;
+}
+
+static void decidePolicyForNavigationAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo)
+{
+ State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo));
+ TEST_ASSERT(!state->didStartProvisionalLoadForFrame);
+ TEST_ASSERT(!state->didCommitLoadForFrame);
+
+ state->didDecidePolicyForNavigationAction = true;
+
+ WKFramePolicyListenerUse(listener);
+}
+
+static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo)
+{
+ WKFramePolicyListenerUse(listener);
+}
+
+static void decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo)
+{
+ WKFramePolicyListenerUse(listener);
+}
+
+TEST(PageLoadBasic)
+{
+ State state;
+
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+ WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get()));
+
+ PlatformWebView webView(pageNamespace.get());
+
+ WKPageLoaderClient loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.version = 0;
+ loaderClient.clientInfo = &state;
+ loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
+ loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ WKPageSetPageLoaderClient(webView.page(), &loaderClient);
+
+ WKPagePolicyClient policyClient;
+ memset(&policyClient, 0, sizeof(policyClient));
+
+ policyClient.version = 0;
+ policyClient.clientInfo = &state;
+ policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction;
+ policyClient.decidePolicyForNewWindowAction = decidePolicyForNewWindowAction;
+ policyClient.decidePolicyForMIMEType = decidePolicyForMIMEType;
+ WKPageSetPagePolicyClient(webView.page(), &policyClient);
+
+ WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("basic-1"));
+ WKPageLoadURL(webView.page(), url.get());
+
+ Util::run(&test1Done);
+}
+
+} // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/basic-1.html b/WebKitTools/TestWebKitAPI/Tests/WebKit2/basic-1.html
new file mode 100644
index 0000000..b597ee6
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WebKit2/basic-1.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+ Basic test 1.
+</body>
+</html>
diff --git a/WebKitTools/TestWebKitAPI/TestsController.cpp b/WebKitTools/TestWebKitAPI/TestsController.cpp
new file mode 100644
index 0000000..e6039f4
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/TestsController.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "TestsController.h"
+
+#include "Test.h"
+#include <algorithm>
+#include <assert.h>
+
+namespace TestWebKitAPI {
+
+TestsController& TestsController::shared()
+{
+ static TestsController& shared = *new TestsController;
+ return shared;
+}
+
+TestsController::TestsController()
+ : m_testFailed(false)
+ , m_currentTest(0)
+{
+}
+
+bool TestsController::runTestNamed(const std::string& identifier)
+{
+ CreateTestFunction createTestFunction = m_createTestFunctions[identifier];
+ if (!createTestFunction) {
+ printf("ERROR: Test not found - %s\n", identifier.c_str());
+ return false;
+ }
+
+ m_currentTest = createTestFunction(identifier);
+ m_currentTest->run();
+
+ if (!m_testFailed)
+ printf("PASS: %s\n", m_currentTest->name().c_str());
+
+ delete m_currentTest;
+ m_currentTest = 0;
+
+ return !m_testFailed;
+}
+
+void TestsController::testFailed(const char* file, int line, const char* message)
+{
+ m_testFailed = true;
+ printf("FAIL: %s\n\t%s (%s:%d)\n", m_currentTest->name().c_str(), message, file, line);
+}
+
+void TestsController::registerCreateTestFunction(const std::string& identifier, CreateTestFunction createTestFunction)
+{
+ m_createTestFunctions[identifier] = createTestFunction;
+}
+
+} // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/TestsController.h b/WebKitTools/TestWebKitAPI/TestsController.h
new file mode 100644
index 0000000..19ebfc2
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/TestsController.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TestsController_h
+#define TestsController_h
+
+#include <map>
+#include <string>
+
+namespace TestWebKitAPI {
+
+class Test;
+
+class TestsController {
+public:
+ static TestsController& shared();
+
+ bool runTestNamed(const std::string&);
+
+ // Called by the tests themselves.
+ void testFailed(const char* file, int line, const char* message);
+
+ typedef Test* (*CreateTestFunction)(const std::string&);
+ void registerCreateTestFunction(const std::string&, CreateTestFunction);
+
+private:
+ TestsController();
+ ~TestsController();
+
+ bool m_testFailed;
+ Test* m_currentTest;
+
+ std::map<std::string, CreateTestFunction> m_createTestFunctions;
+};
+
+} // namespace TestWebKitAPI
+
+#endif // TestsController_h
diff --git a/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm b/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm
new file mode 100644
index 0000000..8b360c8
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PlatformUtilities.h"
+
+#include <WebKit2/WKStringCF.h>
+#include <WebKit2/WKURLCF.h>
+
+namespace TestWebKitAPI {
+namespace Util {
+
+void run(bool* done)
+{
+ while (!*done)
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
+}
+
+WKURLRef createURLForResource(const char* file)
+{
+ NSURL* nsURL = [[NSBundle mainBundle] URLForResource:[NSString stringWithUTF8String:file] withExtension:@"html"];
+ return WKURLCreateWithCFURL((CFURLRef)nsURL);
+}
+
+} // namespace Util
+} // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm b/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm
new file mode 100644
index 0000000..c8f04c8
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PlatformWebView.h"
+
+namespace TestWebKitAPI {
+
+PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef)
+{
+ NSRect rect = NSMakeRect(0, 0, 800, 600);
+ m_view = [[WKView alloc] initWithFrame:rect pageNamespaceRef:namespaceRef];
+
+ NSRect windowRect = NSOffsetRect(rect, -10000, [[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
+ m_window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+ [m_window setColorSpace:[[NSScreen mainScreen] colorSpace]];
+ [[m_window contentView] addSubview:m_view];
+ [m_window orderBack:nil];
+ [m_window setAutodisplay:NO];
+ [m_window setReleasedWhenClosed:NO];
+}
+
+void PlatformWebView::resizeTo(unsigned width, unsigned height)
+{
+ [m_view setFrame:NSMakeRect(0, 0, width, height)];
+}
+
+PlatformWebView::~PlatformWebView()
+{
+ [m_window close];
+ [m_window release];
+ [m_view release];
+}
+
+WKPageRef PlatformWebView::page()
+{
+ return [m_view pageRef];
+}
+
+void PlatformWebView::focus()
+{
+ // Implement.
+}
+
+} // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/mac/main.mm b/WebKitTools/TestWebKitAPI/mac/main.mm
new file mode 100644
index 0000000..59dabab
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/mac/main.mm
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "TestsController.h"
+
+int main(int argc, const char* argv[])
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ [NSApplication sharedApplication];
+
+ bool passed = TestWebKitAPI::TestsController::shared().runTestNamed(std::string(argv[1]));
+
+ [pool drain];
+
+ return passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list