[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - sal/qa

Tomáš Chvátal tchvatal at kemper.freedesktop.org
Wed Apr 4 05:55:07 PDT 2012


 sal/qa/osl/security/osl_Security.cxx     |   93 +++++++++++++++++--------------
 sal/qa/osl/security/osl_Security_Const.h |   19 +-----
 2 files changed, 54 insertions(+), 58 deletions(-)

New commits:
commit 0c1b92a79929fe2b25dc3a95cf94413a713d99db
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Apr 3 14:01:30 2012 +0200

    don't skip first cmdline argument
    
    It looks like this one is also meant to be called manually or something,
    and the original version didn't skip the first argument either.
    
    Signed-off-by: Tomas Chvatal <tchvatal at suse.cz>

diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 637c378..4deb7af 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -637,8 +637,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
     rtl::OUString args[ 3 ];
     int argsCount = 0;
     sal_uInt32 n = rtl_getAppCommandArgCount();
-    // skip first, that's the module name
-    for (sal_uInt32 i = 1; i < n; ++i)
+    for (sal_uInt32 i = 0; i < n; ++i)
     {
         rtl::OUString arg;
         rtl_getAppCommandArg(i, &arg.pData);
commit 23be7b5d793a44ab53a996a1eba6b571bd311339
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Apr 2 18:59:53 2012 +0200

    fix crude command line arguments handling
    
    Signed-off-by: Tomas Chvatal <tchvatal at suse.cz>

diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 751f09b..637c378 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -38,6 +38,7 @@
 #endif
 #include <osl_Security_Const.h>
 #include <osl/thread.h>
+#include <rtl/process.h>
 #include <rtl/strbuf.hxx>
 
 using namespace osl;
@@ -353,7 +354,7 @@ class MyTestPlugInImpl: public CPPUNIT_NS::TestPlugInDefaultImpl
 
 
 void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
-                   const CPPUNIT_NS::PlugInParameters & parameters)
+                   const CPPUNIT_NS::PlugInParameters & )
 {
     /// start message
     t_print("#Initializing ...\n" );
@@ -633,44 +634,53 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
         t_print("Administrator.\n" );
 
     /// get and display forwarded text if available.
-    aStringForward = ::rtl::OUString::createFromAscii( parameters.getCommandLine().c_str() );
-    if ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 )
+    rtl::OUString args[ 3 ];
+    int argsCount = 0;
+    sal_uInt32 n = rtl_getAppCommandArgCount();
+    // skip first, that's the module name
+    for (sal_uInt32 i = 1; i < n; ++i)
     {
-        sal_Int32 nFirstSpacePoint = aStringForward.indexOf( (sal_Unicode)' ' );;
-        sal_Int32 nLastSpacePoint = aStringForward.lastIndexOf( (sal_Unicode)' ' );;
-        if ( nFirstSpacePoint == nLastSpacePoint )
-        /// only forwarded two parameters, username and password.
+        rtl::OUString arg;
+        rtl_getAppCommandArg(i, &arg.pData);
+        if( !arg.isEmpty() && arg[ 0 ] == '-' )
+            continue;
+        if( argsCount >= 3 )
         {
-            aLogonUser = aStringForward.copy( 0, nFirstSpacePoint );
-            t_print("\n#Forwarded username: ");
-            printUString( aLogonUser);
-
-            aLogonPasswd = aStringForward.copy( nFirstSpacePoint +1, aStringForward.getLength( ) - 1 );
-            t_print("#Forwarded password: ");
-            for (int i = nFirstSpacePoint+1; i <= aStringForward.getLength()-1; ++i)
-                t_print("*");
-            t_print("\n" );
-        }
-        else
-        /// forwarded three parameters, username, password and fileserver.
-        {
-            aLogonUser = aStringForward.copy( 0, nFirstSpacePoint );
-            t_print("#Forwarded username: ");
-            printUString( aLogonUser);
-
-            aLogonPasswd = aStringForward.copy( nFirstSpacePoint +1, nLastSpacePoint );
-            t_print("#Forwarded password: ");
-            for (int i = nFirstSpacePoint+1; i <= nLastSpacePoint; ++i)
-                t_print("*");
-            t_print("\n" );
-
-            aFileServer = aStringForward.copy( nLastSpacePoint +1, aStringForward.getLength( ) - 1 );
-            t_print("#Forwarded FileServer: ");
-            printUString( aFileServer );
-
+            SAL_WARN( "sal", "Too many test arguments" );
+            continue;
         }
+        args[ argsCount++ ] = arg;
+    }
+    /// only forwarded two parameters, username and password.
+    if( argsCount == 2 )
+    {
+        aLogonUser = args[ 0 ];
+        t_print("\n#Forwarded username: ");
+        printUString( aLogonUser);
+
+        aLogonPasswd = args[ 1 ];
+        t_print("#Forwarded password: ");
+        for (int i = 0; i < aLogonPasswd.getLength(); ++i)
+            t_print("*");
+        t_print("\n" );
+    }
+    else if( argsCount == 3 )
+    /// forwarded three parameters, username, password and fileserver.
+    {
+        aLogonUser = args[ 0 ];
+        t_print("#Forwarded username: ");
+        printUString( aLogonUser);
+
+        aLogonPasswd = args[ 1 ];
+        t_print("#Forwarded password: ");
+        for (int i = 0; i < aLogonPasswd.getLength(); ++i)
+            t_print("*");
+        t_print("\n" );
+
+        aFileServer = args[ 2 ];
+        t_print("#Forwarded FileServer: ");
+        printUString( aFileServer );
     }
