Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / vcl / qa / cppunit / blocklistparsertest.cxx
blobddad53b94a27d048b981836aa66c35048e1e95f4
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 "opengl/win/blocklist_parser.hxx"
21 namespace
24 class BlocklistParserTest : public test::BootstrapFixtureBase
26 void testParse();
27 void testEvaluate();
29 CPPUNIT_TEST_SUITE(BlocklistParserTest);
30 CPPUNIT_TEST(testParse);
31 CPPUNIT_TEST(testEvaluate);
32 CPPUNIT_TEST_SUITE_END();
35 void BlocklistParserTest::testParse()
37 std::vector<wgl::DriverInfo> aDriveInfos;
39 WinBlocklistParser aBlocklistParser(m_directories.getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_parse.xml", aDriveInfos);
40 aBlocklistParser.parse();
42 size_t const n = aDriveInfos.size();
43 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(22), n);
45 size_t i = 0;
47 for (bool bIsWhitelisted : {true, false})
49 wgl::DriverInfo& aDriveInfo = aDriveInfos[i++];
50 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
51 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor); // "all"
52 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_LESS_THAN, aDriveInfo.meComparisonOp);
53 CPPUNIT_ASSERT_EQUAL(wgl::V(10,20,30,40), aDriveInfo.mnDriverVersion);
55 aDriveInfo = aDriveInfos[i++];
56 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
57 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel), aDriveInfo.maAdapterVendor);
58 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_LESS_THAN_OR_EQUAL, aDriveInfo.meComparisonOp);
59 CPPUNIT_ASSERT_EQUAL(wgl::V(11,21,31,41), aDriveInfo.mnDriverVersion);
61 aDriveInfo = aDriveInfos[i++];
62 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
63 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorATI), aDriveInfo.maAdapterVendor);
64 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_GREATER_THAN, aDriveInfo.meComparisonOp);
65 CPPUNIT_ASSERT_EQUAL(wgl::V(12,22,32,42), aDriveInfo.mnDriverVersion);
67 aDriveInfo = aDriveInfos[i++];
68 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
69 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD), aDriveInfo.maAdapterVendor);
70 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_GREATER_THAN_OR_EQUAL, aDriveInfo.meComparisonOp);
72 aDriveInfo = aDriveInfos[i++];
73 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
74 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA), aDriveInfo.maAdapterVendor);
75 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_EQUAL, aDriveInfo.meComparisonOp);
77 aDriveInfo = aDriveInfos[i++];
78 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
79 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft), aDriveInfo.maAdapterVendor);
80 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
82 aDriveInfo = aDriveInfos[i++];
83 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
84 CPPUNIT_ASSERT_EQUAL(OUString("0xcafe"), aDriveInfo.maAdapterVendor);
85 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
87 aDriveInfo = aDriveInfos[i++];
88 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
89 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
90 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_EXCLUSIVE, aDriveInfo.meComparisonOp);
92 aDriveInfo = aDriveInfos[i++];
93 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
94 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
95 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE, aDriveInfo.meComparisonOp);
97 aDriveInfo = aDriveInfos[i++];
98 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
99 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
100 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE_START, aDriveInfo.meComparisonOp);
102 aDriveInfo = aDriveInfos[i++];
103 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
104 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
105 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_COMPARISON_IGNORED, aDriveInfo.meComparisonOp);
109 void BlocklistParserTest::testEvaluate()
111 std::vector<wgl::DriverInfo> aDriveInfos;
113 WinBlocklistParser aBlocklistParser(m_directories.getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_evaluate.xml", aDriveInfos);
114 aBlocklistParser.parse();
116 OUString vendorAMD = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD);
117 OUString vendorNVIDIA = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA);
118 OUString vendorIntel = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel);
119 OUString vendorMicrosoft = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft);
121 uint32_t osWindowsXP = 0x00050001;
122 uint32_t osWindowsVista = 0x00060000;
123 uint32_t osWindows7 = 0x00060001;
124 uint32_t osWindows8 = 0x00060002;
125 uint32_t osWindows10 = 0x000A0000;
127 // Check OS
128 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
129 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindowsXP));
130 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
131 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindowsVista));
132 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
133 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows7));
134 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
135 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows8));
136 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
137 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows10));
140 // Check Vendors
141 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
142 aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows7));
143 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
144 aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows10));
146 // Check Versions
147 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
148 aDriveInfos, "10.20.30.39", vendorAMD, "all", osWindows7));
149 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
150 aDriveInfos, "10.20.30.40", vendorAMD, "all", osWindows7));
151 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
152 aDriveInfos, "10.20.30.41", vendorAMD, "all", osWindows7));
154 // Check
155 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
156 aDriveInfos, "9.17.10.4229", vendorIntel, "all", osWindows7));
161 } // namespace
163 CPPUNIT_TEST_SUITE_REGISTRATION(BlocklistParserTest);
165 CPPUNIT_PLUGIN_IMPLEMENT();
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */