Add TestWebKitAPI tests for KURL
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2012 06:07:52 +0000 (06:07 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2012 06:07:52 +0000 (06:07 +0000)
<http://webkit.org/b/75774>

Reviewed by Adam Barth.

Source/WebCore:

* WebCore.exp.in: Export additional KURL methods used in
testing.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add a
WebCore folder and KURL.cpp source file to the project.
* TestWebKitAPI/Tests/WebCore/KURL.cpp: Added.
(TestWebKitAPI::WebCore::SetUp): Initialize the main thread
during setup since this test doesn't go through WebKit or
WebKit2.
(TestWebKitAPI::TEST_F): Add two basic tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104671 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/KURL.cpp [new file with mode: 0644]

index 697703e..ca6add0 100644 (file)
@@ -1,3 +1,13 @@
+2012-01-10  David Kilzer  <ddkilzer@apple.com>
+
+        Add TestWebKitAPI tests for KURL
+        <http://webkit.org/b/75774>
+
+        Reviewed by Adam Barth.
+
+        * WebCore.exp.in: Export additional KURL methods used in
+        testing.
+
 2012-01-10  Jer Noble  <jer.noble@apple.com>
 
         Crash in HTMLMediaElement::shouldDisableSleep()
index 8e505fe..0989a25 100644 (file)
@@ -1325,8 +1325,14 @@ __ZNK7WebCore4KURL11isLocalFileEv
 __ZNK7WebCore4KURL12baseAsStringEv
 __ZNK7WebCore4KURL14fileSystemPathEv
 __ZNK7WebCore4KURL17lastPathComponentEv
+__ZNK7WebCore4KURL18fragmentIdentifierEv
+__ZNK7WebCore4KURL21hasFragmentIdentifierEv
 __ZNK7WebCore4KURL4hostEv
+__ZNK7WebCore4KURL4passEv
 __ZNK7WebCore4KURL4pathEv
+__ZNK7WebCore4KURL4portEv
+__ZNK7WebCore4KURL4userEv
+__ZNK7WebCore4KURL5queryEv
 __ZNK7WebCore4KURL8protocolEv
 __ZNK7WebCore4KURLcvP5NSURLEv
 __ZNK7WebCore4Node14isDescendantOfEPKS0_
index 085a936..b6de0ff 100644 (file)
@@ -1,5 +1,20 @@
 2012-01-10  David Kilzer  <ddkilzer@apple.com>
 
+        Add TestWebKitAPI tests for KURL
+        <http://webkit.org/b/75774>
+
+        Reviewed by Adam Barth.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add a
+        WebCore folder and KURL.cpp source file to the project.
+        * TestWebKitAPI/Tests/WebCore/KURL.cpp: Added.
+        (TestWebKitAPI::WebCore::SetUp): Initialize the main thread
+        during setup since this test doesn't go through WebKit or
+        WebKit2.
+        (TestWebKitAPI::TEST_F): Add two basic tests.
+
+2012-01-10  David Kilzer  <ddkilzer@apple.com>
+
         Extract common code for comparing WTF::String objects into WTFStringUtilities.h
 
         Reviewed by Adam Barth.
index 5a493c0..3483bec 100644 (file)
@@ -32,6 +32,7 @@
                37A6895F148A9B50005100FA /* SubresourceErrorCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */; };
                37DC678D140D7C5000ABCCDB /* DOMRangeOfString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */; };
                37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
+               440A1D3914A0103A008A66F2 /* KURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 440A1D3814A0103A008A66F2 /* KURL.cpp */; };
                4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
                4BFDFFA9131477770061F24B /* HitTestResultNodeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */; };
                520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */; };
                37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SubresourceErrorCrash.mm; sourceTree = "<group>"; };
                37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMRangeOfString.mm; sourceTree = "<group>"; };
                37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DOMRangeOfString.html; sourceTree = "<group>"; };
+               440A1D3814A0103A008A66F2 /* KURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KURL.cpp; sourceTree = "<group>"; };
                44A622C114A0E2B60048515B /* WTFStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFStringUtilities.h; sourceTree = "<group>"; };
                4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle_Bundle.cpp; sourceTree = "<group>"; };
                4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle.cpp; sourceTree = "<group>"; };
                        name = Products;
                        sourceTree = "<group>";
                };
+               440A1D3614A01000008A66F2 /* WebCore */ = {
+                       isa = PBXGroup;
+                       children = (
+                               440A1D3814A0103A008A66F2 /* KURL.cpp */,
+                       );
+                       path = WebCore;
+                       sourceTree = "<group>";
+               };
                BC029B1A1486B23800817DA9 /* ns */ = {
                        isa = PBXGroup;
                        children = (
                        children = (
                                C08587F913FEC39B001EF4E5 /* TestWebKitAPI */,
                                C07E6CAD13FD67650038B22B /* mac */,
+                               440A1D3614A01000008A66F2 /* WebCore */,
                                BC9096411255616000083756 /* WebKit2 */,
                                BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */,
                                BC9096461255618900083756 /* WTF */,
                                1AA9E55914980A9900001A8A /* Functional.cpp in Sources */,
                                BCAA485814A044D40088FAC4 /* EditorCommands.mm in Sources */,
                                BC55F5F914AD78EE00484BE1 /* Vector.cpp in Sources */,
+                               440A1D3914A0103A008A66F2 /* KURL.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Tools/TestWebKitAPI/Tests/WebCore/KURL.cpp b/Tools/TestWebKitAPI/Tests/WebCore/KURL.cpp
new file mode 100644 (file)
index 0000000..66f5808
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011, 2012 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 "config.h"
+#include "WTFStringUtilities.h"
+#include <WebCore/KURL.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+class WebCore: public testing::Test {
+public:
+    virtual void SetUp()
+    {
+        WTF::initializeMainThread();
+    }
+};
+
+TEST_F(WebCore, KURLConstructorDefault)
+{
+    KURL kurl;
+
+    EXPECT_FALSE(kurl.hasPath());
+    EXPECT_TRUE(kurl.isEmpty());
+    EXPECT_TRUE(kurl.isNull());
+    EXPECT_FALSE(kurl.isValid());
+}
+
+TEST_F(WebCore, KURLConstructorConstChar)
+{
+    KURL kurl(ParsedURLString, "http://username:password@www.example.com:8080/index.html?var=val#fragment");
+
+    EXPECT_TRUE(kurl.hasPath());
+    EXPECT_FALSE(kurl.isEmpty());
+    EXPECT_FALSE(kurl.isNull());
+    EXPECT_TRUE(kurl.isValid());
+
+    EXPECT_EQ(String("http"), kurl.protocol());
+    EXPECT_EQ(String("www.example.com"), kurl.host());
+    EXPECT_TRUE(kurl.hasPort());
+    EXPECT_EQ(8080, kurl.port());
+    EXPECT_EQ(String("username"), kurl.user());
+    EXPECT_EQ(String("password"), kurl.pass());
+    EXPECT_EQ(String("/index.html"), kurl.path());
+    EXPECT_EQ(String("index.html"), kurl.lastPathComponent());
+    EXPECT_EQ(String("var=val"), kurl.query());
+    EXPECT_TRUE(kurl.hasFragmentIdentifier());
+    EXPECT_EQ(String("fragment"), kurl.fragmentIdentifier());
+}
+
+} // namespace TestWebKitAPI