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 | |
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')
-rw-r--r-- | cui/Library_cui.mk | 1 | ||||
-rw-r--r-- | cui/UIConfig_cui.mk | 2 | ||||
-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 | ||||
-rw-r--r-- | cui/uiconfig/ui/graphictestdlg.ui | 101 | ||||
-rw-r--r-- | cui/uiconfig/ui/graphictestentry.ui | 43 | ||||
-rw-r--r-- | cui/uiconfig/ui/imageviewer.ui | 44 |
9 files changed, 291 insertions, 56 deletions
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index 345f84b7f008..bc4f1e50c139 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -139,6 +139,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\ cui/source/dialogs/postdlg \ cui/source/dialogs/QrCodeGenDialog \ cui/source/dialogs/GraphicTestsDialog \ + cui/source/dialogs/ImageViewerDialog \ cui/source/dialogs/scriptdlg \ cui/source/dialogs/SignatureLineDialogBase \ cui/source/dialogs/SignatureLineDialog \ diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk index 73da8e159f09..3af5d8e698e7 100644 --- a/cui/UIConfig_cui.mk +++ b/cui/UIConfig_cui.mk @@ -83,6 +83,8 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\ cui/uiconfig/ui/gallerytitledialog \ cui/uiconfig/ui/galleryupdateprogress \ cui/uiconfig/ui/graphictestdlg \ + cui/uiconfig/ui/graphictestentry \ + cui/uiconfig/ui/imageviewer \ cui/uiconfig/ui/hangulhanjaadddialog \ cui/uiconfig/ui/hangulhanjaeditdictdialog \ cui/uiconfig/ui/hangulhanjaconversiondialog \ 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); +}; diff --git a/cui/uiconfig/ui/graphictestdlg.ui b/cui/uiconfig/ui/graphictestdlg.ui index 339688d72d2f..2e1252a2bf94 100644 --- a/cui/uiconfig/ui/graphictestdlg.ui +++ b/cui/uiconfig/ui/graphictestdlg.ui @@ -8,11 +8,13 @@ <property name="resizable">False</property> <property name="modal">True</property> <property name="default-width">500</property> - <property name="default-height">450</property> + <property name="default-height">550</property> <property name="type-hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="gptest-main"> <property name="can-focus">False</property> + <property name="margin-top">4</property> + <property name="margin-bottom">4</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child internal-child="action_area"> @@ -41,7 +43,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + <property name="position">1</property> </packing> </child> <child> @@ -60,51 +62,100 @@ </packing> </child> <child> - <object class="GtkLabel" id="gptest_label1"> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="shadow-type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="GtkTextView" id="gptest_txtVW"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="vexpand">True</property> + <property name="pixels-above-lines">2</property> + <property name="pixels-below-lines">2</property> + <property name="editable">False</property> + <property name="left-margin">2</property> + <property name="right-margin">2</property> + <property name="top-margin">2</property> + <property name="bottom-margin">2</property> + <accessibility> + <relation type="labelled-by" target="gptest_log"/> + </accessibility> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="gptest_log"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="margin-end">400</property> - <property name="margin-top">10</property> - <property name="label" translatable="yes" context="graphictestdlg|gptest_label1">Results log:</property> - <property name="justify">center</property> + <property name="halign">start</property> + <property name="margin-start">5</property> + <property name="label" translatable="yes" context="graphictestdlg|gptest_log">Result Log:</property> <accessibility> - <relation type="label-for" target="gptestresults"/> + <relation type="label-for" target="gptest_txtVW"/> </accessibility> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> - <object class="GtkScrolledWindow" id="gpscrollerwindow1"> + <object class="GtkLabel" id="gptest_detail"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-top">20</property> + <property name="margin-bottom">10</property> + <property name="label" translatable="yes" context="graphictestdlg|gptest_detail">Test Details</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="gptest_scrollwindow1"> <property name="visible">True</property> <property name="can-focus">True</property> <property name="shadow-type">in</property> <child> - <object class="GtkTextView" id="gptestresults"> + <object class="GtkViewport"> <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="pixels-above-lines">3</property> - <property name="pixels-below-lines">3</property> - <property name="editable">False</property> - <property name="wrap-mode">word-char</property> - <property name="left-margin">10</property> - <property name="right-margin">10</property> - <property name="top-margin">10</property> - <property name="bottom-margin">10</property> - <property name="indent">2</property> - <accessibility> - <relation type="labelled-by" target="gptest_label1"/> - </accessibility> + <property name="can-focus">False</property> + <child> + <object class="GtkBox" id="gptest_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="hexpand">True</property> + <property name="orientation">vertical</property> + <property name="spacing">5</property> + <child> + <placeholder/> + </child> + </object> + </child> </object> </child> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">5</property> </packing> </child> </object> diff --git a/cui/uiconfig/ui/graphictestentry.ui b/cui/uiconfig/ui/graphictestentry.ui new file mode 100644 index 000000000000..2248b433fed7 --- /dev/null +++ b/cui/uiconfig/ui/graphictestentry.ui @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="cui"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkBox" id="gptestbox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="border-width">3</property> + <child> + <object class="GtkLabel" id="gptestlabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">4</property> + <property name="hexpand">True</property> + <property name="selectable">True</property> + <property name="xalign">0</property> + <child internal-child="accessible"> + <object class="AtkObject" id="gptestlabel-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="gptestbutton"> + <property name="label" translatable="yes" context="graphictestentry|gptestbutton">button</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> +</interface> diff --git a/cui/uiconfig/ui/imageviewer.ui b/cui/uiconfig/ui/imageviewer.ui new file mode 100644 index 000000000000..6008137aded2 --- /dev/null +++ b/cui/uiconfig/ui/imageviewer.ui @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="cui"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkDialog" id="ImageViewerDialog"> + <property name="can-focus">False</property> + <property name="resizable">False</property> + <property name="default-width">350</property> + <property name="default-height">350</property> + <property name="type-hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="imgVW_bx"> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="imgVW_btngrid"> + <property name="can-focus">False</property> + <property name="layout-style">end</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkImage" id="ImgVW_mainImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> |