diff options
author | homeboy445 <akshitsan13@gmail.com> | 2021-06-22 16:54:34 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-07-10 00:34:38 +0200 |
commit | 3057ee8ba01535324f57978569526988664eb53a (patch) | |
tree | a3c0f880ccb2e9ce6cf957c46647621013c7d490 /cui/source | |
parent | 56d7965b6c24915359f39f45f1696c6f1dc3d3c9 (diff) |
Added support for viewing results in the VCL tests UI box
The user can now easily view the result of any VCL test
by just clicking on it - which would show them the resultant
bitmap of that corresponding test.
Change-Id: I57c0c2ab3662a9abec45ba7fc230c9299dcd9279
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117657
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/dialogs/GraphicTestsDialog.cxx | 78 | ||||
-rw-r--r-- | cui/source/dialogs/ImageViewerDialog.cxx | 24 | ||||
-rw-r--r-- | cui/source/inc/GraphicsTestsDialog.hxx | 34 | ||||
-rw-r--r-- | cui/source/inc/ImageViewerDialog.hxx | 20 |
4 files changed, 125 insertions, 31 deletions
diff --git a/cui/source/dialogs/GraphicTestsDialog.cxx b/cui/source/dialogs/GraphicTestsDialog.cxx index 275d33d75886..000129444cd5 100644 --- a/cui/source/dialogs/GraphicTestsDialog.cxx +++ b/cui/source/dialogs/GraphicTestsDialog.cxx @@ -8,48 +8,70 @@ */ #include <GraphicsTestsDialog.hxx> +#include <vcl/test/GraphicsRenderTests.hxx> + +GraphicTestEntry::GraphicTestEntry(weld::Container* pParent, weld::Dialog* pDialog, + OUString aTestName, OUString aTestStatus, Bitmap aTestBitmap) + : m_xBuilder(Application::CreateBuilder(pParent, "cui/ui/graphictestentry.ui")) + , m_xContainer(m_xBuilder->weld_container("gptestbox")) + , m_xTestLabel(m_xBuilder->weld_label("gptestlabel")) + , m_xTestButton(m_xBuilder->weld_button("gptestbutton")) + , m_xResultBitmap(aTestBitmap) +{ + m_xParentDialog = pDialog; + m_xTestLabel->set_label(aTestName); + m_xTestButton->set_label(aTestStatus); + m_xTestButton->set_tooltip_text(aTestName); + m_xTestButton->set_background( + aTestStatus == "PASSED" + ? COL_LIGHTGREEN + : aTestStatus == "QUIRKY" ? COL_YELLOW + : aTestStatus == "FAILED" ? COL_LIGHTRED : COL_LIGHTGRAY); + m_xTestButton->connect_clicked(LINK(this, GraphicTestEntry, HandleResultViewRequest)); + m_xContainer->show(); +} + +IMPL_LINK(GraphicTestEntry, HandleResultViewRequest, weld::Button&, rButton, void) +{ + if (rButton.get_label() == "SKIPPED") + { + return; + } + ImageViewerDialog m_ImgVwDialog(m_xParentDialog, BitmapEx(m_xResultBitmap), + rButton.get_tooltip_text()); + m_ImgVwDialog.run(); +} GraphicsTestsDialog::GraphicsTestsDialog(weld::Window* pParent) : GenericDialogController(pParent, "cui/ui/graphictestdlg.ui", "GraphicTestsDialog") - , m_xResultLog(m_xBuilder->weld_text_view("gptestresults")) + , m_xResultLog(m_xBuilder->weld_text_view("gptest_txtVW")) , m_xDownloadResults(m_xBuilder->weld_button("gptest_downld")) + , m_xContainerBox(m_xBuilder->weld_box("gptest_box")) { - m_xResultLog->set_text("Running tests..."); m_xDownloadResults->connect_clicked(LINK(this, GraphicsTestsDialog, HandleDownloadRequest)); - runGraphicsTestandUpdateLog(); } -void GraphicsTestsDialog::runGraphicsTestandUpdateLog() +short GraphicsTestsDialog::run() { - GraphicsRenderTests TestObject; - TestObject.run(); - OUString atemp = "--General Info--\nGraphics Backend used : " + TestObject.m_aCurGraphicsBackend - + "\nPassed Tests : " + OUString::number(TestObject.m_aPassed.size()) - + "\nQuirky Tests : " + OUString::number(TestObject.m_aQuirky.size()) - + "\nFailed Tests : " + OUString::number(TestObject.m_aFailed.size()) - + "\nSkipped Tests : " + OUString::number(TestObject.m_aSkipped.size()) - + "\n\n--Test Details--\n"; - OString writeResults; - for (const class OString& tests : TestObject.m_aPassed) - { - writeResults += tests + " [PASSED]\n"; - } - for (const class OString& tests : TestObject.m_aQuirky) - { - writeResults += tests + " [QUIRKY]\n"; - } - for (const class OString& tests : TestObject.m_aFailed) - { - writeResults += tests + " [FAILED]\n"; - } - for (const class OString& tests : TestObject.m_aSkipped) + GraphicsRenderTests aTestObject; + aTestObject.run(true); + OUString aResultLog = aTestObject.getResultString() + + "\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()) { - writeResults += tests + " [SKIPPED]\n"; + auto xGpTest = std::make_unique<GraphicTestEntry>(m_xContainerBox.get(), m_xDialog.get(), + tests.getTestName(), tests.getStatus(), + tests.getBitmap()); + m_xContainerBox->reorder_child(xGpTest->get_widget(), nTestNumber++); + m_xGraphicTestEntries.push_back(std::move(xGpTest)); } - m_xResultLog->set_text(atemp + OStringToOUString(writeResults, RTL_TEXTENCODING_UTF8)); + return GenericDialogController::run(); } IMPL_STATIC_LINK_NOARG(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void) { //TODO: Enter code for downloading the results to user's system. + return; } diff --git a/cui/source/dialogs/ImageViewerDialog.cxx b/cui/source/dialogs/ImageViewerDialog.cxx new file mode 100644 index 000000000000..b245c8c08b60 --- /dev/null +++ b/cui/source/dialogs/ImageViewerDialog.cxx @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 <vcl/virdev.hxx> +#include <ImageViewerDialog.hxx> + +ImageViewerDialog::ImageViewerDialog(weld::Dialog* pParent, BitmapEx aBitmap, OUString atitle) + : GenericDialogController(pParent, "cui/ui/imageviewer.ui", "ImageViewerDialog") + , m_xDisplayImage(m_xBuilder->weld_image("ImgVW_mainImage")) +{ + m_xDialog->set_title(atitle); + aBitmap.Scale(Size(300, 300), BmpScaleFlag::Fast); + ScopedVclPtr<VirtualDevice> m_pVirDev = m_xDisplayImage->create_virtual_device(); + m_pVirDev->SetOutputSizePixel(aBitmap.GetSizePixel()); + m_pVirDev->DrawBitmapEx(Point(0, 0), aBitmap); + m_xDisplayImage->set_image(m_pVirDev.get()); + m_pVirDev.disposeAndClear(); +} diff --git a/cui/source/inc/GraphicsTestsDialog.hxx b/cui/source/inc/GraphicsTestsDialog.hxx index d851fbf0b528..2912d898efb7 100644 --- a/cui/source/inc/GraphicsTestsDialog.hxx +++ b/cui/source/inc/GraphicsTestsDialog.hxx @@ -8,17 +8,45 @@ */ #pragma once +#include <vcl/bitmapex.hxx> +#include <vcl/svapp.hxx> #include <vcl/weld.hxx> -#include <vcl/test/GraphicsRenderTests.hxx> +#include <tools/link.hxx> + +#include "ImageViewerDialog.hxx" + +#include <vector> + +class GraphicTestEntry final +{ +private: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::Label> m_xTestLabel; + std::unique_ptr<weld::Button> m_xTestButton; + + weld::Dialog* m_xParentDialog; + + Bitmap m_xResultBitmap; + +public: + DECL_LINK(HandleResultViewRequest, weld::Button&, void); + GraphicTestEntry(weld::Container* pParent, weld::Dialog* pDialog, OUString aTestName, + OUString aTestStatus, Bitmap aTestBitmap); + weld::Widget* get_widget() const { return m_xContainer.get(); } +}; class GraphicsTestsDialog : public weld::GenericDialogController { std::unique_ptr<weld::TextView> m_xResultLog; std::unique_ptr<weld::Button> m_xDownloadResults; + std::unique_ptr<weld::Box> m_xContainerBox; + + std::vector<std::unique_ptr<GraphicTestEntry>> m_xGraphicTestEntries; DECL_STATIC_LINK(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void); public: GraphicsTestsDialog(weld::Window* pParent); - void runGraphicsTestandUpdateLog(); -};
\ No newline at end of file + virtual short run() override; +}; diff --git a/cui/source/inc/ImageViewerDialog.hxx b/cui/source/inc/ImageViewerDialog.hxx new file mode 100644 index 000000000000..884deb18d4a7 --- /dev/null +++ b/cui/source/inc/ImageViewerDialog.hxx @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ +#pragma once + +#include <vcl/bitmapex.hxx> +#include <vcl/weld.hxx> + +class ImageViewerDialog : public weld::GenericDialogController +{ + std::unique_ptr<weld::Image> m_xDisplayImage; + +public: + ImageViewerDialog(weld::Dialog* pParent, BitmapEx aBitmap, OUString atitle); +}; |