1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "gtest/gtest.h"
7
8 namespace mozilla {
9 namespace webgl {
10 std::string SanitizeRenderer(const std::string&);
11 } // namespace webgl
12 } // namespace mozilla
13
TEST(SanitizeRenderer,TestLinuxRadeon)14 TEST(SanitizeRenderer, TestLinuxRadeon)
15 {
16 const std::string renderer(
17 "AMD Radeon RX 5700 (NAVI10, DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
18 const std::string expectation("Radeon R9 200 Series");
19 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
20 EXPECT_EQ(sanitized, expectation);
21 }
22
TEST(SanitizeRenderer,TestLinuxRadeonTM)23 TEST(SanitizeRenderer, TestLinuxRadeonTM)
24 {
25 const std::string renderer(
26 "AMD Radeon (TM) RX 460 Graphics (POLARIS11, DRM 3.35.0, "
27 "5.4.0-65-generic, LLVM 11.0.0)");
28 const std::string expectation("Radeon R9 200 Series");
29 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
30 EXPECT_EQ(sanitized, expectation);
31 }
32
TEST(SanitizeRenderer,TestLinuxRadeonWithoutGeneration)33 TEST(SanitizeRenderer, TestLinuxRadeonWithoutGeneration)
34 {
35 const std::string renderer(
36 "AMD Radeon RX 5700 (DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
37 const std::string expectation("Radeon R9 200 Series");
38 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
39 EXPECT_EQ(sanitized, expectation);
40 }
41
TEST(SanitizeRenderer,TestWindowsVega)42 TEST(SanitizeRenderer, TestWindowsVega)
43 {
44 const std::string renderer("Radeon RX Vega");
45 const std::string expectation("Radeon R9 200 Series");
46 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
47 EXPECT_EQ(sanitized, expectation);
48 }
49
TEST(SanitizeRenderer,TestMacAmd)50 TEST(SanitizeRenderer, TestMacAmd)
51 {
52 const std::string renderer("AMD Radeon Pro 5300M OpenGL Engine");
53 const std::string expectation("Radeon R9 200 Series");
54 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
55 EXPECT_EQ(sanitized, expectation);
56 }
57
TEST(SanitizeRenderer,TestLinuxIntel620)58 TEST(SanitizeRenderer, TestLinuxIntel620)
59 {
60 const std::string renderer("Mesa Intel(R) UHD Graphics 620 (KBL GT2)");
61 const std::string expectation("Intel(R) HD Graphics 400");
62 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
63 EXPECT_EQ(sanitized, expectation);
64 }
TEST(SanitizeRenderer,TestLinuxIntel4000)65 TEST(SanitizeRenderer, TestLinuxIntel4000)
66 {
67 const std::string renderer("Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)");
68 const std::string expectation("Intel(R) HD Graphics");
69 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
70 EXPECT_EQ(sanitized, expectation);
71 }
72
TEST(SanitizeRenderer,TestMacIntel)73 TEST(SanitizeRenderer, TestMacIntel)
74 {
75 const std::string renderer("Intel(R) HD Graphics 530");
76 const std::string expectation("Intel(R) HD Graphics 400");
77 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
78 EXPECT_EQ(sanitized, expectation);
79 }
80
TEST(SanitizeRenderer,TestMacApple)81 TEST(SanitizeRenderer, TestMacApple)
82 {
83 const std::string renderer("Apple M1");
84 const std::string expectation("Apple M1");
85 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
86 EXPECT_EQ(sanitized, expectation);
87 }
88
TEST(SanitizeRenderer,TestPipe)89 TEST(SanitizeRenderer, TestPipe)
90 {
91 const std::string renderer("llvmpipe (LLVM 11.0.0, 128 bits)");
92 const std::string expectation("llvmpipe");
93 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
94 EXPECT_EQ(sanitized, expectation);
95 }
96
97 // -
98
TEST(SanitizeRenderer,TestAngleVega)99 TEST(SanitizeRenderer, TestAngleVega)
100 {
101 const std::string renderer("ANGLE (Radeon RX Vega Direct3D11 vs_5_0 ps_5_0)");
102 const std::string expectation(
103 "ANGLE (Radeon R9 200 Series Direct3D11 vs_5_0 ps_5_0)");
104 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
105 EXPECT_EQ(sanitized, expectation);
106 }
107
TEST(SanitizeRenderer,TestAngleWarp)108 TEST(SanitizeRenderer, TestAngleWarp)
109 {
110 const std::string renderer(
111 "ANGLE (Microsoft Basic Render Driver Direct3D11 vs_5_0 ps_5_0)");
112 const std::string expectation = renderer;
113 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
114 EXPECT_EQ(sanitized, expectation);
115 }
116
TEST(SanitizeRenderer,TestAngle3070)117 TEST(SanitizeRenderer, TestAngle3070)
118 {
119 const std::string renderer(
120 "ANGLE (NVIDIA GeForce RTX 3070 Direct3D11 vs_5_0 ps_5_0)");
121 const std::string expectation(
122 "ANGLE (NVIDIA GeForce GTX 980 Direct3D11 vs_5_0 ps_5_0)");
123 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
124 EXPECT_EQ(sanitized, expectation);
125 }
126
TEST(SanitizeRenderer,TestWindows3070)127 TEST(SanitizeRenderer, TestWindows3070)
128 {
129 const std::string renderer("GeForce RTX 3070/PCIe/SSE2");
130 const std::string expectation("GeForce GTX 980/PCIe/SSE2");
131 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
132 EXPECT_EQ(sanitized, expectation);
133 }
134
TEST(SanitizeRenderer,TestAngleK600)135 TEST(SanitizeRenderer, TestAngleK600)
136 {
137 const std::string renderer(
138 "ANGLE (NVIDIA Quadro K600 Direct3D11 vs_5_0 ps_5_0)");
139 const std::string expectation(
140 "ANGLE (NVIDIA GeForce GTX 480 Direct3D11 vs_5_0 ps_5_0)");
141 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
142 EXPECT_EQ(sanitized, expectation);
143 }
144
TEST(SanitizeRenderer,TestLinuxK600)145 TEST(SanitizeRenderer, TestLinuxK600)
146 {
147 const std::string renderer("NVE7");
148 const std::string expectation("GeForce GTX 480");
149 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
150 EXPECT_EQ(sanitized, expectation);
151 }
152
TEST(SanitizeRenderer,TestLinux980)153 TEST(SanitizeRenderer, TestLinux980)
154 {
155 const std::string renderer("NV124");
156 const std::string expectation("GeForce GTX 980");
157 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
158 EXPECT_EQ(sanitized, expectation);
159 }
160
TEST(SanitizeRenderer,TestAdreno512)161 TEST(SanitizeRenderer, TestAdreno512)
162 {
163 const std::string renderer("Adreno (TM) 512");
164 const std::string expectation("Adreno (TM) 540");
165 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
166 EXPECT_EQ(sanitized, expectation);
167 }
168