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
9a7ca779
Kaydet (Commit)
9a7ca779
authored
Mar 05, 2014
tarafından
Markus Mohrhard
Kaydeden (comit)
Markus Mohrhard
Mar 05, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
move the export validation code to test
Change-Id: Iaafe30a1095bd5b6dac3637c394818ba8bd848ce
üst
7691532a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
67 deletions
+83
-67
bootstrapfixture.hxx
include/test/bootstrapfixture.hxx
+8
-0
qahelper.cxx
sc/qa/unit/helper/qahelper.cxx
+1
-67
bootstrapfixture.cxx
test/source/bootstrapfixture.cxx
+74
-0
No files found.
include/test/bootstrapfixture.hxx
Dosyayı görüntüle @
9a7ca779
...
...
@@ -27,6 +27,12 @@
namespace
test
{
enum
ValidationFormat
{
OOXML
,
ODF
};
// Class to do lots of heavy-lifting UNO & environment
// bootstrapping for unit tests, such that we can use
// almost an entire LibreOffice during compile - so
...
...
@@ -47,6 +53,8 @@ public:
virtual
void
setUp
();
virtual
void
tearDown
();
static
void
validate
(
const
OUString
&
rURL
,
ValidationFormat
);
};
}
...
...
sc/qa/unit/helper/qahelper.cxx
Dosyayı görüntüle @
9a7ca779
...
...
@@ -587,70 +587,6 @@ void ScBootstrapFixture::createCSVPath(const OUString& aFileBase, OUString& rCSV
rCSVPath
=
aBuffer
.
makeStringAndClear
();
}
namespace
validation
{
enum
ScValidationFormat
{
OOXML
};
}
#if HAVE_EXPORT_VALIDATION
namespace
{
void
validate
(
const
utl
::
TempFile
&
rTempFile
,
validation
::
ScValidationFormat
eFormat
)
{
OUString
aValidator
;
if
(
eFormat
==
validation
::
OOXML
)
{
aValidator
=
"officeotron "
;
}
else
return
;
utl
::
TempFile
aOutput
;
aOutput
.
EnableKillingFile
();
OUString
aOutputFile
=
aOutput
.
GetFileName
();
OUString
aInputFile
=
rTempFile
.
GetFileName
();
OUString
aCommand
=
aValidator
+
aInputFile
+
" > "
+
aOutputFile
;
system
(
OUStringToOString
(
aCommand
,
RTL_TEXTENCODING_UTF8
).
getStr
());
std
::
string
aContent
;
loadFile
(
aOutputFile
,
aContent
);
OString
aContentString
(
aContent
.
c_str
());
OUString
aContentOUString
=
OStringToOUString
(
aContentString
,
RTL_TEXTENCODING_UTF8
);
if
(
eFormat
==
validation
::
OOXML
&&
!
aContentOUString
.
isEmpty
()
)
{
// check for validation errors here
sal_Int32
nIndex
=
aContentOUString
.
lastIndexOf
(
"Grand total of errors in submitted package: "
);
if
(
nIndex
==
-
1
)
{
SAL_WARN
(
"sc"
,
"no summery line"
);
}
else
{
sal_Int32
nStartOfNumber
=
nIndex
+
std
::
strlen
(
"Grand total of errors in submitted package: "
);
OUString
aNumber
=
aContentOUString
.
copy
(
nStartOfNumber
);
sal_Int32
nErrors
=
aNumber
.
toInt32
();
OString
aMsg
(
"validation error in OOXML export: Errors: "
);
aMsg
=
aMsg
+
OString
::
number
(
nErrors
);
if
(
nErrors
)
{
SAL_WARN
(
"sc"
,
aContent
);
}
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
aMsg
.
getStr
(),
sal_Int32
(
0
),
nErrors
);
}
}
}
}
#endif
ScDocShellRef
ScBootstrapFixture
::
saveAndReload
(
ScDocShell
*
pShell
,
const
OUString
&
rFilter
,
const
OUString
&
rUserData
,
const
OUString
&
rTypeName
,
sal_uLong
nFormatType
)
...
...
@@ -678,10 +614,8 @@ ScDocShellRef ScBootstrapFixture::saveAndReload(
nFormat
=
SFX_FILTER_IMPORT
|
SFX_FILTER_USESOPTIONS
;
ScDocShellRef
xDocSh
=
load
(
aTempFile
.
GetURL
(),
rFilter
,
rUserData
,
rTypeName
,
nFormatType
,
nFormat
);
#if HAVE_EXPORT_VALIDATION
if
(
nFormatType
==
XLSX_FORMAT_TYPE
)
validate
(
aTempFile
,
validation
::
OOXML
);
#endif
validate
(
aTempFile
.
GetFileName
(),
test
::
OOXML
);
return
xDocSh
;
}
...
...
test/source/bootstrapfixture.cxx
Dosyayı görüntüle @
9a7ca779
...
...
@@ -23,6 +23,11 @@
#include <tools/resmgr.hxx>
#include <vcl/graphicfilter.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <osl/file.hxx>
#include <unotools/tempfile.hxx>
#include <boost/scoped_array.hpp>
#include <cstring>
using
namespace
::
com
::
sun
::
star
;
...
...
@@ -113,6 +118,75 @@ test::BootstrapFixture::~BootstrapFixture()
{
}
namespace
{
OString
loadFile
(
const
OUString
&
rURL
)
{
osl
::
File
aFile
(
rURL
);
osl
::
FileBase
::
RC
eStatus
=
aFile
.
open
(
osl_File_OpenFlag_Read
);
CPPUNIT_ASSERT_EQUAL
(
eStatus
,
osl
::
FileBase
::
E_None
);
sal_uInt64
nSize
;
aFile
.
getSize
(
nSize
);
boost
::
scoped_array
<
char
>
aBytes
(
new
char
[
nSize
]);
sal_uInt64
nBytesRead
;
aFile
.
read
(
aBytes
.
get
(),
nSize
,
nBytesRead
);
CPPUNIT_ASSERT_EQUAL
(
nSize
,
nBytesRead
);
OString
aContent
(
aBytes
.
get
());
return
aContent
;
}
}
void
test
::
BootstrapFixture
::
validate
(
const
OUString
&
rPath
,
test
::
ValidationFormat
eFormat
)
{
(
void
)
rPath
;
(
void
)
eFormat
;
#if HAVE_EXPORT_VALIDATION
OUString
aValidator
;
if
(
eFormat
==
test
::
OOXML
)
{
aValidator
=
"officeotron "
;
}
else
return
;
utl
::
TempFile
aOutput
;
aOutput
.
EnableKillingFile
();
OUString
aOutputFile
=
aOutput
.
GetFileName
();
OUString
aCommand
=
aValidator
+
rPath
+
" > "
+
aOutputFile
;
system
(
OUStringToOString
(
aCommand
,
RTL_TEXTENCODING_UTF8
).
getStr
());
OString
aContentString
=
loadFile
(
aOutput
.
GetURL
());
OUString
aContentOUString
=
OStringToOUString
(
aContentString
,
RTL_TEXTENCODING_UTF8
);
if
(
eFormat
==
test
::
OOXML
&&
!
aContentOUString
.
isEmpty
()
)
{
// check for validation errors here
sal_Int32
nIndex
=
aContentOUString
.
lastIndexOf
(
"Grand total of errors in submitted package: "
);
if
(
nIndex
==
-
1
)
{
SAL_WARN
(
"test"
,
"no summery line"
);
}
else
{
sal_Int32
nStartOfNumber
=
nIndex
+
std
::
strlen
(
"Grand total of errors in submitted package: "
);
OUString
aNumber
=
aContentOUString
.
copy
(
nStartOfNumber
);
sal_Int32
nErrors
=
aNumber
.
toInt32
();
OString
aMsg
(
"validation error in OOXML export: Errors: "
);
aMsg
=
aMsg
+
OString
::
number
(
nErrors
);
if
(
nErrors
)
{
SAL_WARN
(
"test"
,
aContentOUString
);
}
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
aMsg
.
getStr
(),
sal_Int32
(
0
),
nErrors
);
}
}
#endif
}
IMPL_STATIC_LINK_NOINSTANCE
(
test
::
BootstrapFixture
,
ImplInitFilterHdl
,
ConvertData
*
,
pData
)
{
...
...
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