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
07254e70
Kaydet (Commit)
07254e70
authored
Tem 13, 2015
tarafından
Michael Meeks
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
tdf#93532 - Bitmap CRC unit tests.
Change-Id: Ic75801d7ad941ba802ffe418d5c666b1e7b0e94f
üst
d3dbbf09
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
BitmapTest.cxx
vcl/qa/cppunit/BitmapTest.cxx
+56
-0
No files found.
vcl/qa/cppunit/BitmapTest.cxx
Dosyayı görüntüle @
07254e70
...
...
@@ -12,9 +12,13 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <unordered_map>
#include <vcl/bitmap.hxx>
#include <vcl/bmpacc.hxx>
#include <vcl/virdev.hxx>
#include <rtl/strbuf.hxx>
#include <tools/stream.hxx>
#include <vcl/graphicfilter.hxx>
...
...
@@ -27,10 +31,12 @@ class BitmapTest : public CppUnit::TestFixture
{
void
testConvert
();
void
testScale
();
void
testCRC
();
CPPUNIT_TEST_SUITE
(
BitmapTest
);
CPPUNIT_TEST
(
testConvert
);
CPPUNIT_TEST
(
testScale
);
CPPUNIT_TEST
(
testCRC
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -129,6 +135,56 @@ void BitmapTest::testScale()
}
}
typedef
std
::
unordered_map
<
sal_uInt64
,
const
char
*>
CRCHash
;
void
checkAndInsert
(
CRCHash
&
rHash
,
sal_uInt64
nCRC
,
const
char
*
pLocation
)
{
auto
it
=
rHash
.
find
(
nCRC
);
if
(
it
!=
rHash
.
end
())
{
OStringBuffer
aBuf
(
"CRC collision between "
);
aBuf
.
append
(
pLocation
);
aBuf
.
append
(
" and "
);
aBuf
.
append
(
it
->
second
);
aBuf
.
append
(
" hash is 0x"
);
aBuf
.
append
((
sal_Int64
)
nCRC
,
16
);
CPPUNIT_FAIL
(
aBuf
.
toString
().
getStr
());
}
rHash
[
nCRC
]
=
pLocation
;
}
void
checkAndInsert
(
CRCHash
&
rHash
,
Bitmap
rBmp
,
const
char
*
pLocation
)
{
checkAndInsert
(
rHash
,
rBmp
.
GetChecksum
(),
pLocation
);
}
Bitmap
getAsBitmap
(
VclPtr
<
OutputDevice
>
pOut
)
{
return
pOut
->
GetBitmap
(
Point
(),
pOut
->
GetOutputSizePixel
());
}
void
BitmapTest
::
testCRC
()
{
CRCHash
aCRCs
;
Bitmap
aBitmap
(
Size
(
1023
,
759
),
24
,
0
);
aBitmap
.
Erase
(
COL_BLACK
);
checkAndInsert
(
aCRCs
,
aBitmap
,
"black bitmap"
);
aBitmap
.
Invert
();
checkAndInsert
(
aCRCs
,
aBitmap
,
"white bitmap"
);
ScopedVclPtrInstance
<
VirtualDevice
>
aVDev
;
aVDev
->
SetOutputSizePixel
(
Size
(
1023
,
759
));
Bitmap
aWhiteCheck
=
getAsBitmap
(
aVDev
);
CPPUNIT_ASSERT
(
aCRCs
.
find
(
aWhiteCheck
.
GetChecksum
())
!=
aCRCs
.
end
());
// a 1x1 black & white checkerboard
aVDev
->
DrawCheckered
(
Point
(),
aVDev
->
GetOutputSizePixel
(),
1
,
1
);
Bitmap
aChecker
=
getAsBitmap
(
aVDev
);
checkAndInsert
(
aCRCs
,
aChecker
,
"checkerboard"
);
aChecker
.
Invert
();
checkAndInsert
(
aCRCs
,
aChecker
,
"inverted checkerboard"
);
}
}
// namespace
CPPUNIT_TEST_SUITE_REGISTRATION
(
BitmapTest
);
...
...
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