diff options
author | homeboy445 <akshitsan13@gmail.com> | 2021-06-26 20:46:25 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-07-27 14:19:06 +0200 |
commit | 6cb3c79b84e396959a982070f6fc4d439a9c396d (patch) | |
tree | e76414396b63922a1b12b52193d30be2f2da1808 /cui | |
parent | a66dc788d92d9ef0ab6a5a0339f02df0c39b97fb (diff) |
Added the feature to store VCL test results as a zip file
The results can now be downloaded as a zip file, which would
consist of the test log and all the resultant bitmap images produced
by the tests compressed as png stored in the user directory folder.
Change-Id: I8a6098a7454a621bbb9cafa7b6f2cafaa5503522
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117937
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/GraphicTestsDialog.cxx | 43 | ||||
-rw-r--r-- | cui/source/inc/GraphicsTestsDialog.hxx | 8 |
2 files changed, 44 insertions, 7 deletions
diff --git a/cui/source/dialogs/GraphicTestsDialog.cxx b/cui/source/dialogs/GraphicTestsDialog.cxx index 000129444cd5..0bd3bdd0fc39 100644 --- a/cui/source/dialogs/GraphicTestsDialog.cxx +++ b/cui/source/dialogs/GraphicTestsDialog.cxx @@ -7,6 +7,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <comphelper/backupfilehelper.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/DirectoryHelper.hxx> +#include <osl/file.hxx> +#include <unotools/ZipPackageHelper.hxx> #include <GraphicsTestsDialog.hxx> #include <vcl/test/GraphicsRenderTests.hxx> @@ -48,6 +53,10 @@ GraphicsTestsDialog::GraphicsTestsDialog(weld::Window* pParent) , m_xDownloadResults(m_xBuilder->weld_button("gptest_downld")) , m_xContainerBox(m_xBuilder->weld_box("gptest_box")) { + OUString userProfile = comphelper::BackupFileHelper::getUserProfileURL(); + m_xZipFileUrl = userProfile + "/GraphicTestResults.zip"; + m_xCreateFolderUrl = userProfile + "/GraphicTestResults"; + osl::Directory::create(m_xCreateFolderUrl); m_xDownloadResults->connect_clicked(LINK(this, GraphicsTestsDialog, HandleDownloadRequest)); } @@ -59,19 +68,41 @@ short GraphicsTestsDialog::run() + "\n(Click on any test to view its resultant bitmap image)"; m_xResultLog->set_text(aResultLog); sal_Int32 nTestNumber = 0; - for (VclTestResult& tests : aTestObject.getTestResults()) + for (VclTestResult& test : aTestObject.getTestResults()) { auto xGpTest = std::make_unique<GraphicTestEntry>(m_xContainerBox.get(), m_xDialog.get(), - tests.getTestName(), tests.getStatus(), - tests.getBitmap()); + test.getTestName(), test.getStatus(), + test.getBitmap()); m_xContainerBox->reorder_child(xGpTest->get_widget(), nTestNumber++); m_xGraphicTestEntries.push_back(std::move(xGpTest)); } return GenericDialogController::run(); } -IMPL_STATIC_LINK_NOARG(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void) +IMPL_LINK_NOARG(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void) { - //TODO: Enter code for downloading the results to user's system. - return; + osl::File::remove(m_xZipFileUrl); // Remove previous exports + try + { + utl::ZipPackageHelper aZipHelper(comphelper::getProcessComponentContext(), m_xZipFileUrl); + aZipHelper.addFolderWithContent(aZipHelper.getRootFolder(), m_xCreateFolderUrl); + aZipHelper.savePackage(); + } + catch (const std::exception&) + { + std::unique_ptr<weld::MessageDialog> xBox( + Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, + VclButtonsType::Ok, "Creation of Zip file failed!")); + xBox->run(); + return; + } + FileExportedDialog aDialog( + m_xDialog.get(), + "The results have been successfully saved in the file 'GraphicTestResults.zip' !"); + aDialog.run(); +} + +GraphicsTestsDialog::~GraphicsTestsDialog() +{ + comphelper::DirectoryHelper::deleteDirRecursively(m_xCreateFolderUrl); } diff --git a/cui/source/inc/GraphicsTestsDialog.hxx b/cui/source/inc/GraphicsTestsDialog.hxx index 2912d898efb7..09e7fb28ff8e 100644 --- a/cui/source/inc/GraphicsTestsDialog.hxx +++ b/cui/source/inc/GraphicsTestsDialog.hxx @@ -12,6 +12,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <tools/link.hxx> +#include <svx/FileExportedDialog.hxx> #include "ImageViewerDialog.hxx" @@ -44,9 +45,14 @@ class GraphicsTestsDialog : public weld::GenericDialogController std::vector<std::unique_ptr<GraphicTestEntry>> m_xGraphicTestEntries; - DECL_STATIC_LINK(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void); + OUString m_xZipFileUrl; + OUString m_xCreateFolderUrl; + + DECL_LINK(HandleDownloadRequest, weld::Button&, void); + DECL_LINK(HandleResultViewRequest, weld::Button&, void); public: GraphicsTestsDialog(weld::Window* pParent); + ~GraphicsTestsDialog(); virtual short run() override; }; |