summaryrefslogtreecommitdiff
path: root/vcl/opengl/win
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2016-02-15 15:10:03 +0100
committerMichael Meeks <michael.meeks@collabora.com>2016-02-15 16:56:43 +0000
commitd83fb2b2dea1296885fdefda6804c1dea961d48a (patch)
tree9ec93436af448ccf3e043877754c7f6f084ec71a /vcl/opengl/win
parentc0d4f3ad3307c7a0d0fddd8c413ef0cc91d382ae (diff)
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@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/opengl/win')
-rw-r--r--vcl/opengl/win/WinDeviceInfo.cxx57
-rw-r--r--vcl/opengl/win/blocklist_parser.cxx2
-rw-r--r--vcl/opengl/win/blocklist_parser.hxx45
3 files changed, 33 insertions, 71 deletions
diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx
index 798dc5862138..729368a4b05e 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 bb9e6fb81d40..c728bd407a9c 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/opengl/win/blocklist_parser.hxx b/vcl/opengl/win/blocklist_parser.hxx
deleted file mode 100644
index bc2e2a14baa7..000000000000
--- a/vcl/opengl/win/blocklist_parser.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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 "opengl/win/WinDeviceInfo.hxx"
-
-#include <xmlreader/xmlreader.hxx>
-
-#include <vector>
-
-class InvalidFileException
-{
-};
-
-class WinBlocklistParser
-{
-public:
- WinBlocklistParser(const OUString& rURL, std::vector<wgl::DriverInfo>& rDriverList);
- void parse();
-
-private:
- void handleEntry(wgl::DriverInfo& rDriver, xmlreader::XmlReader& rReader);
- void handleDevices(wgl::DriverInfo& rDriver, xmlreader::XmlReader& rReader);
- void handleList(xmlreader::XmlReader& rReader);
- void handleContent(xmlreader::XmlReader& rReader);
-
-
- enum class BlockType
- {
- WHITELIST,
- BLACKLIST,
- UNKNOWN
- };
-
- BlockType meBlockType;
- std::vector<wgl::DriverInfo>& mrDriverList;
- OUString maURL;
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */