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
c7b69624
Kaydet (Commit)
c7b69624
authored
Mar 16, 2014
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Introduce HtmlWriter unit tests.
Change-Id: Icb39dde433124d444c48761e074f6b839a043d4e
üst
2480ded8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
206 additions
and
0 deletions
+206
-0
CppunitTest_svtools_html.mk
svtools/CppunitTest_svtools_html.mk
+33
-0
Module_svtools.mk
svtools/Module_svtools.mk
+4
-0
testHtmlWriter.cxx
svtools/qa/unit/testHtmlWriter.cxx
+169
-0
No files found.
svtools/CppunitTest_svtools_html.mk
0 → 100644
Dosyayı görüntüle @
c7b69624
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,svtools_html))
$(eval $(call gb_CppunitTest_use_external,svtools_html,boost_headers))
$(eval $(call gb_CppunitTest_use_api,svtools_html, \
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_add_exception_objects,svtools_html, \
svtools/qa/unit/testHtmlWriter \
))
$(eval $(call gb_CppunitTest_use_libraries,svtools_html, \
comphelper \
cppu \
cppuhelper \
tl \
sal \
svt \
$(gb_UWINAPI) \
))
# vim: set noet sw=4 ts=4:
svtools/Module_svtools.mk
Dosyayı görüntüle @
c7b69624
...
...
@@ -28,6 +28,10 @@ $(eval $(call gb_Module_add_l10n_targets,svtools,\
UIConfig_svt \
))
$(eval $(call gb_Module_add_check_targets,svtools,\
CppunitTest_svtools_html \
))
ifeq ($(CROSS_COMPILING),)
ifneq ($(OS),WNT)
...
...
svtools/qa/unit/testHtmlWriter.cxx
0 → 100644
Dosyayı görüntüle @
c7b69624
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include "cppunit/TestCase.h"
#include "cppunit/TestFixture.h"
#include "cppunit/TestSuite.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include <tools/stream.hxx>
#include <svtools/HtmlWriter.hxx>
namespace
{
OString
extractFromStream
(
SvMemoryStream
&
rStream
)
{
rStream
.
WriteChar
(
'\0'
);
rStream
.
Flush
();
rStream
.
Seek
(
STREAM_SEEK_TO_BEGIN
);
return
OString
((
const
sal_Char
*
)
rStream
.
GetBuffer
());
}
}
class
Test
:
public
CppUnit
::
TestFixture
{
public
:
virtual
void
setUp
();
void
testSingleElement
();
void
testSingleElementWithAttributes
();
void
testSingleElementWithContent
();
void
testSingleElementWithContentAndAttributes
();
void
testNested
();
CPPUNIT_TEST_SUITE
(
Test
);
CPPUNIT_TEST
(
testSingleElement
);
CPPUNIT_TEST
(
testSingleElementWithAttributes
);
CPPUNIT_TEST
(
testSingleElementWithContent
);
CPPUNIT_TEST
(
testSingleElementWithContentAndAttributes
);
CPPUNIT_TEST
(
testNested
);
CPPUNIT_TEST_SUITE_END
();
};
void
Test
::
setUp
()
{}
void
Test
::
testSingleElement
()
{
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
start
(
"abc"
);
aHtml
.
end
();
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
aString
,
OString
(
"<abc/>"
));
}
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
single
(
"abc"
);
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
aString
,
OString
(
"<abc/>"
));
}
}
void
Test
::
testSingleElementWithAttributes
()
{
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
start
(
"abc"
);
aHtml
.
attribute
(
"x"
,
"y"
);
aHtml
.
end
();
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
aString
,
OString
(
"<abc x=
\"
y
\"
/>"
));
}
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
start
(
"abc"
);
aHtml
.
attribute
(
"x"
,
"y"
);
aHtml
.
attribute
(
"q"
,
"w"
);
aHtml
.
end
();
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
aString
,
OString
(
"<abc x=
\"
y
\"
q=
\"
w
\"
/>"
));
}
}
void
Test
::
testSingleElementWithContent
()
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
start
(
"abc"
);
aHtml
.
write
(
"xxxx"
);
aHtml
.
end
();
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
aString
,
OString
(
"<abc>xxxx</abc>"
));
}
void
Test
::
testSingleElementWithContentAndAttributes
()
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
start
(
"abc"
);
aHtml
.
attribute
(
"x"
,
"y"
);
aHtml
.
attribute
(
"q"
,
"w"
);
aHtml
.
write
(
"xxxx"
);
aHtml
.
end
();
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
aString
,
OString
(
"<abc x=
\"
y
\"
q=
\"
w
\"
>xxxx</abc>"
));
}
void
Test
::
testNested
()
{
SvMemoryStream
aStream
;
HtmlWriter
aHtml
(
aStream
);
aHtml
.
prettyPrint
(
false
);
aHtml
.
start
(
"abc"
);
aHtml
.
start
(
"xyz"
);
aHtml
.
write
(
"xxx"
);
aHtml
.
end
();
aHtml
.
end
();
OString
aString
=
extractFromStream
(
aStream
);
CPPUNIT_ASSERT_EQUAL
(
OString
(
"<abc><xyz>xxx</xyz></abc>"
),
aString
);
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
Test
);
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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