[Libreoffice-commits] core.git: svl/qa

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 3 19:42:09 UTC 2019


 svl/qa/unit/lockfiles/test_lockfiles.cxx |   98 ++++++++++++-------------------
 1 file changed, 39 insertions(+), 59 deletions(-)

New commits:
commit 413461e3cf3a4b32a17419f67f879a8975c43987
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Apr 3 18:05:40 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Apr 3 21:41:42 2019 +0200

    svl.lockfiles.test: Create the temporary lock files in workdir
    
    Change-Id: I98b03754259c296ec8b4de2dddf6aee611bfe68a
    Reviewed-on: https://gerrit.libreoffice.org/70209
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/svl/qa/unit/lockfiles/test_lockfiles.cxx b/svl/qa/unit/lockfiles/test_lockfiles.cxx
index 5f23240f387c..b6c110ed6e48 100644
--- a/svl/qa/unit/lockfiles/test_lockfiles.cxx
+++ b/svl/qa/unit/lockfiles/test_lockfiles.cxx
@@ -29,6 +29,8 @@ namespace
 {
 class LockfileTest : public test::BootstrapFixture
 {
+    OUString generateTestURL(const OUString& sFileName) const;
+
 public:
     void testLOLockFileURL();
     void testLOLockFileContent();
@@ -92,11 +94,15 @@ OUString GetLockFileName(const svt::GenDocumentLockFile& rLockFile)
     return aDocURL.GetName();
 }
 
+OUString LockfileTest::generateTestURL(const OUString& sFileName) const
+{
+    return m_directories.getURLFromWorkdir("/CppunitTest/svl_lockfiles.test.user/") + sFileName;
+}
+
 void LockfileTest::testLOLockFileURL()
 {
     // Test the generated file name for LibreOffice lock files
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testLOLockFileURL.odt");
+    OUString aTestODT = generateTestURL("testLOLockFileURL.odt");
 
     svt::DocumentLockFile aLockFile(aTestODT);
     CPPUNIT_ASSERT_EQUAL(OUString(".~lock.testLOLockFileURL.odt%23"), GetLockFileName(aLockFile));
@@ -105,8 +111,7 @@ void LockfileTest::testLOLockFileURL()
 void LockfileTest::testLOLockFileContent()
 {
     // Test the lockfile generated for the specified ODT document
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testLOLockFileContent.odt");
+    OUString aTestODT = generateTestURL("testLOLockFileContent.odt");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -157,8 +162,7 @@ void LockfileTest::testLOLockFileContent()
 void LockfileTest::testLOLockFileRT()
 {
     // Test the lockfile generated for the specified ODT document
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testLOLockFileRT.odt");
+    OUString aTestODT = generateTestURL("testLOLockFileRT.odt");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -188,8 +192,7 @@ void LockfileTest::testLOLockFileRT()
 void LockfileTest::testLOLockFileUnicodeUsername()
 {
     // Test the lockfile generated for the specified ODT document
-    OUString aTestODT = m_directories.getURLFromSrc(
-        "/svl/qa/unit/lockfiles/data/testLOLockFileUnicodeUsername.odt");
+    OUString aTestODT = generateTestURL("testLOLockFileUnicodeUsername.odt");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -215,8 +218,7 @@ void LockfileTest::testLOLockFileUnicodeUsername()
 
 void LockfileTest::testLOLockFileOverwrite()
 {
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testLOLockFileOverwrite.odt");
+    OUString aTestODT = generateTestURL("testLOLockFileOverwrite.odt");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -257,62 +259,56 @@ void LockfileTest::testWordLockFileURL()
 
     // Word specific file format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testWordLockFileURL.docx");
+        OUString aTestFile = generateTestURL("testWordLockFileURL.docx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$stWordLockFileURL.docx"), GetLockFileName(aLockFile));
     }
 
     // Eight character file name (cuts two characters)
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.docx");
+        OUString aTestFile = generateTestURL("12345678.docx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$345678.docx"), GetLockFileName(aLockFile));
     }
 
     // Seven character file name (cuts one character)
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/1234567.docx");
+        OUString aTestFile = generateTestURL("1234567.docx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$234567.docx"), GetLockFileName(aLockFile));
     }
 
     // Six character file name (cuts no character)
     {
-        OUString aTestFile = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/123456.docx");
+        OUString aTestFile = generateTestURL("123456.docx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$123456.docx"), GetLockFileName(aLockFile));
     }
 
     // One character file name
     {
-        OUString aTestFile = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/1.docx");
+        OUString aTestFile = generateTestURL("1.docx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$1.docx"), GetLockFileName(aLockFile));
     }
 
     // Test for ODT format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.odt");
+        OUString aTestFile = generateTestURL("12345678.odt");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$345678.odt"), GetLockFileName(aLockFile));
     }
 
     // Test for DOC format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.doc");
+        OUString aTestFile = generateTestURL("12345678.doc");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$345678.doc"), GetLockFileName(aLockFile));
     }
 
     // Test for RTF format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.rtf");
+        OUString aTestFile = generateTestURL("12345678.rtf");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$345678.rtf"), GetLockFileName(aLockFile));
     }
@@ -322,31 +318,28 @@ void LockfileTest::testExcelLockFileURL()
 {
     // Test the generated file name for Excel lock files
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testExcelLockFileURL.xlsx");
+        OUString aTestFile = generateTestURL("testExcelLockFileURL.xlsx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$testExcelLockFileURL.xlsx"), GetLockFileName(aLockFile));
     }
 
     // Eight character file name
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.xlsx");
+        OUString aTestFile = generateTestURL("12345678.xlsx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$12345678.xlsx"), GetLockFileName(aLockFile));
     }
 
     // One character file name
     {
-        OUString aTestFile = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/1.xlsx");
+        OUString aTestFile = generateTestURL("1.xlsx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$1.xlsx"), GetLockFileName(aLockFile));
     }
 
     // Test for ODS format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.ods");
