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
c454a0cd
Kaydet (Commit)
c454a0cd
authored
Kas 07, 2014
tarafından
Zolnai Tamás
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test for size based auto swap out mechanism
Change-Id: Iff0942b9b545f27dd74b73bee3f8ac785539867d
üst
f3ff1195
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
2 deletions
+142
-2
CppunitTest_svtools_graphic.mk
svtools/CppunitTest_svtools_graphic.mk
+36
-0
GraphicObjectTest.cxx
svtools/qa/unit/GraphicObjectTest.cxx
+106
-2
document_with_two_images.odt
svtools/qa/unit/data/document_with_two_images.odt
+0
-0
No files found.
svtools/CppunitTest_svtools_graphic.mk
Dosyayı görüntüle @
c454a0cd
...
...
@@ -11,6 +11,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,svtools_graphic))
$(eval $(call gb_CppunitTest_use_externals,svtools_graphic,\
boost_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_use_api,svtools_graphic, \
...
...
@@ -29,18 +30,53 @@ $(eval $(call gb_CppunitTest_use_libraries,svtools_graphic, \
tl \
sal \
svt \
sw \
test \
unotest \
vcl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_set_include,svtools_graphic,\
-I$(SRCDIR)/sw/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_custom_headers,svtools_graphic,\
officecfg/registry \
))
$(eval $(call gb_CppunitTest_use_configuration,svtools_graphic))
$(eval $(call gb_CppunitTest_use_components,svtools_graphic,\
basic/util/sb \
comphelper/util/comphelp \
configmgr/source/configmgr \
embeddedobj/util/embobj \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
framework/util/fwk \
i18npool/util/i18npool \
linguistic/source/lng \
oox/util/oox \
package/source/xstor/xstor \
package/util/package2 \
sax/source/expatwrap/expwrap \
sfx2/util/sfx \
starmath/util/sm \
svl/source/fsstor/fsstorage \
svtools/util/svt \
sw/util/sw \
sw/util/swd \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
unotools/util/utl \
unoxml/source/service/unoxml \
uui/util/uui \
writerfilter/util/writerfilter \
$(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \
xmloff/util/xo \
))
$(eval $(call gb_CppunitTest_add_exception_objects,svtools_graphic, \
...
...
svtools/qa/unit/GraphicObjectTest.cxx
Dosyayı görüntüle @
c454a0cd
...
...
@@ -19,21 +19,42 @@
#include <vcl/image.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <officecfg/Office/Common.hxx>
#include <unotest/macros_test.hxx>
#include <comphelper/processfactory.hxx>
#include <unotxdoc.hxx>
#include <docsh.hxx>
#include <doc.hxx>
#include <ndgrf.hxx>
#include <boost/shared_ptr.hpp>
using
namespace
css
;
namespace
{
class
GraphicObjectTest
:
public
test
::
BootstrapFixture
class
GraphicObjectTest
:
public
test
::
BootstrapFixture
,
public
unotest
::
MacrosTest
{
public
:
void
testSwap
();
void
testSizeBasedAutoSwap
();
virtual
void
setUp
()
SAL_OVERRIDE
{
test
::
BootstrapFixture
::
setUp
();
mxDesktop
.
set
(
css
::
frame
::
Desktop
::
create
(
comphelper
::
getComponentContext
(
getMultiServiceFactory
())));
}
private
:
DECL_LINK
(
getLinkStream
,
GraphicObject
*
);
private
:
CPPUNIT_TEST_SUITE
(
GraphicObjectTest
);
CPPUNIT_TEST
(
testSwap
);
CPPUNIT_TEST
(
testS
izeBasedAutoS
wap
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -120,6 +141,89 @@ void GraphicObjectTest::testSwap()
}
}
void
GraphicObjectTest
::
testSizeBasedAutoSwap
()
{
// Set cache size to a very small value to check what happens
{
boost
::
shared_ptr
<
comphelper
::
ConfigurationChanges
>
aBatch
(
comphelper
::
ConfigurationChanges
::
create
());
officecfg
::
Office
::
Common
::
Cache
::
GraphicManager
::
TotalCacheSize
::
set
(
sal_Int32
(
1
),
aBatch
);
aBatch
->
commit
();
}
uno
::
Reference
<
lang
::
XComponent
>
xComponent
=
loadFromDesktop
(
getURLFromSrc
(
"svtools/qa/unit/data/document_with_two_images.odt"
),
"com.sun.star.text.TextDocument"
);
SwXTextDocument
*
pTxtDoc
=
dynamic_cast
<
SwXTextDocument
*>
(
xComponent
.
get
());
CPPUNIT_ASSERT
(
pTxtDoc
);
SwDoc
*
pDoc
=
pTxtDoc
->
GetDocShell
()
->
GetDoc
();
CPPUNIT_ASSERT
(
pDoc
);
SwNodes
&
aNodes
=
pDoc
->
GetNodes
();
// Find images
const
GraphicObject
*
pGrafObj1
=
0
;
const
GraphicObject
*
pGrafObj2
=
0
;
for
(
sal_uLong
nIndex
=
0
;
nIndex
<
aNodes
.
Count
();
++
nIndex
)
{
if
(
aNodes
[
nIndex
]
->
IsGrfNode
()
)
{
SwGrfNode
*
pGrfNode
=
aNodes
[
nIndex
]
->
GetGrfNode
();
if
(
!
pGrafObj1
)
{
pGrafObj1
=
&
pGrfNode
->
GetGrfObj
();
}
else
{
pGrafObj2
=
&
pGrfNode
->
GetGrfObj
();
}
}
}
CPPUNIT_ASSERT_MESSAGE
(
"Missing image"
,
pGrafObj1
!=
0
&&
pGrafObj2
!=
0
);
{
// First image should be swapped out
CPPUNIT_ASSERT
(
pGrafObj1
->
IsSwappedOut
());
CPPUNIT_ASSERT_EQUAL
(
sal_uLong
(
697230
),
pGrafObj1
->
GetSizeBytes
());
// Still swapped out: size is cached
CPPUNIT_ASSERT
(
pGrafObj1
->
IsSwappedOut
());
}
{
// Second image should be in the memory
// Size based swap out is triggered by swap in, so the last swapped in image should be
// in the memory despite of size limit is reached.
CPPUNIT_ASSERT
(
!
pGrafObj2
->
IsSwappedOut
());
CPPUNIT_ASSERT_EQUAL
(
sal_uLong
(
1620000
),
pGrafObj2
->
GetSizeBytes
());
}
// Swap in first image -> second image will be swapped out
{
pGrafObj1
->
GetGraphic
();
// GetGraphic calls swap in on a const object
CPPUNIT_ASSERT
(
!
pGrafObj1
->
IsSwappedOut
());
CPPUNIT_ASSERT
(
pGrafObj2
->
IsSwappedOut
());
}
// Swap in second image -> first image will be swapped out
{
pGrafObj2
->
GetGraphic
();
// GetGraphic calls swap in on a const object
CPPUNIT_ASSERT
(
!
pGrafObj2
->
IsSwappedOut
());
CPPUNIT_ASSERT
(
pGrafObj1
->
IsSwappedOut
());
}
// Use bigger cache
{
GraphicManager
&
rGrfMgr
=
pGrafObj1
->
GetGraphicManager
();
rGrfMgr
.
SetMaxCacheSize
(
pGrafObj1
->
GetSizeBytes
()
+
pGrafObj2
->
GetSizeBytes
());
}
// Swap in both images -> both should be swapped in
{
pGrafObj1
->
GetGraphic
();
pGrafObj2
->
GetGraphic
();
CPPUNIT_ASSERT
(
!
pGrafObj1
->
IsSwappedOut
());
CPPUNIT_ASSERT
(
!
pGrafObj2
->
IsSwappedOut
());
}
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
GraphicObjectTest
);
}
...
...
svtools/qa/unit/data/document_with_two_images.odt
0 → 100644
Dosyayı görüntüle @
c454a0cd
File added
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