Fix ProductFileReader to parse localized summary and adapt testcases.
authorMichael Andres <ma@suse.de>
Tue, 23 Mar 2010 17:21:03 +0000 (18:21 +0100)
committerMichael Andres <ma@suse.de>
Tue, 23 Mar 2010 17:24:10 +0000 (18:24 +0100)
tests/zypp/Target_test.cc
zypp/parser/ProductFileReader.cc

index 6309c0e..cfb6ecd 100644 (file)
@@ -22,7 +22,7 @@ BOOST_AUTO_TEST_CASE(target_test)
 {
 
     filesystem::TmpDir tmp;
-    
+
     ZYpp::Ptr z = getZYpp();
 
     // create the products.d directory
@@ -31,9 +31,9 @@ BOOST_AUTO_TEST_CASE(target_test)
 
     // make it the base product
     BOOST_CHECK( symlink(tmp.path() / "/etc/products.d/product.prod", tmp.path() / "/etc/products.d/baseproduct" ) == 0 );
-    
+
     z->initializeTarget( tmp.path() );
-    
+
     BOOST_CHECK( ! z->target()->anonymousUniqueId().empty() );
     BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").isExist() );
     BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").size() > 0 );
@@ -43,4 +43,7 @@ BOOST_AUTO_TEST_CASE(target_test)
     BOOST_CHECK_EQUAL( z->target()->targetDistributionRelease(), "special_edition");
     BOOST_CHECK_EQUAL( z->target()->distributionVersion(), "10");
 
+    Target::DistributionLabel dlabel( z->target()->distributionLabel() );
+    BOOST_CHECK_EQUAL( dlabel.summary, "A cool distribution" );
+    BOOST_CHECK_EQUAL( dlabel.shortName, "" );
 }
index 0ea5f97..c6d07ff 100644 (file)
@@ -146,7 +146,8 @@ namespace zypp
             ("release",       MANDTAORY,  xml::parseDefAssign( _release ) )
             ("arch",          MANDTAORY,  xml::parseDefAssign( _pdata._arch ) )
             ("shortsummary",  OPTIONAL,   xml::parseDefAssign( _pdata._shortName ) )
-            ("summary",       OPTIONAL,   xml::parseDefAssign( _pdata._summary ) )
+            ("summary",       MULTIPLE_OPTIONAL, xml::parseDefAssign( _ttext )( "lang", _tlocale )
+                                         >>bind( &ProductNode::doneLocalizedDefault, this, _1, ref(_pdata._summary) ))
             ("productline",   OPTIONAL,   xml::parseDefAssign( _pdata._productline ) )
             ("register",      OPTIONAL)
             ("updaterepokey", OPTIONAL,   xml::parseDefAssign( _pdata._updaterepokey ) )
@@ -184,6 +185,13 @@ namespace zypp
         _pdata._upgrades.push_back( cdata );
         _upgrade = ProductFileData::Upgrade::Impl();
       }
+      /** collect localized data */
+      void doneLocalizedDefault( const xml::Node & _node, std::string & store_r )
+      {
+       // take 1st or default
+       if ( store_r.empty() || _tlocale.empty() )
+         store_r = _ttext;
+      }
 
       /** finaly */
       void done( const xml::Node & _node )
@@ -197,6 +205,9 @@ namespace zypp
         std::string             _version;
         std::string             _release;
 
+       std::string             _ttext;
+       std::string             _tlocale;
+
         ProductFileData::Upgrade::Impl _upgrade;
     };