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
e98fbca5
Kaydet (Commit)
e98fbca5
authored
Haz 04, 2014
tarafından
David Tardon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add unit test for writerperfect::DirectoryStream
Change-Id: I53aaf2355d9f3071544ebcaaee01bd44a30f88fc
üst
72d7d1f3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
160 additions
and
1 deletion
+160
-1
CppunitTest_writerperfect_stream.mk
writerperfect/CppunitTest_writerperfect_stream.mk
+3
-1
DirectoryStreamTest.cxx
writerperfect/qa/unit/DirectoryStreamTest.cxx
+148
-0
manifest.xml
...erfect/qa/unit/data/stream/test.dir/META-INF/manifest.xml
+1
-0
thumbnail.png
...ect/qa/unit/data/stream/test.dir/Thumbnails/thumbnail.png
+1
-0
content.xml
writerperfect/qa/unit/data/stream/test.dir/content.xml
+1
-0
manifest.rdf
writerperfect/qa/unit/data/stream/test.dir/manifest.rdf
+1
-0
meta.xml
writerperfect/qa/unit/data/stream/test.dir/meta.xml
+1
-0
mimetype
writerperfect/qa/unit/data/stream/test.dir/mimetype
+2
-0
settings.xml
writerperfect/qa/unit/data/stream/test.dir/settings.xml
+1
-0
styles.xml
writerperfect/qa/unit/data/stream/test.dir/styles.xml
+1
-0
No files found.
writerperfect/CppunitTest_writerperfect_stream.mk
Dosyayı görüntüle @
e98fbca5
...
...
@@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_stream,\
sot \
test \
tl \
ucbhelper \
unotest \
utl \
writerperfect \
...
...
@@ -52,8 +53,9 @@ $(eval $(call gb_CppunitTest_use_components,writerperfect_stream,\
))
$(eval $(call gb_CppunitTest_add_exception_objects,writerperfect_stream,\
writerperfect/qa/unit/
stream
\
writerperfect/qa/unit/
DirectoryStreamTest
\
writerperfect/qa/unit/WPXSvStreamTest \
writerperfect/qa/unit/stream \
))
# vim: set noet sw=4 ts=4:
writerperfect/qa/unit/DirectoryStreamTest.cxx
0 → 100644
Dosyayı görüntüle @
e98fbca5
/* -*- 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 <boost/scoped_ptr.hpp>
#include <cppunit/extensions/HelperMacros.h>
#include <comphelper/processfactory.hxx>
#include <ucbhelper/content.hxx>
#include <test/bootstrapfixture.hxx>
#include <writerperfect/DirectoryStream.hxx>
namespace
ucb
=
com
::
sun
::
star
::
ucb
;
namespace
uno
=
com
::
sun
::
star
::
uno
;
using
boost
::
scoped_ptr
;
using
librevenge
::
RVNGInputStream
;
using
writerperfect
::
DirectoryStream
;
namespace
{
class
DirectoryStreamTest
:
public
test
::
BootstrapFixture
{
public
:
DirectoryStreamTest
();
public
:
CPPUNIT_TEST_SUITE
(
DirectoryStreamTest
);
CPPUNIT_TEST
(
testConstruction
);
CPPUNIT_TEST
(
testDetection
);
CPPUNIT_TEST
(
testDataOperations
);
CPPUNIT_TEST
(
testStructuredOperations
);
CPPUNIT_TEST_SUITE_END
();
private
:
void
testConstruction
();
void
testDetection
();
void
testDataOperations
();
void
testStructuredOperations
();
private
:
uno
::
Reference
<
ucb
::
XContent
>
m_xDir
;
uno
::
Reference
<
ucb
::
XContent
>
m_xFile
;
uno
::
Reference
<
ucb
::
XContent
>
m_xNonexistent
;
};
static
const
char
g_aDirPath
[]
=
"/writerperfect/qa/unit/data/stream/test.dir"
;
static
const
char
g_aNondirPath
[]
=
"/writerperfect/qa/unit/data/stream/test.dir/mimetype"
;
static
const
char
g_aNonexistentPath
[]
=
"/writerperfect/qa/unit/data/stream/foo/bar"
;
DirectoryStreamTest
::
DirectoryStreamTest
()
{
const
uno
::
Reference
<
ucb
::
XCommandEnvironment
>
xCmdEnv
;
const
uno
::
Reference
<
uno
::
XComponentContext
>
xContext
(
comphelper
::
getProcessComponentContext
());
using
ucbhelper
::
Content
;
m_xDir
=
Content
(
getURLFromSrc
(
g_aDirPath
),
xCmdEnv
,
xContext
).
get
();
m_xFile
=
Content
(
getURLFromSrc
(
g_aNondirPath
),
xCmdEnv
,
xContext
).
get
();
m_xNonexistent
=
Content
(
getURLFromSrc
(
g_aNonexistentPath
),
xCmdEnv
,
xContext
).
get
();
}
void
DirectoryStreamTest
::
testConstruction
()
{
const
scoped_ptr
<
DirectoryStream
>
pDir
(
DirectoryStream
::
createForParent
(
m_xFile
));
CPPUNIT_ASSERT
(
bool
(
pDir
));
CPPUNIT_ASSERT
(
pDir
->
isStructured
());
// this should work for dirs too
const
scoped_ptr
<
DirectoryStream
>
pDir2
(
DirectoryStream
::
createForParent
(
m_xDir
));
CPPUNIT_ASSERT
(
bool
(
pDir2
));
CPPUNIT_ASSERT
(
pDir2
->
isStructured
());
// for nonexistent dirs nothing is created
const
scoped_ptr
<
DirectoryStream
>
pNondir
(
DirectoryStream
::
createForParent
(
m_xNonexistent
));
CPPUNIT_ASSERT
(
!
pNondir
);
// even if we try harder, just an empty shell is created
DirectoryStream
aNondir2
(
m_xNonexistent
);
CPPUNIT_ASSERT
(
!
aNondir2
.
isStructured
());
}
void
DirectoryStreamTest
::
testDetection
()
{
CPPUNIT_ASSERT
(
DirectoryStream
::
isDirectory
(
m_xDir
));
CPPUNIT_ASSERT
(
!
DirectoryStream
::
isDirectory
(
m_xFile
));
CPPUNIT_ASSERT
(
!
DirectoryStream
::
isDirectory
(
m_xNonexistent
));
}
void
lcl_testDataOperations
(
RVNGInputStream
&
rStream
)
{
CPPUNIT_ASSERT
(
rStream
.
isEnd
());
CPPUNIT_ASSERT_EQUAL
(
0L
,
rStream
.
tell
());
CPPUNIT_ASSERT_EQUAL
(
-
1
,
rStream
.
seek
(
0
,
librevenge
::
RVNG_SEEK_CUR
));
unsigned
long
numBytesRead
=
0
;
CPPUNIT_ASSERT
(
0
==
rStream
.
read
(
1
,
numBytesRead
));
CPPUNIT_ASSERT_EQUAL
(
0UL
,
numBytesRead
);
}
void
DirectoryStreamTest
::
testDataOperations
()
{
// data operations do not make sense on a directory -> just dummy
// impls.
DirectoryStream
aDir
(
m_xDir
);
lcl_testDataOperations
(
aDir
);
// ... and they are equally empty if we try to pass a file
DirectoryStream
aFile
(
m_xFile
);
lcl_testDataOperations
(
aFile
);
}
void
lcl_testStructuredOperations
(
RVNGInputStream
&
rStream
)
{
CPPUNIT_ASSERT
(
rStream
.
isStructured
());
scoped_ptr
<
RVNGInputStream
>
pSubstream
(
rStream
.
getSubStreamByName
(
"mimetype"
));
CPPUNIT_ASSERT
(
bool
(
pSubstream
));
// TODO: test for other operations when they are implemented =)
}
void
DirectoryStreamTest
::
testStructuredOperations
()
{
DirectoryStream
aDir
(
m_xDir
);
lcl_testStructuredOperations
(
aDir
);
scoped_ptr
<
DirectoryStream
>
pDir
(
DirectoryStream
::
createForParent
(
m_xFile
));
CPPUNIT_ASSERT
(
bool
(
pDir
));
lcl_testStructuredOperations
(
*
pDir
.
get
());
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
DirectoryStreamTest
);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
writerperfect/qa/unit/data/stream/test.dir/META-INF/manifest.xml
0 → 100644
Dosyayı görüntüle @
e98fbca5
writerperfect/qa/unit/data/stream/test.dir/Thumbnails/thumbnail.png
0 → 100644
Dosyayı görüntüle @
e98fbca5
writerperfect/qa/unit/data/stream/test.dir/content.xml
0 → 100644
Dosyayı görüntüle @
e98fbca5
writerperfect/qa/unit/data/stream/test.dir/manifest.rdf
0 → 100644
Dosyayı görüntüle @
e98fbca5
writerperfect/qa/unit/data/stream/test.dir/meta.xml
0 → 100644
Dosyayı görüntüle @
e98fbca5
writerperfect/qa/unit/data/stream/test.dir/mimetype
0 → 100644
Dosyayı görüntüle @
e98fbca5
application/vnd.oasis.opendocument.text
\ No newline at end of file
writerperfect/qa/unit/data/stream/test.dir/settings.xml
0 → 100644
Dosyayı görüntüle @
e98fbca5
writerperfect/qa/unit/data/stream/test.dir/styles.xml
0 → 100644
Dosyayı görüntüle @
e98fbca5
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