summaryrefslogtreecommitdiff
path: root/extensions/qa/update
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-11-29 21:52:43 +0100
committerJan Holesovsky <kendy@suse.cz>2011-11-30 00:24:51 +0100
commitb87fa222f1cc58e17b57fe5ef08438520976faae (patch)
treebff41d37d327be00a6827ba3fb6742bbd94c0601 /extensions/qa/update
parent4432a44e75c2ead9b226838014a480d68f7900e9 (diff)
online update: Unit testing framework + rewrite of load().
- introduce first two basic tests (to be improved) - rewrite of UpdateInformationProvider::load() to use comphelper - smaller splitting of functions to be able to unit test
Diffstat (limited to 'extensions/qa/update')
-rw-r--r--extensions/qa/update/simple.xml10
-rw-r--r--extensions/qa/update/test_update.cxx94
2 files changed, 89 insertions, 15 deletions
diff --git a/extensions/qa/update/simple.xml b/extensions/qa/update/simple.xml
new file mode 100644
index 000000000000..6a6af1280b87
--- /dev/null
+++ b/extensions/qa/update/simple.xml
@@ -0,0 +1,10 @@
+<?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:os>Linux</inst:os>
+ <inst:arch>x86</inst:arch>
+
+ <inst:update type="text/html" src="http://www.libreoffice.org/download/" />
+</inst:description>
diff --git a/extensions/qa/update/test_update.cxx b/extensions/qa/update/test_update.cxx
index d699da999bd5..57ff71cc40a1 100644
--- a/extensions/qa/update/test_update.cxx
+++ b/extensions/qa/update/test_update.cxx
@@ -27,6 +27,7 @@
#include <sal/config.h>
#include <sal/precppunit.hxx>
+#include <test/bootstrapfixture.hxx>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
@@ -35,7 +36,9 @@
#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/deployment/UpdateInformationEntry.hpp>
#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
+#include <com/sun/star/xml/dom/XNodeList.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -43,50 +46,111 @@
#include "../../source/update/check/updateprotocol.hxx"
using namespace com::sun::star;
+using namespace com::sun::star::xml;
namespace testupdate {
-class Test : public CppUnit::TestFixture
+class Test : public test::BootstrapFixture
{
public:
- void setUp()
+ virtual void setUp()
{
- if (!m_xContext.is())
- m_xContext = cppu::defaultBootstrap_InitialComponentContext();
+ // so that comphelper::getProcessServiceFactory() works, m_xContext is
+ // set up, etc.
+ test::BootstrapFixture::setUp();
+
+ if ( !m_xProvider.is() )
+ m_xProvider = deployment::UpdateInformationProvider::create( m_xContext );
+
+ // repositories that we will be checking
+ m_aRepositoryList.realloc( 1 );
+ m_aRepositoryList[0] = getURLFromSrc( "/extensions/qa/update/simple.xml" );
}
- void tearDown()
+ virtual void tearDown()
{
- uno::Reference< lang::XComponent >( m_xContext, uno::UNO_QUERY_THROW)->dispose();
+ m_xProvider.clear();
+ m_aRepositoryList.realloc( 0 );
+ test::BootstrapFixture::tearDown();
}
protected:
+ // test the getUpdateInformationEnumeration() method
+ void testGetUpdateInformationEnumeration()
+ {
+ ::rtl::OUString aInstallSetID( RTL_CONSTASCII_USTRINGPARAM( "TODO" ) ); // unused when we do not have a 'feed'
+
+ uno::Reference< container::XEnumeration > aUpdateInfoEnumeration =
+ m_xProvider->getUpdateInformationEnumeration( m_aRepositoryList, aInstallSetID );
+
+ if ( !aUpdateInfoEnumeration.is() )
+ CPPUNIT_FAIL( "Calling getUpdateInformationEnumeration() with TODO failed." );
+
+ if ( !aUpdateInfoEnumeration->hasMoreElements() )
+ CPPUNIT_FAIL( "Should have more elements (this one is 1st)." );
+
+ deployment::UpdateInformationEntry aEntry;
+ if ( aUpdateInfoEnumeration->nextElement() >>= aEntry )
+ {
+ CPPUNIT_ASSERT( aEntry.UpdateDocument->getNodeName() == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "description" ) ) );
+
+ uno::Reference< dom::XNodeList> xChildNodes = aEntry.UpdateDocument->getChildNodes();
+ CPPUNIT_ASSERT( xChildNodes.is() );
+#if 0
+ for ( int i = 0; i < xChildNodes->getLength(); ++i )
+ {
+ fprintf( stderr, "node == %d\n", i );
+ uno::Reference< dom::XElement > xChildId( xChildNodes->item( i ), uno::UNO_QUERY );
+ if ( xChildId.is() )
+ {
+ fprintf( stderr, "Name == %s\n", rtl::OUStringToOString( xChildId->getNodeName(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ fprintf( stderr, "Value == %s\n", rtl::OUStringToOString( xChildId->getNodeValue(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ }
+#endif
+ CPPUNIT_ASSERT( xChildNodes->getLength() == 13 );
+
+ //uno::Reference< dom::XElement > xChildId( xChildNodes->item( 0 ), uno::UNO_QUERY );
+ //CPPUNIT_ASSERT( xChildId.is() );
+ //CPPUNIT_ASSERT( xChildId->getNodeValue() == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LibreOffice_3.4" ) ) );
+ //fprintf( stderr, "Attribute == %s\n", rtl::OUStringToOString( aEntry.UpdateDocument->getAttribute( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "test" ) ) ), RTL_TEXTENCODING_UTF8 ).getStr() );
+ //fprintf( stderr, "Value == %s\n", rtl::OUStringToOString( xChildId->getNodeValue(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ // TODO check more deeply
+ }
+ else
+ CPPUNIT_FAIL( "Wrong type of the entry." );
+ }
+
// test the checkForUpdates() method
void testCheckForUpdates()
{
-
UpdateInfo aInfo;
rtl::Reference< UpdateCheck > aController( UpdateCheck::get() );
- uno::Reference< deployment::XUpdateInformationProvider > m_xProvider( deployment::UpdateInformationProvider::create( m_xContext ) );
- if ( checkForUpdates( aInfo, m_xContext, aController->getInteractionHandler(), m_xProvider ) )
+ if ( checkForUpdates( aInfo, m_xContext, aController->getInteractionHandler(), m_xProvider,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OS" ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Arch" ) ),
+ m_aRepositoryList,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BuildID" ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InstallSetID" ) ) ) )
{
- aController->setUpdateInfo( aInfo );
+ //aController->setUpdateInfo( aInfo );
+ // TODO check the result
}
else
- CPPUNIT_FAIL("Calling checkForUpdates() failed.");
+ CPPUNIT_FAIL( "Calling checkForUpdates() failed." );
}
CPPUNIT_TEST_SUITE(Test);
- // FIXME CPPUNIT_TEST(testCheckForUpdates);
+ CPPUNIT_TEST(testGetUpdateInformationEnumeration);
+ CPPUNIT_TEST(testCheckForUpdates);
CPPUNIT_TEST_SUITE_END();
private:
- static uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< deployment::XUpdateInformationProvider > m_xProvider;
+ uno::Sequence< rtl::OUString > m_aRepositoryList;
};
-uno::Reference< uno::XComponentContext > Test::m_xContext;
-
CPPUNIT_TEST_SUITE_REGISTRATION(testupdate::Test);
} // namespace testupdate