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
13184da2
Kaydet (Commit)
13184da2
authored
Haz 30, 2016
tarafından
Katarina Behrens
Kaydeden (comit)
Thorsten Behrens
Agu 18, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
screenshots: move shared code to separate class
Change-Id: I1760de221bc53d345c2bbfb4fe878c120073ea45
üst
2e288225
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
0 deletions
+142
-0
screenshot_test.hxx
include/test/screenshot_test.hxx
+39
-0
Library_test.mk
test/Library_test.mk
+1
-0
screenshot_test.cxx
test/source/screenshot_test.cxx
+102
-0
No files found.
include/test/screenshot_test.hxx
0 → 100644
Dosyayı görüntüle @
13184da2
/* -*- 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/.
*/
#ifndef INCLUDED_TEST_SCREENSHOT_TEST_HXX
#define INCLUDED_TEST_SCREENSHOT_TEST_HXX
#include <sal/config.h>
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <osl/file.hxx>
class
VclAbstractDialog
;
class
OOO_DLLPUBLIC_TEST
ScreenshotTest
:
public
test
::
BootstrapFixture
,
public
unotest
::
MacrosTest
{
public
:
ScreenshotTest
();
virtual
void
setUp
()
override
;
virtual
void
tearDown
()
override
;
void
dumpDialogToPath
(
VclAbstractDialog
&
rDialog
);
private
:
void
saveScreenshot
(
VclAbstractDialog
&
rDialog
);
OUString
m_aScreenshotDirectory
;
};
#endif // INCLUDED_TEST_SCREENSHOT_TEST_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
test/Library_test.mk
Dosyayı görüntüle @
13184da2
...
...
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/mtfxmldump \
test/source/xmlwriter \
test/source/primitive2dxmldump \
test/source/screenshot_test \
))
# vim: set noet sw=4 ts=4:
test/source/screenshot_test.cxx
0 → 100644
Dosyayı görüntüle @
13184da2
/* -*- 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 "test/screenshot_test.hxx"
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/processfactory.hxx>
#include <vcl/abstdlg.hxx>
#include <vcl/pngwrite.hxx>
namespace
{
void
splitHelpId
(
OString
&
rHelpId
,
OUString
&
rDirname
,
OUString
&
rBasename
)
{
sal_Int32
nIndex
=
rHelpId
.
lastIndexOf
(
'/'
);
if
(
nIndex
>
0
)
rDirname
=
OStringToOUString
(
rHelpId
.
copy
(
0
,
nIndex
),
RTL_TEXTENCODING_UTF8
);
if
(
rHelpId
.
getLength
()
>
nIndex
+
1
)
rBasename
=
OStringToOUString
(
rHelpId
.
copy
(
nIndex
+
1
),
RTL_TEXTENCODING_UTF8
);
}
}
using
namespace
css
;
using
namespace
css
::
uno
;
ScreenshotTest
::
ScreenshotTest
()
:
m_aScreenshotDirectory
(
"/workdir/screenshots/"
)
{
}
void
ScreenshotTest
::
setUp
()
{
test
::
BootstrapFixture
::
setUp
();
mxDesktop
=
css
::
frame
::
Desktop
::
create
(
comphelper
::
getComponentContext
(
getMultiServiceFactory
())
);
CPPUNIT_ASSERT_MESSAGE
(
"no desktop!"
,
mxDesktop
.
is
());
osl
::
FileBase
::
RC
err
=
osl
::
Directory
::
create
(
m_directories
.
getURLFromSrc
(
m_aScreenshotDirectory
)
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to create screenshot directory"
,
(
err
==
osl
::
FileBase
::
E_None
||
err
==
osl
::
FileBase
::
E_EXIST
)
);
}
void
ScreenshotTest
::
tearDown
()
{
test
::
BootstrapFixture
::
tearDown
();
}
void
ScreenshotTest
::
saveScreenshot
(
VclAbstractDialog
&
rDialog
)
{
const
Bitmap
aScreenshot
(
rDialog
.
createScreenshot
());
if
(
!
aScreenshot
.
IsEmpty
())
{
OString
aScreenshotId
=
rDialog
.
GetScreenshotId
();
OUString
aDirname
,
aBasename
;
splitHelpId
(
aScreenshotId
,
aDirname
,
aBasename
);
aDirname
=
m_aScreenshotDirectory
+
aDirname
;
osl
::
FileBase
::
RC
err
=
osl
::
Directory
::
createPath
(
m_directories
.
getURLFromSrc
(
aDirname
));
CPPUNIT_ASSERT_MESSAGE
(
OUStringToOString
(
"Failed to create "
+
aDirname
,
RTL_TEXTENCODING_UTF8
).
getStr
(),
(
err
==
osl
::
FileBase
::
E_None
||
err
==
osl
::
FileBase
::
E_EXIST
)
);
OUString
aFullPath
=
m_directories
.
getSrcRootPath
()
+
aDirname
+
"/"
+
aBasename
+
".png"
;
SvFileStream
aNew
(
aFullPath
,
StreamMode
::
WRITE
|
StreamMode
::
TRUNC
);
CPPUNIT_ASSERT_MESSAGE
(
OUStringToOString
(
"Failed to open "
+
OUString
::
number
(
aNew
.
GetErrorCode
()),
RTL_TEXTENCODING_UTF8
).
getStr
(),
aNew
.
IsOpen
()
);
vcl
::
PNGWriter
aPNGWriter
(
aScreenshot
);
aPNGWriter
.
Write
(
aNew
);
}
}
void
ScreenshotTest
::
dumpDialogToPath
(
VclAbstractDialog
&
rDialog
)
{
const
std
::
vector
<
OString
>
aPageDescriptions
(
rDialog
.
getAllPageUIXMLDescriptions
());
if
(
aPageDescriptions
.
size
())
{
for
(
sal_uInt32
a
(
0
);
a
<
aPageDescriptions
.
size
();
a
++
)
{
if
(
rDialog
.
selectPageByUIXMLDescription
(
aPageDescriptions
[
a
]))
{
saveScreenshot
(
rDialog
);
}
else
{
CPPUNIT_ASSERT
(
false
);
}
}
}
else
{
saveScreenshot
(
rDialog
);
}
}
/* 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