16#include <com/sun/star/frame/Desktop.hpp>
27 void splitHelpId(
const OUString& rHelpId, OUString& rDirname, OUString &rBasename )
29 sal_Int32
nIndex = rHelpId.lastIndexOf(
'/' );
32 rDirname = rHelpId.subView( 0, nIndex );
34 if( rHelpId.getLength() > nIndex+1 )
35 rBasename = rHelpId.subView( nIndex+1 );
40using namespace css::uno;
46 : maParent(nullptr,
"vcl/ui/screenshotparent.ui",
"ScreenShot")
47 , mxParentWidget(maParent.getDialog()->weld_content_area())
49 if (
auto const env = getenv(
"LO_TEST_LOCALE")) {
63 CPPUNIT_ASSERT_MESSAGE(
"no desktop!",
mxDesktop.is());
76 OUString aDirname, aBasename;
77 splitHelpId(rScreenshotId, aDirname, aBasename);
82 auto const e = osl::Directory::createPath(dirUrl);
83 if (e != osl::FileBase::E_EXIST) {
84 CPPUNIT_ASSERT_EQUAL_MESSAGE(
87 osl::FileBase::E_None, e);
90 auto const pngUrl = OUString(dirUrl +
"/" + aBasename +
".png");
91 SvFileStream aNew(pngUrl, StreamMode::WRITE | StreamMode::TRUNC);
92 CPPUNIT_ASSERT_MESSAGE(OString(
"Failed to open <" +
OUStringToOString(pngUrl, RTL_TEXTENCODING_UTF8) +
">: " + OString::number(sal_uInt32(aNew.
GetErrorCode()))).getStr(), aNew.
IsOpen());
94 std::cout <<
"saving " << pngUrl <<
":\n";
96 aPNGWriter.
write(rScreenshot);
107 if (!aScreenshotId.isEmpty())
117 const BitmapEx aScreenshot(xDialogSurface->GetBitmapEx(
Point(), xDialogSurface->GetOutputSizePixel()));
121 const OUString aScreenshotId = rDialog.
get_help_id();
122 assert(!aScreenshotId.isEmpty());
143 if (!aPageDescriptions.empty())
145 for (
size_t a(0);
a < aPageDescriptions.size();
a++)
153 CPPUNIT_ASSERT(
false);
169 int nPages = xTabCtrl ? xTabCtrl->get_n_pages() : 0;
172 for (
int i = 0;
i < nPages; ++
i)
174 OUString sIdent(xTabCtrl->get_page_ident(
i));
175 xTabCtrl->set_current_page(sIdent);
176 if (xTabCtrl->get_current_page_ident() == sIdent)
178 OUString sOrigHelpId(xDialog->get_help_id());
182 if (!sBuildableName.isEmpty() && !sBuildableName.startsWith(
"__"))
185 xDialog->set_help_id(sOrigHelpId);
189 CPPUNIT_ASSERT(
false);
201 if (rUIXMLDescription.empty())
204 bool bNonConforming = rUIXMLDescription ==
"modules/swriter/ui/sidebarstylepresets.ui" ||
205 rUIXMLDescription ==
"modules/swriter/ui/sidebartheme.ui" ||
206 rUIXMLDescription ==
"modules/swriter/ui/notebookbar.ui" ||
207 rUIXMLDescription ==
"modules/scalc/ui/sidebaralignment.ui" ||
208 rUIXMLDescription ==
"modules/scalc/ui/sidebarcellappearance.ui" ||
209 rUIXMLDescription ==
"modules/scalc/ui/sidebarnumberformat.ui" ||
210 rUIXMLDescription ==
"sfx/ui/helpbookmarkpage.ui" ||
211 rUIXMLDescription ==
"sfx/ui/helpcontentpage.ui" ||
212 rUIXMLDescription ==
"sfx/ui/helpindexpage.ui" ||
213 rUIXMLDescription ==
"sfx/ui/helpsearchpage.ui" ||
214 rUIXMLDescription ==
"sfx/ui/startcenter.ui" ||
215 rUIXMLDescription ==
"svx/ui/datanavigator.ui" ||
216 rUIXMLDescription ==
"svx/ui/xformspage.ui" ||
217 rUIXMLDescription ==
"modules/dbreport/ui/conditionwin.ui";
250 static constexpr OStringLiteral aComment(
"#");
252 while (aStream.
ReadLine(aNextUIFile))
254 if (!aNextUIFile.isEmpty() && !aNextUIFile.startsWith(aComment))
256 std::cout <<
"processing " << aNextUIFile <<
":\n";
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
void implSaveScreenshot(const BitmapEx &rScreenshot, const OUString &rScreenshotId)
helpers
mapType maKnownDialogs
the set of known dialogs and their ID for usage in createDialogByID
virtual void setUp() override
void processDialogBatchFile(std::u16string_view rFile)
helper to process an input file containing the UXMLDescriptions of the dialogs to dump.
void saveScreenshot(VclAbstractDialog const &rDialog)
virtual VclPtr< VclAbstractDialog > createDialogByID(sal_uInt32 nID)=0
dialog creation for known dialogs by ID.
std::unique_ptr< weld::Container > mxParentWidget
void dumpDialogToPath(weld::Builder &rDialog)
helper method to create and dump a dialog based on Builder contents.
virtual ~ScreenshotTest() override
void processAllKnownDialogs()
helper to process all known dialogs
virtual void registerKnownDialogsByID(mapType &rKnownDialogs)=0
helper method to populate maKnownDialogs, called in setUp().
VclPtr< VclAbstractDialog > createDialogByName(const OString &rName)
Dialog creation for known dialogs by Name (path and UIXMLDescription, *.ui file).
const mapType & getKnownDialogs() const
const access to known dialogs
OUString maCurrentLanguage
The current UI language.
bool ReadLine(OStringBuffer &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
ErrCode const & GetErrorCode() const
virtual OUString GetScreenshotId() const
virtual std::vector< OUString > getAllPageUIXMLDescriptions() const
virtual bool selectPageByUIXMLDescription(const OUString &rUIXMLDescription)
virtual BitmapEx createScreenshot() const
const css::uno::Reference< css::lang::XMultiServiceFactory > & getMultiServiceFactory() const
Directories m_directories
virtual void setUp() override
OUString getURLFromWorkdir(std::u16string_view rPath) const
OUString getURLFromSrc(std::u16string_view rPath) const
css::uno::Reference< css::frame::XDesktop2 > mxDesktop
bool write(const BitmapEx &rBitmap)
virtual std::unique_ptr< Notebook > weld_notebook(const OUString &id)=0
virtual std::unique_ptr< Window > create_screenshot_window()=0
virtual VclPtr< VirtualDevice > screenshot()=0
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment > & env
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
constexpr OUStringLiteral g_aScreenshotDirectory(u"screenshots")
the target directory for screenshots