Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e674cd3f
Kaydet (Commit)
e674cd3f
authored
Tem 19, 2014
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
use the shared XPath test code in chart2
Change-Id: Ia8481516eb3d53f406824cc2ef8873fe1cba3909
üst
e566d0e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
92 deletions
+28
-92
chart2export.cxx
chart2/qa/extras/chart2export.cxx
+28
-92
No files found.
chart2/qa/extras/chart2export.cxx
Dosyayı görüntüle @
e674cd3f
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#include "charttest.hxx"
#include "charttest.hxx"
#include <test/xmltesttools.hxx>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
...
@@ -27,8 +29,11 @@
...
@@ -27,8 +29,11 @@
using
uno
::
Reference
;
using
uno
::
Reference
;
using
beans
::
XPropertySet
;
using
beans
::
XPropertySet
;
class
Chart2ExportTest
:
public
ChartTest
class
Chart2ExportTest
:
public
ChartTest
,
public
XmlTestTools
{
{
protected
:
virtual
void
registerNamespaces
(
xmlXPathContextPtr
&
pXmlXPathCtx
);
public
:
public
:
Chart2ExportTest
()
:
ChartTest
()
{}
Chart2ExportTest
()
:
ChartTest
()
{}
void
test
();
void
test
();
...
@@ -108,38 +113,6 @@ protected:
...
@@ -108,38 +113,6 @@ protected:
*/
*/
xmlDocPtr
parseExport
(
const
OUString
&
rDir
,
const
OUString
&
rFilterFormat
);
xmlDocPtr
parseExport
(
const
OUString
&
rDir
,
const
OUString
&
rFilterFormat
);
/**
* Helper method to return nodes represented by rXPath.
*/
xmlNodeSetPtr
getXPathNode
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
);
/**
* Assert that rXPath exists, and returns exactly one node.
* In case rAttribute is provided, the rXPath's attribute's value must
* equal to the rExpected value.
*/
void
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
=
OString
(),
const
OUString
&
rExpectedValue
=
OUString
());
/**
* Assert that rXPath exists, and returns exactly nNumberOfNodes nodes.
* Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
*/
void
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
int
nNumberOfNodes
);
/**
* Same as the assertXPath(), but don't assert: return the string instead.
*/
OUString
getXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
);
/**
Assert that rXPath exists, and its content equals rContent.
*/
void
assertXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OUString
&
rContent
);
/**
Same as the assertXPathContent(), but don't assert: return the string instead.
*/
OUString
getXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
);
private
:
};
};
void
Chart2ExportTest
::
test
()
void
Chart2ExportTest
::
test
()
...
@@ -201,65 +174,27 @@ xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rF
...
@@ -201,65 +174,27 @@ xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rF
return
xmlParseMemory
((
const
char
*
)
aDocument
.
getStr
(),
aDocument
.
getLength
());
return
xmlParseMemory
((
const
char
*
)
aDocument
.
getStr
(),
aDocument
.
getLength
());
}
}
xmlNodeSetPtr
Chart2ExportTest
::
getXPathNode
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
)
void
Chart2ExportTest
::
registerNamespaces
(
xmlXPathContextPtr
&
pXmlXPathCtx
)
{
{
xmlXPathContextPtr
pXmlXpathCtx
=
xmlXPathNewContext
(
pXmlDoc
);
struct
{
xmlChar
*
pPrefix
;
xmlChar
*
pURI
;
}
aNamespaces
[]
=
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"w"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
));
{
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"v"
),
BAD_CAST
(
"urn:schemas-microsoft-com:vml"
));
{
BAD_CAST
(
"w"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
)
},
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"c"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/chart"
));
{
BAD_CAST
(
"v"
),
BAD_CAST
(
"urn:schemas-microsoft-com:vml"
)
},
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"a"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/main"
));
{
BAD_CAST
(
"c"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/chart"
)
},
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"mc"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/markup-compatibility/2006"
));
{
BAD_CAST
(
"a"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/main"
)
},
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"wps"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
));
{
BAD_CAST
(
"mc"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/markup-compatibility/2006"
)
},
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"wpg"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
));
{
BAD_CAST
(
"wps"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
)
},
xmlXPathRegisterNs
(
pXmlXpathCtx
,
BAD_CAST
(
"wp"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
));
{
BAD_CAST
(
"wpg"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
)
},
xmlXPathObjectPtr
pXmlXpathObj
=
xmlXPathEvalExpression
(
BAD_CAST
(
rXPath
.
getStr
()),
pXmlXpathCtx
);
{
BAD_CAST
(
"wp"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
)
},
return
pXmlXpathObj
->
nodesetval
;
{
BAD_CAST
(
"office"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
)
},
}
{
BAD_CAST
(
"table"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
)
},
{
BAD_CAST
(
"text"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
)
},
void
Chart2ExportTest
::
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
,
const
OUString
&
rExpectedValue
)
{
BAD_CAST
(
"xlink"
),
BAD_CAST
(
"http://www.w3c.org/1999/xlink"
)
}
{
};
OUString
aValue
=
getXPath
(
pXmlDoc
,
rXPath
,
rAttribute
);
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aNamespaces
);
++
i
)
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
{
OString
(
"Attribute '"
+
rAttribute
+
"' of '"
+
rXPath
+
"' incorrect value."
).
getStr
(),
xmlXPathRegisterNs
(
pXmlXPathCtx
,
aNamespaces
[
i
].
pPrefix
,
aNamespaces
[
i
].
pURI
);
rExpectedValue
,
aValue
);
}
}
void
Chart2ExportTest
::
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
int
nNumberOfNodes
)
{
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
rXPath
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
OString
(
"XPath '"
+
rXPath
+
"' number of nodes is incorrect"
).
getStr
(),
nNumberOfNodes
,
xmlXPathNodeSetGetLength
(
pXmlNodes
));
}
void
Chart2ExportTest
::
assertXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OUString
&
rContent
)
{
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"XPath contents of child does not match"
,
rContent
,
getXPathContent
(
pXmlDoc
,
rXPath
));
}
OUString
Chart2ExportTest
::
getXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
)
{
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
rXPath
);
CPPUNIT_ASSERT_MESSAGE
(
OString
(
"XPath '"
+
rXPath
+
"' not found"
).
getStr
(),
xmlXPathNodeSetGetLength
(
pXmlNodes
)
>
0
);
xmlNodePtr
pXmlNode
=
pXmlNodes
->
nodeTab
[
0
];
_xmlNode
*
pNode
=
&
(
pXmlNode
->
children
[
0
]);
return
pNode
?
OUString
::
createFromAscii
((
const
char
*
)((
pXmlNode
->
children
[
0
]).
content
))
:
OUString
();
}
OUString
Chart2ExportTest
::
getXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
)
{
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
rXPath
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
OString
(
"XPath '"
+
rXPath
+
"' number of nodes is incorrect"
).
getStr
(),
1
,
xmlXPathNodeSetGetLength
(
pXmlNodes
));
if
(
rAttribute
.
isEmpty
())
return
OUString
();
xmlNodePtr
pXmlNode
=
pXmlNodes
->
nodeTab
[
0
];
return
OUString
::
createFromAscii
((
const
char
*
)
xmlGetProp
(
pXmlNode
,
BAD_CAST
(
rAttribute
.
getStr
())));
}
}
namespace
{
namespace
{
...
@@ -584,7 +519,8 @@ void Chart2ExportTest::testChartExternalData()
...
@@ -584,7 +519,8 @@ void Chart2ExportTest::testChartExternalData()
xmlDocPtr
pXmlDoc
=
parseExport
(
"word/charts/chart"
,
"Office Open XML Text"
);
xmlDocPtr
pXmlDoc
=
parseExport
(
"word/charts/chart"
,
"Office Open XML Text"
);
CPPUNIT_ASSERT
(
pXmlDoc
);
CPPUNIT_ASSERT
(
pXmlDoc
);
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
"/c:chartSpace/c:externalData"
);
xmlXPathObjectPtr
pXmlPathObj
=
getXPathNode
(
pXmlDoc
,
"/c:chartSpace/c:externalData"
);
xmlNodeSetPtr
pXmlNodes
=
pXmlPathObj
->
nodesetval
;
CPPUNIT_ASSERT
(
pXmlNodes
);
CPPUNIT_ASSERT
(
pXmlNodes
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment