Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / qa / cppunit / blocklistparsertest.cxx
blob7d99e87f37504103e1cde683993faa5f4b73537a
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>(16), 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::VendorNVIDIA), aDriveInfo.maAdapterVendor);
58 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_EQUAL, aDriveInfo.meComparisonOp);
60 aDriveInfo = aDriveInfos[i++];
61 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
62 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft), aDriveInfo.maAdapterVendor);
63 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
65 aDriveInfo = aDriveInfos[i++];
66 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
67 CPPUNIT_ASSERT_EQUAL(OUString("0xcafe"), aDriveInfo.maAdapterVendor);
68 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_NOT_EQUAL, aDriveInfo.meComparisonOp);
70 aDriveInfo = aDriveInfos[i++];
71 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
72 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
73 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_EXCLUSIVE, aDriveInfo.meComparisonOp);
75 aDriveInfo = aDriveInfos[i++];
76 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
77 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
78 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE, aDriveInfo.meComparisonOp);
80 aDriveInfo = aDriveInfos[i++];
81 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
82 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
83 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_BETWEEN_INCLUSIVE_START, aDriveInfo.meComparisonOp);
85 aDriveInfo = aDriveInfos[i++];
86 CPPUNIT_ASSERT_EQUAL(bIsWhitelisted, aDriveInfo.mbWhitelisted);
87 CPPUNIT_ASSERT_EQUAL(WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAll), aDriveInfo.maAdapterVendor);
88 CPPUNIT_ASSERT_EQUAL(wgl::VersionComparisonOp::DRIVER_COMPARISON_IGNORED, aDriveInfo.meComparisonOp);
92 void BlocklistParserTest::testEvaluate()
94 std::vector<wgl::DriverInfo> aDriveInfos;
96 WinBlocklistParser aBlocklistParser(m_directories.getURLFromSrc("vcl/qa/cppunit/") + "test_blocklist_evaluate.xml", aDriveInfos);
97 aBlocklistParser.parse();
99 OUString vendorAMD = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorAMD);
100 OUString vendorNVIDIA = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorNVIDIA);
101 OUString vendorIntel = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorIntel);
102 OUString vendorMicrosoft = WinOpenGLDeviceInfo::GetDeviceVendor(wgl::VendorMicrosoft);
104 uint32_t const osWindows7 = 0x00060001;
105 uint32_t const osWindows8 = 0x00060002;
106 uint32_t const osWindows10 = 0x000A0000;
108 // Check OS
109 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
110 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows7));
111 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
112 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows8));
113 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
114 aDriveInfos, "10.20.30.40", vendorNVIDIA, "all", osWindows10));
117 // Check Vendors
118 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
119 aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows7));
120 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
121 aDriveInfos, "10.20.30.40", vendorMicrosoft, "all", osWindows10));
123 // Check Versions
124 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
125 aDriveInfos, "10.20.30.39", vendorAMD, "all", osWindows7));
126 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
127 aDriveInfos, "10.20.30.40", vendorAMD, "all", osWindows7));
128 CPPUNIT_ASSERT_EQUAL(false, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
129 aDriveInfos, "10.20.30.41", vendorAMD, "all", osWindows7));
131 // Check
132 CPPUNIT_ASSERT_EQUAL(true, WinOpenGLDeviceInfo::FindBlocklistedDeviceInList(
133 aDriveInfos, "9.17.10.4229", vendorIntel, "all", osWindows7));
138 } // namespace
140 CPPUNIT_TEST_SUITE_REGISTRATION(BlocklistParserTest);
142 CPPUNIT_PLUGIN_IMPLEMENT();
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */