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

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Jan 4 11:25:43 PST 2012


 extensions/qa/update/simple.xml                   |    6 ++--
 extensions/qa/update/test_update.cxx              |   27 +++++++++++++++++++---
 extensions/source/update/check/updateprotocol.cxx |   14 +++++++++--
 extensions/source/update/check/updateprotocol.hxx |    1 
 4 files changed, 40 insertions(+), 8 deletions(-)

New commits:
commit 953b7f9e1ba665b4763fac8f83113f43b6d49b39
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jan 4 19:25:57 2012 +0100

    Online update: Introduce inst:gitid to check exactly if we are the same.
    
    This allows to feed updates via a static .xml in a controlled environment.

diff --git a/extensions/qa/update/simple.xml b/extensions/qa/update/simple.xml
index 6a6af12..7900397 100644
--- a/extensions/qa/update/simple.xml
+++ b/extensions/qa/update/simple.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <inst:description xmlns:inst="http://update.libreoffice.org/description">
-  <inst:id>LibreOffice_3.4</inst:id>
-  <inst:version>3.4.2</inst:version>
-  <inst:buildid>102</inst:buildid>
+  <inst:id>LibreOffice 3.5.0 Beta2</inst:id>
+  <inst:version>3.5.0 Beta2</inst:version>
+  <inst:gitid>123456-abcdef-1a2b3c-4d5e6f</inst:gitid>
   <inst:os>Linux</inst:os>
   <inst:arch>x86</inst:arch>
 
diff --git a/extensions/qa/update/test_update.cxx b/extensions/qa/update/test_update.cxx
index bed67d3..af93e66 100644
--- a/extensions/qa/update/test_update.cxx
+++ b/extensions/qa/update/test_update.cxx
@@ -121,8 +121,8 @@ protected:
             CPPUNIT_FAIL( "Wrong type of the entry." );
     }
 
-    // test the checkForUpdates() method
-    void testCheckForUpdates()
+    // test the checkForUpdates() method - update is available
+    void testCheckUpdateAvailable()
     {
         UpdateInfo aInfo;
         rtl::Reference< UpdateCheck > aController( UpdateCheck::get() );
@@ -131,6 +131,7 @@ protected:
                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Linux" ) ),
                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "x86" ) ),
                     m_aRepositoryList,
+                    rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "111111-222222-333333-444444" ) ),
                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InstallSetID" ) ) ) )
         {
             CPPUNIT_ASSERT( aInfo.Sources.size() == 1 );
@@ -140,9 +141,29 @@ protected:
             CPPUNIT_FAIL( "Calling checkForUpdates() failed." );
     }
 
+    // test the checkForUpdates() method - we are up-to-date
+    void testCheckUpToDate()
+    {
+        UpdateInfo aInfo;
+        rtl::Reference< UpdateCheck > aController( UpdateCheck::get() );
+
+        if ( checkForUpdates( aInfo, m_xContext, aController->getInteractionHandler(), m_xProvider,
+                    rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Linux" ) ),
+                    rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "x86" ) ),
+                    m_aRepositoryList,
+                    rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "123456-abcdef-1a2b3c-4d5e6f" ) ),
+                    rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InstallSetID" ) ) ) )
+        {
+            CPPUNIT_ASSERT( aInfo.Sources.size() == 0 );
+        }
+        else
+            CPPUNIT_FAIL( "Calling checkForUpdates() failed." );
+    }
+
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testGetUpdateInformationEnumeration);
-    CPPUNIT_TEST(testCheckForUpdates);
+    CPPUNIT_TEST(testCheckUpdateAvailable);
+    CPPUNIT_TEST(testCheckUpToDate);
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/extensions/source/update/check/updateprotocol.cxx b/extensions/source/update/check/updateprotocol.cxx
index b0a20ab..2e9ec20 100644
--- a/extensions/source/update/check/updateprotocol.cxx
+++ b/extensions/source/update/check/updateprotocol.cxx
@@ -59,8 +59,14 @@ namespace xml = css::xml ;
 static bool
 getBootstrapData(
     uno::Sequence< ::rtl::OUString > & rRepositoryList,
+    ::rtl::OUString & rGitID,
     ::rtl::OUString & rInstallSetID)
 {
+    rGitID = UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" );
+    rtl::Bootstrap::expandMacros( rGitID );
+    if ( rGitID.isEmpty() )
+        return false;
+
     rInstallSetID = UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":UpdateID}" );
     rtl::Bootstrap::expandMacros( rInstallSetID );
     if ( ! rInstallSetID.getLength() )
@@ -97,14 +103,15 @@ checkForUpdates(
     rtl::Bootstrap::get(UNISTRING("_ARCH"), myArch);
 
     uno::Sequence< ::rtl::OUString > aRepositoryList;
+    ::rtl::OUString aGitID;
     ::rtl::OUString aInstallSetID;
 
-    if( ! ( getBootstrapData(aRepositoryList, aInstallSetID) && (aRepositoryList.getLength() > 0) ) )
+    if( ! ( getBootstrapData(aRepositoryList, aGitID, aInstallSetID) && (aRepositoryList.getLength() > 0) ) )
         return false;
 
     return checkForUpdates( o_rUpdateInfo, rxContext, rxInteractionHandler, rUpdateInfoProvider,
             myOS, myArch,
-            aRepositoryList, aInstallSetID );
+            aRepositoryList, aGitID, aInstallSetID );
 }
 
 bool
@@ -116,6 +123,7 @@ checkForUpdates(
     const rtl::OUString &rOS,
     const rtl::OUString &rArch,
     const uno::Sequence< rtl::OUString > &rRepositoryList,
+    const rtl::OUString &rGitID,
     const rtl::OUString &rInstallSetID )
 {
     if( !rxContext.is() )
@@ -147,6 +155,8 @@ checkForUpdates(
         aBuffer.append( rOS );
         aBuffer.appendAscii("\' and inst:arch=\'");
         aBuffer.append( rArch );
+        aBuffer.appendAscii("\' and inst:gitid!=\'");
+        aBuffer.append( rGitID );
         aBuffer.appendAscii("\']");
 
         rtl::OUString aXPathExpression = aBuffer.makeStringAndClear();
diff --git a/extensions/source/update/check/updateprotocol.hxx b/extensions/source/update/check/updateprotocol.hxx
index e155837..510f8f9 100644
--- a/extensions/source/update/check/updateprotocol.hxx
+++ b/extensions/source/update/check/updateprotocol.hxx
@@ -51,6 +51,7 @@ checkForUpdates(
     const rtl::OUString &rOS,
     const rtl::OUString &rArch,
     const ::com::sun::star::uno::Sequence< rtl::OUString > &rRepositoryList,
+    const rtl::OUString &rGitID,
     const rtl::OUString &rInstallID
 );
 


More information about the Libreoffice-commits mailing list