Kaydet (Commit) 20caa9a3 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

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.
üst bc4699ba
<?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>
......
......@@ -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:
......
......@@ -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.isEmpty() )
......@@ -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();
......
......@@ -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
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment