calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / blocklistparsertest.cxx
blob689e8d9c9e2433a458dfce63ce8f96adca7d8255
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/types.h>
12 #include <cppunit/TestAssert.h>
13 #include <cppunit/TestFixture.h>
14 #include <cppunit/extensions/HelperMacros.h>
15 #include <cppunit/plugin/TestPlugIn.h>
17 #include <unotest/bootstrapfixturebase.hxx>
19 #include <driverblocklist.hxx>
21 using namespace DriverBlocklist;
23 namespace
26 class BlocklistParserTest : public test::BootstrapFixtureBase
28 void testParse();
29 void testEvaluate();
30 void testVulkan();
32 CPPUNIT_TEST_SUITE(BlocklistParserTest);
33 CPPUNIT_TEST(testParse);
34 CPPUNIT_TEST(testEvaluate);
35 CPPUNIT_TEST(testVulkan);
36 CPPUNIT_TEST_SUITE_END();
39 void BlocklistParserTest::testParse()
41 std::vector<DriverInfo> aDriveInfos;
43 Parser aBlocklistParser(m_directories.getURLFromSrc(u"vcl/qa/cppunit/") + "test_blocklist_parse.xml",
44 aDriveInfos, VersionType::OpenGL);
45 aBlocklistParser.parse();
47 size_t const n = aDriveInfos.size();
48 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(16), n);
50 size_t i = 0;
52 for (bool bIsAllowlisted : {true, false})
54 DriverInfo& aDriveInfo = aDriveInfos[i++];
55 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
56 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor); // "all"
57 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_LESS_THAN, aDriveInfo.meComparisonOp);
58 CPPUNIT_ASSERT_EQUAL(OpenGLVersion(10,20,30,40), aDriveInfo.mnDriverVersion);
60 aDriveInfo = aDriveInfos[i++];
61 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
62 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorNVIDIA), aDriveInfo.maAdapterVendor);
63 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_EQUAL, aDriveInfo.meComparisonOp);
65 aDriveInfo = aDriveInfos[i++];
66 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
67 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorMicrosoft), aDriveInfo.maAdapterVendor);
68 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
70 aDriveInfo = aDriveInfos[i++];
71 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
72 CPPUNIT_ASSERT_EQUAL(OUString("0xcafe"), aDriveInfo.maAdapterVendor);
73 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
75 aDriveInfo = aDriveInfos[i++];
76 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
77 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
78 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_BETWEEN_EXCLUSIVE, aDriveInfo.meComparisonOp);
80 aDriveInfo = aDriveInfos[i++];
81 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
82 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
83 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE, aDriveInfo.meComparisonOp);
85 aDriveInfo = aDriveInfos[i++];
86 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
87 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
88 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE_START, aDriveInfo.meComparisonOp);
90 aDriveInfo = aDriveInfos[i++];
91 CPPUNIT_ASSERT_EQUAL(bIsAllowlisted, aDriveInfo.mbAllowlisted);
92 CPPUNIT_ASSERT_EQUAL(GetVendorId(VendorAll), aDriveInfo.maAdapterVendor);
93 CPPUNIT_ASSERT_EQUAL(VersionComparisonOp::DRIVER_COMPARISON_IGNORED, aDriveInfo.meComparisonOp);
97 void BlocklistParserTest::testEvaluate()
99 std::vector<DriverInfo> aDriveInfos;
101 Parser aBlocklistParser(m_directories.getURLFromSrc(u"vcl/qa/cppunit/") + "test_blocklist_evaluate.xml",
102 aDriveInfos, VersionType::OpenGL);
103 aBlocklistParser.parse();
105 OUString vendorAMD = GetVendorId(VendorAMD);
106 OUString vendorNVIDIA = GetVendorId(VendorNVIDIA);
107 OUString vendorIntel = GetVendorId(VendorIntel);
108 OUString vendorMicrosoft = GetVendorId(VendorMicrosoft);
110 // Check OS
111 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
112 aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorNVIDIA, "all", DRIVER_OS_WINDOWS_7));
113 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
114 aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorNVIDIA, "all", DRIVER_OS_WINDOWS_8));
115 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
116 aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorNVIDIA, "all", DRIVER_OS_WINDOWS_10));
118 // Check generic OS
119 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
120 aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_WINDOWS_10));
121 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
122 aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_LINUX));
123 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
124 aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_OSX_10_7));
125 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
126 aDriveInfos, VersionType::OpenGL, u"10.20.30.50", vendorMicrosoft, "all", DRIVER_OS_OSX_10_8));
128 // Check Vendors
129 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
130 aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorMicrosoft, "all", DRIVER_OS_WINDOWS_7));
131 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
132 aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorMicrosoft, "all", DRIVER_OS_WINDOWS_10));
134 // Check Versions
135 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
136 aDriveInfos, VersionType::OpenGL, u"10.20.30.39", vendorAMD, "all", DRIVER_OS_WINDOWS_7));
137 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
138 aDriveInfos, VersionType::OpenGL, u"10.20.30.40", vendorAMD, "all", DRIVER_OS_WINDOWS_7));
139 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
140 aDriveInfos, VersionType::OpenGL, u"10.20.30.41", vendorAMD, "all", DRIVER_OS_WINDOWS_7));
142 // Check
143 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
144 aDriveInfos, VersionType::OpenGL, u"9.17.10.4229", vendorIntel, "all", DRIVER_OS_WINDOWS_7));
149 void BlocklistParserTest::testVulkan()
151 std::vector<DriverInfo> aDriveInfos;
153 Parser aBlocklistParser(m_directories.getURLFromSrc(u"vcl/qa/cppunit/") + "test_blocklist_vulkan.xml",
154 aDriveInfos, VersionType::Vulkan);
155 aBlocklistParser.parse();
157 OUString vendorAMD = GetVendorId(VendorAMD);
159 // Check Versions
160 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
161 aDriveInfos, VersionType::Vulkan, u"1.2.3", vendorAMD, "all", DRIVER_OS_ALL));
162 CPPUNIT_ASSERT_EQUAL(true, FindBlocklistedDeviceInList(
163 aDriveInfos, VersionType::Vulkan, u"1.2.2", vendorAMD, "all", DRIVER_OS_ALL));
164 CPPUNIT_ASSERT_EQUAL(false, FindBlocklistedDeviceInList(
165 aDriveInfos, VersionType::Vulkan, u"1.2.20", vendorAMD, "all", DRIVER_OS_ALL));
168 } // namespace
170 CPPUNIT_TEST_SUITE_REGISTRATION(BlocklistParserTest);
172 CPPUNIT_PLUGIN_IMPLEMENT();
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */