[Libreoffice-commits] core.git: vcl/CppunitTest_vcl_blocklistparser_test.mk vcl/inc vcl/Module_vcl.mk vcl/opengl vcl/qa

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Mon Feb 15 16:57:09 UTC 2016


 vcl/CppunitTest_vcl_blocklistparser_test.mk |   49 ++++++++
 vcl/Module_vcl.mk                           |    1 
 vcl/inc/opengl/win/WinDeviceInfo.hxx        |   14 +-
 vcl/inc/opengl/win/blocklist_parser.hxx     |   43 +++++++
 vcl/opengl/win/WinDeviceInfo.cxx            |   57 +++++----
 vcl/opengl/win/blocklist_parser.cxx         |    2 
 vcl/opengl/win/blocklist_parser.hxx         |   45 -------
 vcl/qa/cppunit/blocklistparsertest.cxx      |  161 ++++++++++++++++++++++++++++
 vcl/qa/cppunit/test_blocklist_evaluate.xml  |   47 ++++++++
 vcl/qa/cppunit/test_blocklist_parse.xml     |   75 +++++++++++++
 10 files changed, 419 insertions(+), 75 deletions(-)

New commits:
commit d83fb2b2dea1296885fdefda6804c1dea961d48a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Feb 15 15:10:03 2016 +0100

    Unit test for opengl blocklist parsing and evaluating
    
    Parsing unit test checks that the xml values are parsed correctly
    and that the DriverInfo structure is populated with the expected
    values.
    
    Evaluate unit test checks that blacklisting / whitelisting
    logic blocks OS/vendor/driver/device as expected.
    
    Change-Id: Ib1b0926606f0835207c324193bbe19ba83f86bdc
    Reviewed-on: https://gerrit.libreoffice.org/22371
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/CppunitTest_vcl_blocklistparser_test.mk b/vcl/CppunitTest_vcl_blocklistparser_test.mk
new file mode 100644
index 0000000..95b7507
--- /dev/null
+++ b/vcl/CppunitTest_vcl_blocklistparser_test.mk
@@ -0,0 +1,49 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,vcl_blocklistparser_test))
+
+$(eval $(call gb_CppunitTest_set_include,vcl_blocklistparser_test,\
+	$$(INCLUDE) \
+	-I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,vcl_blocklistparser_test, \
+	vcl/qa/cppunit/blocklistparsertest \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,vcl_blocklistparser_test,\
+	boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,vcl_blocklistparser_test, \
+	sal \
+	test \
+	unotest \
+	vcl \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,vcl_blocklistparser_test,\
+	udkapi \
+	offapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,vcl_blocklistparser_test))
+$(eval $(call gb_CppunitTest_use_vcl,vcl_blocklistparser_test))
+
+$(eval $(call gb_CppunitTest_use_components,vcl_blocklistparser_test,\
+	configmgr/source/configmgr \
+	i18npool/util/i18npool \
+	ucb/source/core/ucb1 \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,vcl_blocklistparser_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 6a41a0b..81a7276 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -125,6 +125,7 @@ endif
 ifeq ($(OS),WNT)
 $(eval $(call gb_Module_add_check_targets,vcl,\
 	CppunitTest_vcl_timer \
+	CppunitTest_vcl_blocklistparser_test \
 ))
 endif
 # vim: set noet sw=4 ts=4:
diff --git a/vcl/inc/opengl/win/WinDeviceInfo.hxx b/vcl/inc/opengl/win/WinDeviceInfo.hxx
index 974d6b3..8dcbd55 100644
--- a/vcl/inc/opengl/win/WinDeviceInfo.hxx
+++ b/vcl/inc/opengl/win/WinDeviceInfo.hxx
@@ -10,7 +10,10 @@
 #ifndef INCLUDED_VCL_OPENGL_WIN_WINDEVICEINFO_HXX
 #define INCLUDED_VCL_OPENGL_WIN_WINDEVICEINFO_HXX
 
+#include <vcl/dllapi.h>
+
 #include "opengl/DeviceInfo.hxx"
+
 #include <rtl/ustring.hxx>
 #include <vector>
 #include <cstdint>
@@ -60,14 +63,14 @@ enum DeviceVendor {
 
 bool ParseDriverVersion(const OUString& rString, uint64_t& rVersion);
 
-struct DriverInfo
+struct VCL_DLLPUBLIC DriverInfo
 {
 
     DriverInfo(OperatingSystem os, const OUString& vendor, VersionComparisonOp op,
             uint64_t driverVersion, bool bWhiteListed = false, const char *suggestedVersion = nullptr);
 
     DriverInfo();
-    ~DriverInfo();
+    virtual ~DriverInfo();
 
     OperatingSystem meOperatingSystem;
     uint32_t mnOperatingSystemVersion;
@@ -96,7 +99,7 @@ struct DriverInfo
 #define GFX_DRIVER_VERSION(a,b,c,d) \
     ((uint64_t(a)<<48) | (uint64_t(b)<<32) | (uint64_t(c)<<16) | uint64_t(d))
 
-inline uint64_t V(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
+inline VCL_DLLPUBLIC uint64_t V(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
 {
     // We make sure every driver number is padded by 0s, this will allow us the
     // easiest 'compare as if decimals' approach. See ParseDriverVersion for a
@@ -115,7 +118,7 @@ inline uint64_t V(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
 
 }
 
-class WinOpenGLDeviceInfo : public OpenGLDeviceInfo
+class VCL_DLLPUBLIC WinOpenGLDeviceInfo : public OpenGLDeviceInfo
 {
 private:
     OUString maDriverVersion;
@@ -204,6 +207,9 @@ public:
         return mnWindowsVersion;
     }
 
+    static bool FindBlocklistedDeviceInList(std::vector<wgl::DriverInfo>& aDeviceInfos,
+                                            OUString sDriverVersion, OUString sAdapterVendorID,
+                                            OUString sAdapterDeviceID, uint32_t nWindowsVersion);
 };
 
 #endif
diff --git a/vcl/opengl/win/blocklist_parser.hxx b/vcl/inc/opengl/win/blocklist_parser.hxx
similarity index 94%
rename from vcl/opengl/win/blocklist_parser.hxx
rename to vcl/inc/opengl/win/blocklist_parser.hxx
index bc2e2a1..f307344 100644
--- a/vcl/opengl/win/blocklist_parser.hxx
+++ b/vcl/inc/opengl/win/blocklist_parser.hxx
@@ -7,17 +7,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "opengl/win/WinDeviceInfo.hxx"
-
+#include <vcl/dllapi.h>
 #include <xmlreader/xmlreader.hxx>
-
 #include <vector>
+#include "opengl/win/WinDeviceInfo.hxx"
 
 class InvalidFileException
 {
 };
 
-class WinBlocklistParser
+class VCL_DLLPUBLIC WinBlocklistParser
 {
 public:
     WinBlocklistParser(const OUString& rURL, std::vector<wgl::DriverInfo>& rDriverList);
@@ -29,7 +28,6 @@ private:
     void handleList(xmlreader::XmlReader& rReader);
     void handleContent(xmlreader::XmlReader& rReader);
 
-
     enum class BlockType
     {
         WHITELIST,
diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx
index 798dc58..729368a 100644
--- a/vcl/opengl/win/WinDeviceInfo.cxx
+++ b/vcl/opengl/win/WinDeviceInfo.cxx
@@ -9,7 +9,7 @@
 
 #include "opengl/win/WinDeviceInfo.hxx"
 
-#include "blocklist_parser.hxx"
+#include "opengl/win/blocklist_parser.hxx"
 #include <config_folders.h>
 
 #include <windows.h>
@@ -441,67 +441,69 @@ private:
 
 }
 
-bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList()
+bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(std::vector<wgl::DriverInfo>& aDeviceInfos,
+                                                      OUString sDriverVersion, OUString sAdapterVendorID,
+                                                      OUString sAdapterDeviceID, uint32_t nWindowsVersion)
 {
     uint64_t driverVersion;
-    wgl::ParseDriverVersion(maDriverVersion, driverVersion);
+    wgl::ParseDriverVersion(sDriverVersion, driverVersion);
 
-    wgl::OperatingSystem eOS = WindowsVersionToOperatingSystem(mnWindowsVersion);
+    wgl::OperatingSystem eOS = WindowsVersionToOperatingSystem(nWindowsVersion);
     bool match = false;
     uint32_t i = 0;
-    for (; i < maDriverInfo.size(); i++)
+    for (; i < aDeviceInfos.size(); i++)
     {
-        if (maDriverInfo[i].meOperatingSystem != wgl::DRIVER_OS_ALL &&
-                maDriverInfo[i].meOperatingSystem != eOS)
+        if (aDeviceInfos[i].meOperatingSystem != wgl::DRIVER_OS_ALL &&
+                aDeviceInfos[i].meOperatingSystem != eOS)
         {
             continue;
         }
 
-        if (maDriverInfo[i].mnOperatingSystemVersion && maDriverInfo[i].mnOperatingSystemVersion != mnWindowsVersion)
+        if (aDeviceInfos[i].mnOperatingSystemVersion && aDeviceInfos[i].mnOperatingSystemVersion != nWindowsVersion)
         {
             continue;
         }
 
-        if (!maDriverInfo[i].maAdapterVendor.equalsIgnoreAsciiCase(GetDeviceVendor(wgl::VendorAll)) &&
-                !maDriverInfo[i].maAdapterVendor.equalsIgnoreAsciiCase(maAdapterVendorID))
+        if (!aDeviceInfos[i].maAdapterVendor.equalsIgnoreAsciiCase(GetDeviceVendor(wgl::VendorAll)) &&
+                !aDeviceInfos[i].maAdapterVendor.equalsIgnoreAsciiCase(sAdapterVendorID))
         {
             continue;
         }
 
-        if (std::none_of(maDriverInfo[i].maDevices.begin(), maDriverInfo[i].maDevices.end(), compareIgnoreAsciiCase("all")) &&
-            std::none_of(maDriverInfo[i].maDevices.begin(), maDriverInfo[i].maDevices.end(), compareIgnoreAsciiCase(maAdapterDeviceID)))
+        if (std::none_of(aDeviceInfos[i].maDevices.begin(), aDeviceInfos[i].maDevices.end(), compareIgnoreAsciiCase("all")) &&
+            std::none_of(aDeviceInfos[i].maDevices.begin(), aDeviceInfos[i].maDevices.end(), compareIgnoreAsciiCase(sAdapterDeviceID)))
         {
             continue;
         }
 
-        switch (maDriverInfo[i].meComparisonOp)
+        switch (aDeviceInfos[i].meComparisonOp)
         {
             case wgl::DRIVER_LESS_THAN:
-                match = driverVersion < maDriverInfo[i].mnDriverVersion;
+                match = driverVersion < aDeviceInfos[i].mnDriverVersion;
                 break;
             case wgl::DRIVER_LESS_THAN_OR_EQUAL:
-                match = driverVersion <= maDriverInfo[i].mnDriverVersion;
+                match = driverVersion <= aDeviceInfos[i].mnDriverVersion;
                 break;
             case wgl::DRIVER_GREATER_THAN:
-                match = driverVersion > maDriverInfo[i].mnDriverVersion;
+                match = driverVersion > aDeviceInfos[i].mnDriverVersion;
                 break;
             case wgl::DRIVER_GREATER_THAN_OR_EQUAL:
-                match = driverVersion >= maDriverInfo[i].mnDriverVersion;
+                match = driverVersion >= aDeviceInfos[i].mnDriverVersion;
                 break;
             case wgl::DRIVER_EQUAL:
-                match = driverVersion == maDriverInfo[i].mnDriverVersion;
+                match = driverVersion == aDeviceInfos[i].mnDriverVersion;
                 break;
             case wgl::DRIVER_NOT_EQUAL:
-                match = driverVersion != maDriverInfo[i].mnDriverVersion;
+                match = driverVersion != aDeviceInfos[i].mnDriverVersion;
                 break;
             case wgl::DRIVER_BETWEEN_EXCLUSIVE:
-                match = driverVersion > maDriverInfo[i].mnDriverVersion && driverVersion < maDriverInfo[i].mnDriverVersionMax;
+                match = driverVersion > aDeviceInfos[i].mnDriverVersion && driverVersion < aDeviceInfos[i].mnDriverVersionMax;
                 break;
             case wgl::DRIVER_BETWEEN_INCLUSIVE:
-                match = driverVersion >= maDriverInfo[i].mnDriverVersion && driverVersion <= maDriverInfo[i].mnDriverVersionMax;
+                match = driverVersion >= aDeviceInfos[i].mnDriverVersion && driverVersion <= aDeviceInfos[i].mnDriverVersionMax;
                 break;
             case wgl::DRIVER_BETWEEN_INCLUSIVE_START:
-                match = driverVersion >= maDriverInfo[i].mnDriverVersion && driverVersion < maDriverInfo[i].mnDriverVersionMax;
+                match = driverVersion >= aDeviceInfos[i].mnDriverVersion && driverVersion < aDeviceInfos[i].mnDriverVersionMax;
                 break;
             case wgl::DRIVER_COMPARISON_IGNORED:
                 // We don't have a comparison op, so we match everything.
@@ -512,17 +514,17 @@ bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList()
                 break;
         }
 
-        if (match || maDriverInfo[i].mnDriverVersion == wgl::DriverInfo::allDriverVersions)
+        if (match || aDeviceInfos[i].mnDriverVersion == wgl::DriverInfo::allDriverVersions)
         {
             // white listed drivers
-            if (maDriverInfo[i].mbWhitelisted)
+            if (aDeviceInfos[i].mbWhitelisted)
             {
                 SAL_WARN("vcl.opengl", "whitelisted driver");
                 return false;
             }
 
             match = true;
-            SAL_WARN("vcl.opengl", "use : " << maDriverInfo[i].maSuggestedVersion);
+            SAL_WARN("vcl.opengl", "use : " << aDeviceInfos[i].maSuggestedVersion);
             break;
         }
     }
@@ -531,6 +533,11 @@ bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList()
     return match;
 }
 
+bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList()
+{
+    return FindBlocklistedDeviceInList(maDriverInfo, maDriverVersion, maAdapterVendorID, maAdapterDeviceID, mnWindowsVersion);
+}
+
 namespace {
 
 OUString getCacheFolder()
diff --git a/vcl/opengl/win/blocklist_parser.cxx b/vcl/opengl/win/blocklist_parser.cxx
index bb9e6fb..c728bd4 100644
--- a/vcl/opengl/win/blocklist_parser.cxx
+++ b/vcl/opengl/win/blocklist_parser.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "blocklist_parser.hxx"
+#include "opengl/win/blocklist_parser.hxx"
 
 WinBlocklistParser::WinBlocklistParser(const OUString& rURL,
         std::vector<wgl::DriverInfo>& rDriverList)
diff --git a/vcl/qa/cppunit/blocklistparsertest.cxx b/vcl/qa/cppunit/blocklistparsertest.cxx
new file mode 100644
index 0000000..66a4f70
--- /dev/null
+++ b/vcl/qa/cppunit/blocklistparsertest.cxx
@@ -0,0 +1,161 @@
+/* -*- 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 <sal/types.h>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <unotest/bootstrapfixturebase.hxx>
+
+#include "opengl/win/blocklist_parser.hxx"
+
+namespace
+{
+
+class BlocklistParserTest : public test::BootstrapFixtureBase
+{
+    void testParse();
+    void testEvaluate();
+
+    CPPUNIT_TEST_SUITE(BlocklistParserTest);
+    CPPUNIT_TEST(testParse);
+    CPPUNIT_TEST(testEvaluate);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void BlocklistParserTest::testParse()
+{
+    std::vector<wgl::DriverInfo> aDriveInfos;
+
+    WinBlocklistParser aBlocklistParser(getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_parse.xml", aDriveInfos);
+    aBlocklistParser.parse();
+
+    CPPUNIT_ASSERT_EQUAL(20U, aDriveInfos.size());
+
+    size_t i = 0;
+
+    for (bool bIsWhitelisted : {true, false})
+    {
+        wgl::DriverInfo& aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); // "all"
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_LESS_THAN, aDriveInfo.meComparisonOp);
+        CPPUNIT_ASSERT_EQUAL(wgl::V(10,20,30,40), aDriveInfo.mnDriverVersion);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_LESS_THAN_OR_EQUAL, aDriveInfo.meComparisonOp);
+        CPPUNIT_ASSERT_EQUAL(wgl::V(11,21,31,41), aDriveInfo.mnDriverVersion);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorATI), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_GREATER_THAN, aDriveInfo.meComparisonOp);
+        CPPUNIT_ASSERT_EQUAL(wgl::V(12,22,32,42), aDriveInfo.mnDriverVersion);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_GREATER_THAN_OR_EQUAL, aDriveInfo.meComparisonOp);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_EQUAL, aDriveInfo.meComparisonOp);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_EXCLUSIVE, aDriveInfo.meComparisonOp);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE, aDriveInfo.meComparisonOp);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE_START, aDriveInfo.meComparisonOp);
+
+        aDriveInfo = aDriveInfos[i++];
+        CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
+        CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
+        CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_COMPARISON_IGNORED, aDriveInfo.meComparisonOp);
+    }
+}
+
+void BlocklistParserTest::testEvaluate()
+{
+    std::vector<wgl::DriverInfo> aDriveInfos;
+
+    WinBlocklistParser aBlocklistParser(getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_evaluate.xml", aDriveInfos);
+    aBlocklistParser.parse();
+
+    OUString vendorAMD = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD);
+    OUString vendorNVIDIA = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA);
+    OUString vendorIntel = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel);
+    OUString vendorMicrosoft = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft);
+
+    uint32_t osWindowsXP = 0x00050001;
+    uint32_t osWindowsVista = 0x00060000;
+    uint32_t osWindows7 = 0x00060001;
+    uint32_t osWindows8 = 0x00060002;
+    uint32_t osWindows10 = 0x000A0000;
+
+    // Check OS
+    CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindowsXP));
+    CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindowsVista));
+    CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows7));
+    CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows8));
+    CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows10));
+
+
+    // Check Vendors
+    CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows7));
+    CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows10));
+
+    // Check Versions
+    CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.39", vendorAMD, "all", osWindows7));
+    CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.40", vendorAMD, "all", osWindows7));
+    CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "10.20.30.41", vendorAMD, "all", osWindows7));
+
+    // Check
+    CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
+                                    aDriveInfos, "9.17.10.4229", vendorIntel, "all", osWindows7));
+
+
+}
+
+} // namespace
+
+CPPUNIT_TEST_SUITE_REGISTRATION(BlocklistParserTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/test_blocklist_evaluate.xml b/vcl/qa/cppunit/test_blocklist_evaluate.xml
new file mode 100755
index 0000000..7ffbe3a
--- /dev/null
+++ b/vcl/qa/cppunit/test_blocklist_evaluate.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* 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/.
+-->
+
+<!--
+    entry attributes:
+    os - "all", "xp", "server2003", "vista", "7", "8", "8_1", "10"
+    vendor - "all", "intel", "ati", "amd", "nvidia", "microsoft"
+    compare - "less", "less_equal", "greater", "greater_equal", "equal", "not_equal", "between_exclusive", "between_inclusive", "between_inclusive_start"
+    version
+    minVersion
+    maxVersion
+-->
+
+<root>
+    <whitelist>
+    </whitelist>
+    <blacklist>
+       <entry os="xp" vendor="all">
+            <device id="all"/>
+        </entry>
+        <entry os="server2003" vendor="all">
+            <device id="all"/>
+        </entry>
+        <entry os="vista" vendor="all">
+            <device id="all"/>
+        </entry>
+
+        <entry os="all" vendor="amd" compare="less" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+
+        <entry os="all" vendor="microsoft">
+            <device id="all"/>
+        </entry>
+
+        <entry os="all" vendor="intel" compare="less" version="10.18.14.4264">
+            <device id="all"/>
+        </entry>
+
+    </blacklist>
+</root>
diff --git a/vcl/qa/cppunit/test_blocklist_parse.xml b/vcl/qa/cppunit/test_blocklist_parse.xml
new file mode 100755
index 0000000..6564668
--- /dev/null
+++ b/vcl/qa/cppunit/test_blocklist_parse.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* 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/.
+-->
+
+<root>
+    <whitelist>
+        <entry os="all" vendor="all" compare="less" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="xp" vendor="intel" compare="less_equal" version="11.21.31.41">
+            <device id="all"/>
+        </entry>
+        <entry os="server2003" vendor="ati" compare="greater" version="12.22.32.42">
+            <device id="all"/>
+        </entry>
+        <entry os="vista" vendor="amd" compare="greater_equal" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="7" vendor="nvidia" compare="equal" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="8" vendor="microsoft" compare="not_equal" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="8_1" compare="between_exclusive" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="10" compare="between_inclusive" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="all" compare="between_inclusive_start" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="all">
+            <device id="all"/>
+        </entry>
+    </whitelist>
+    <blacklist>
+        <entry os="all" vendor="all" compare="less" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="xp" vendor="intel" compare="less_equal" version="11.21.31.41">
+            <device id="all"/>
+        </entry>
+        <entry os="server2003" vendor="ati" compare="greater" version="12.22.32.42">
+            <device id="all"/>
+        </entry>
+        <entry os="vista" vendor="amd" compare="greater_equal" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="7" vendor="nvidia" compare="equal" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="8" vendor="microsoft" compare="not_equal" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="8_1" compare="between_exclusive" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="10" compare="between_inclusive" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="all" compare="between_inclusive_start" version="10.20.30.40">
+            <device id="all"/>
+        </entry>
+        <entry os="all">
+            <device id="all"/>
+        </entry>
+    </blacklist>
+</root>


More information about the Libreoffice-commits mailing list