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
9825e169
Kaydet (Commit)
9825e169
authored
Tem 23, 2014
tarafından
David Tardon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add test for swapping of GraphicObject
Change-Id: I341f52e5dfedb61130545cf30ff61e891abc7e04
üst
2a197185
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
180 additions
and
0 deletions
+180
-0
CppunitTest_svtools_graphic.mk
svtools/CppunitTest_svtools_graphic.mk
+50
-0
Module_svtools.mk
svtools/Module_svtools.mk
+1
-0
GraphicObjectTest.cxx
svtools/qa/unit/GraphicObjectTest.cxx
+129
-0
graphic.png
svtools/qa/unit/data/graphic.png
+0
-0
No files found.
svtools/CppunitTest_svtools_graphic.mk
0 → 100644
Dosyayı görüntüle @
9825e169
# -*- 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_graphic))
$(eval $(call gb_CppunitTest_use_externals,svtools_graphic,\
boost_headers \
))
$(eval $(call gb_CppunitTest_use_api,svtools_graphic, \
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,svtools_graphic))
$(eval $(call gb_CppunitTest_use_vcl,svtools_graphic))
$(eval $(call gb_CppunitTest_use_libraries,svtools_graphic, \
comphelper \
cppu \
cppuhelper \
tl \
sal \
svt \
test \
unotest \
vcl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_configuration,svtools_graphic))
$(eval $(call gb_CppunitTest_use_components,svtools_graphic,\
configmgr/source/configmgr \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
))
$(eval $(call gb_CppunitTest_add_exception_objects,svtools_graphic, \
svtools/qa/unit/GraphicObjectTest \
))
# vim: set noet sw=4 ts=4:
svtools/Module_svtools.mk
Dosyayı görüntüle @
9825e169
...
@@ -29,6 +29,7 @@ $(eval $(call gb_Module_add_l10n_targets,svtools,\
...
@@ -29,6 +29,7 @@ $(eval $(call gb_Module_add_l10n_targets,svtools,\
))
))
$(eval $(call gb_Module_add_check_targets,svtools,\
$(eval $(call gb_Module_add_check_targets,svtools,\
CppunitTest_svtools_graphic \
CppunitTest_svtools_html \
CppunitTest_svtools_html \
))
))
...
...
svtools/qa/unit/GraphicObjectTest.cxx
0 → 100644
Dosyayı görüntüle @
9825e169
/* -*- 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/extensions/HelperMacros.h>
#include "cppunit/plugin/TestPlugIn.h"
#include <svtools/grfmgr.hxx>
#include <test/bootstrapfixture.hxx>
#include <tools/stream.hxx>
#include <vcl/image.hxx>
namespace
{
class
GraphicObjectTest
:
public
test
::
BootstrapFixture
{
public
:
void
testSwap
();
private
:
DECL_LINK
(
getLinkStream
,
GraphicObject
*
);
private
:
CPPUNIT_TEST_SUITE
(
GraphicObjectTest
);
CPPUNIT_TEST
(
testSwap
);
CPPUNIT_TEST_SUITE_END
();
};
static
const
char
aGraphicFile
[]
=
"/svtools/qa/unit/data/graphic.png"
;
static
const
sal_uLong
nGraphicSizeBytes
=
4800
;
const
Graphic
lcl_loadGraphic
(
const
rtl
::
OUString
&
rUrl
)
{
const
Image
aImage
(
rUrl
);
return
Graphic
(
aImage
.
GetBitmapEx
());
}
IMPL_LINK
(
GraphicObjectTest
,
getLinkStream
,
GraphicObject
*
,
/*pGraphObj*/
)
{
return
reinterpret_cast
<
sal_IntPtr
>
(
GRFMGR_AUTOSWAPSTREAM_LINK
);
}
void
GraphicObjectTest
::
testSwap
()
{
// simple non-linked case
{
GraphicObject
aGraphObj
(
lcl_loadGraphic
(
getURLFromSrc
(
aGraphicFile
)));
CPPUNIT_ASSERT
(
!
aGraphObj
.
HasSwapStreamHdl
());
CPPUNIT_ASSERT
(
!
aGraphObj
.
IsSwappedOut
());
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj
.
GetGraphic
().
GetSizeBytes
());
// swap out
CPPUNIT_ASSERT
(
aGraphObj
.
SwapOut
());
CPPUNIT_ASSERT
(
aGraphObj
.
IsSwappedOut
());
// swap in
CPPUNIT_ASSERT
(
aGraphObj
.
SwapIn
());
CPPUNIT_ASSERT
(
!
aGraphObj
.
IsSwappedOut
());
// the data are still there
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj
.
GetGraphic
().
GetSizeBytes
());
}
// linked case
{
GraphicObject
aGraphObj
(
lcl_loadGraphic
(
getURLFromSrc
(
aGraphicFile
)));
aGraphObj
.
SetSwapStreamHdl
(
LINK
(
this
,
GraphicObjectTest
,
getLinkStream
));
CPPUNIT_ASSERT
(
aGraphObj
.
HasSwapStreamHdl
());
CPPUNIT_ASSERT
(
!
aGraphObj
.
IsSwappedOut
());
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj
.
GetGraphic
().
GetSizeBytes
());
// swap out
CPPUNIT_ASSERT
(
aGraphObj
.
SwapOut
());
CPPUNIT_ASSERT
(
aGraphObj
.
IsSwappedOut
());
// swap in
CPPUNIT_ASSERT
(
aGraphObj
.
SwapIn
());
CPPUNIT_ASSERT
(
!
aGraphObj
.
IsSwappedOut
());
// the data are still there
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj
.
GetGraphic
().
GetSizeBytes
());
}
// combination of two GraphicObjects
{
GraphicObject
aGraphObj
(
lcl_loadGraphic
(
getURLFromSrc
(
aGraphicFile
)));
GraphicObject
aGraphObj2
(
aGraphObj
);
aGraphObj2
.
SetSwapStreamHdl
(
LINK
(
this
,
GraphicObjectTest
,
getLinkStream
));
CPPUNIT_ASSERT
(
!
aGraphObj
.
IsSwappedOut
());
CPPUNIT_ASSERT
(
!
aGraphObj2
.
IsSwappedOut
());
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj
.
GetGraphic
().
GetSizeBytes
());
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj2
.
GetGraphic
().
GetSizeBytes
());
// GraphicObjects never share the same Graphic. A new one is created as one step during
// registration of the GraphicObject at GraphicManager.
// swap out
CPPUNIT_ASSERT
(
aGraphObj
.
SwapOut
());
CPPUNIT_ASSERT
(
aGraphObj
.
IsSwappedOut
());
CPPUNIT_ASSERT
(
!
aGraphObj2
.
IsSwappedOut
());
CPPUNIT_ASSERT
(
aGraphObj2
.
SwapOut
());
CPPUNIT_ASSERT
(
aGraphObj2
.
IsSwappedOut
());
// swap in
CPPUNIT_ASSERT
(
aGraphObj2
.
SwapIn
());
CPPUNIT_ASSERT
(
!
aGraphObj2
.
IsSwappedOut
());
CPPUNIT_ASSERT
(
aGraphObj
.
IsSwappedOut
());
CPPUNIT_ASSERT
(
aGraphObj
.
SwapIn
());
CPPUNIT_ASSERT
(
!
aGraphObj
.
IsSwappedOut
());
// the data are still there
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj
.
GetGraphic
().
GetSizeBytes
());
CPPUNIT_ASSERT_EQUAL
(
nGraphicSizeBytes
,
aGraphObj2
.
GetGraphic
().
GetSizeBytes
());
}
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
GraphicObjectTest
);
CPPUNIT_PLUGIN_IMPLEMENT
();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
svtools/qa/unit/data/graphic.png
0 → 100644
Dosyayı görüntüle @
9825e169
175 Bytes
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