+        OUString aTestFile = generateTestURL("12345678.ods");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$12345678.ods"), GetLockFileName(aLockFile));
     }
@@ -356,8 +349,7 @@ void LockfileTest::testPowerPointLockFileURL()
 {
     // Test the generated file name for PowerPoint lock files
     {
-        OUString aTestFile = m_directories.getURLFromSrc(
-            "/svl/qa/unit/lockfiles/data/testPowerPointLockFileURL.pptx");
+        OUString aTestFile = generateTestURL("testPowerPointLockFileURL.pptx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$testPowerPointLockFileURL.pptx"),
                              GetLockFileName(aLockFile));
@@ -365,31 +357,28 @@ void LockfileTest::testPowerPointLockFileURL()
 
     // Eight character file name
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.pptx");
+        OUString aTestFile = generateTestURL("12345678.pptx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$12345678.pptx"), GetLockFileName(aLockFile));
     }
 
     // One character file name
     {
-        OUString aTestFile = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/1.pptx");
+        OUString aTestFile = generateTestURL("1.pptx");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$1.pptx"), GetLockFileName(aLockFile));
     }
 
     // Test for PPT format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.ppt");
+        OUString aTestFile = generateTestURL("12345678.ppt");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$12345678.ppt"), GetLockFileName(aLockFile));
     }
 
     // Test for ODP format
     {
-        OUString aTestFile
-            = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/12345678.odp");
+        OUString aTestFile = generateTestURL("/12345678.odp");
         svt::MSODocumentLockFile aLockFile(aTestFile);
         CPPUNIT_ASSERT_EQUAL(OUString("~$12345678.odp"), GetLockFileName(aLockFile));
     }
@@ -398,8 +387,7 @@ void LockfileTest::testPowerPointLockFileURL()
 void LockfileTest::testWordLockFileContent()
 {
     // Test the lockfile generated for the specified DOCX document
-    OUString aTestFile
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testWordLockFileContent.docx");
+    OUString aTestFile = generateTestURL("testWordLockFileContent.docx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -453,8 +441,7 @@ void LockfileTest::testWordLockFileContent()
 void LockfileTest::testExcelLockFileContent()
 {
     // Test the lockfile generated for the specified XLSX document
-    OUString aTestFile
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testExcelLockFileContent.xlsx");
+    OUString aTestFile = generateTestURL("testExcelLockFileContent.xlsx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -513,8 +500,7 @@ void LockfileTest::testExcelLockFileContent()
 void LockfileTest::testPowerPointLockFileContent()
 {
     // Test the lockfile generated for the specified PPTX document
-    OUString aTestFile = m_directories.getURLFromSrc(
-        "/svl/qa/unit/lockfiles/data/testPowerPointLockFileContent.pptx");
+    OUString aTestFile = generateTestURL("testPowerPointLockFileContent.pptx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -574,8 +560,7 @@ void LockfileTest::testPowerPointLockFileContent()
 
 void LockfileTest::testWordLockFileRT()
 {
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testWordLockFileRT.docx");
+    OUString aTestODT = generateTestURL("testWordLockFileRT.docx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -596,8 +581,7 @@ void LockfileTest::testWordLockFileRT()
 
 void LockfileTest::testExcelLockFileRT()
 {
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testExcelLockFileRT.xlsx");
+    OUString aTestODT = generateTestURL("testExcelLockFileRT.xlsx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -618,8 +602,7 @@ void LockfileTest::testExcelLockFileRT()
 
 void LockfileTest::testPowerPointLockFileRT()
 {
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testPowerPointLockFileRT.pptx");
+    OUString aTestODT = generateTestURL("testPowerPointLockFileRT.pptx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -640,8 +623,7 @@ void LockfileTest::testPowerPointLockFileRT()
 
 void LockfileTest::testMSOLockFileLongUserName()
 {
-    OUString aTestODT = m_directories.getURLFromSrc(
-        "/svl/qa/unit/lockfiles/data/testMSOLockFileLongUserName.docx");
+    OUString aTestODT = generateTestURL("testMSOLockFileLongUserName.docx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -667,8 +649,7 @@ void LockfileTest::testMSOLockFileLongUserName()
 void LockfileTest::testMSOLockFileUnicodeUsername()
 {
     // Test the lockfile generated for the specified ODT document
-    OUString aTestODT = m_directories.getURLFromSrc(
-        "/svl/qa/unit/lockfiles/data/testMSOLockFileUnicodeUsername.docx");
+    OUString aTestODT = generateTestURL("testMSOLockFileUnicodeUsername.docx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -694,8 +675,7 @@ void LockfileTest::testMSOLockFileUnicodeUsername()
 
 void LockfileTest::testMSOLockFileOverwrite()
 {
-    OUString aTestODT
-        = m_directories.getURLFromSrc("/svl/qa/unit/lockfiles/data/testMSOLockFileOverwrite.docx");
+    OUString aTestODT = generateTestURL("testMSOLockFileOverwrite.docx");
 
     // Set user name
     SvtUserOptions aUserOpt;
@@ -725,7 +705,7 @@ void LockfileTest::testMSOLockFileOverwrite()
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(LockfileTest);
-}
+} // namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 


More information about the Libreoffice-commits mailing list