-
     t_print("#\n#Initialization Done.\n" );
 
 }
commit 6ec109edd3b5384a15b8367f7760f9fe84a1d04d
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Apr 2 18:41:12 2012 +0200

    fix very ... uhm ... inventive and confusing use of empty string
    
    Signed-off-by: Tomas Chvatal <tchvatal at suse.cz>

diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 38f8130..751f09b 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -129,12 +129,12 @@ namespace osl_Security
 
 
         SAL_CPPUNIT_TEST_SUITE( logonUser );
-        if  ( !aStringForward.equals( aNullUrl )  && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) ==  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
+        if  ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) ==  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
         /// if user name and passwd are forwarded
         {
             CPPUNIT_TEST( logonUser_user_pwd );
         }
-        if  ( !aStringForward.equals( aNullUrl )  && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) !=  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
+        if  ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) !=  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
         /// if user name and passwd and file server are forwarded
         {
             CPPUNIT_TEST( logonUser_user_pwd_server );
@@ -597,31 +597,31 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
     t_print("#\n#Retrived system information is below:\n");
 
     t_print("Computer Name:              ");
-    if ( strComputerName == aNullUrl )
+    if ( strComputerName.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strComputerName );
 
     t_print("Current User Name:          ");
-    if ( strUserName == aNullUrl )
+    if ( strUserName.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strUserName );
 
     t_print("Current User Home Directory:");
-    if ( strHomeDirectory == aNullUrl )
+    if ( strHomeDirectory.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strHomeDirectory );
 
     t_print("Current Config Directory:   ");
-    if ( strConfigDirectory == aNullUrl )
+    if ( strConfigDirectory.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strConfigDirectory );
 
     t_print("Current UserID:             ");
-    if ( strUserID == aNullUrl )
+    if ( strUserID.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strUserID );
@@ -634,7 +634,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
 
     /// get and display forwarded text if available.
     aStringForward = ::rtl::OUString::createFromAscii( parameters.getCommandLine().c_str() );
-    if ( !aStringForward.equals( aNullUrl ) && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 )
+    if ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 )
     {
         sal_Int32 nFirstSpacePoint = aStringForward.indexOf( (sal_Unicode)' ' );;
         sal_Int32 nLastSpacePoint = aStringForward.lastIndexOf( (sal_Unicode)' ' );;
diff --git a/sal/qa/osl/security/osl_Security_Const.h b/sal/qa/osl/security/osl_Security_Const.h
index 0c3a242..4eca51c 100644
--- a/sal/qa/osl/security/osl_Security_Const.h
+++ b/sal/qa/osl/security/osl_Security_Const.h
@@ -59,22 +59,9 @@
 #define BUFSIZE 1024
 const char pTestString[17] = "Sun Microsystems";
 
-
-#define OSLTEST_DECLARE_USTRING( str_name, str_value ) \
-    ::rtl::OUString a##str_name = rtl::OUString::createFromAscii( str_value )
-
-//------------------------------------------------------------------------
-// condition names
-//------------------------------------------------------------------------
-
-// Intentionally different from the aNullURL in osl_File_Const.h to avoid
-// duplicate symbols as all the unit tests here get linked together for iOS...
-
-OSLTEST_DECLARE_USTRING( NullUrl,  "" );
-
-::rtl::OUString aLogonUser( aNullUrl ), aLogonPasswd( aNullUrl ), aFileServer( aNullUrl ), aStringForward( aNullUrl );
-::rtl::OUString strUserName( aNullUrl ) , strComputerName( aNullUrl ) , strHomeDirectory( aNullUrl );
-::rtl::OUString strConfigDirectory( aNullUrl ), strUserID( aNullUrl );
+::rtl::OUString aLogonUser, aLogonPasswd, aFileServer, aStringForward;
+::rtl::OUString strUserName, strComputerName, strHomeDirectory;
+::rtl::OUString strConfigDirectory, strUserID;
 
 sal_Bool isAdmin = sal_False;
 


More information about the Libreoffice-commits mailing list