tools/qa/cppunit/test_urlobj.cxx |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

New commits:
commit 792cd487831b1f731b6fb2fc2d0f39ef60a63534
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Tue Nov 23 12:17:18 2021 +0100
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Tue Nov 23 14:16:28 2021 +0100

    Add test for INetURLObject::changeScheme
    
    Change-Id: I84497ee93e30b639199bbbb958ac1b2c758db50c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125693
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index 255c07137b1c..be605d53d6df 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -294,6 +294,23 @@ namespace tools_urlobj
                 obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
         }
 
+        void testChangeScheme() {
+            INetURLObject obj("unkonwn://example.com/foo/bar");
+            CPPUNIT_ASSERT(!obj.HasError());
+            obj.changeScheme(INetProtocol::Http);
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("http://example.com/foo/bar";),
+                obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            obj.changeScheme(INetProtocol::Https);
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("https://example.com/foo/bar";),
+                obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            obj.changeScheme(INetProtocol::Ftp);
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("ftp://example.com/foo/bar";),
+                obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+        }
+
         // Change the following lines only, if you add, remove or rename
         // member functions of the current class,
         // because these macros are need by auto register mechanism.
@@ -308,6 +325,7 @@ namespace tools_urlobj
         CPPUNIT_TEST( urlobjTest_isAnyKnownWebDAVScheme );
         CPPUNIT_TEST( testSetName );
         CPPUNIT_TEST( testSetExtension );
+        CPPUNIT_TEST( testChangeScheme );
         CPPUNIT_TEST_SUITE_END(  );
     };                          // class createPool
 

Reply via email to