summaryrefslogtreecommitdiffstats
path: root/dom/canvas/gtest/TestSanitizeRenderer.cpp
blob: a51904ddd16e8291ac20ed6c180495acc319eaee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "gtest/gtest.h"

namespace mozilla::webgl {
std::string SanitizeRenderer(const std::string&);
}  // namespace mozilla::webgl

TEST(SanitizeRenderer, TestLinuxRadeon)
{
  const std::string renderer(
      "AMD Radeon RX 5700 (NAVI10, DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxRadeonTM)
{
  const std::string renderer(
      "AMD Radeon (TM) RX 460 Graphics (POLARIS11, DRM 3.35.0, "
      "5.4.0-65-generic, LLVM 11.0.0)");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxRadeonWithoutGeneration)
{
  const std::string renderer(
      "AMD Radeon RX 5700 (DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxRenoir)
{
  const std::string renderer(
      "AMD RENOIR (DRM 3.41.0, 5.13.4-1-default, LLVM 11.1.0)");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestWindowsVega)
{
  const std::string renderer("Radeon RX Vega");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestMacAmd)
{
  const std::string renderer("AMD Radeon Pro 5300M OpenGL Engine");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxAruba)
{
  const std::string renderer(
      "AMD ARUBA (DRM 2.50.0 / 5.10.42-calculate, LLVM 12.0.1)");
  const std::string expectation("Radeon HD 5850, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxRembrandt)
{
  const std::string renderer(
      "REMBRANDT (rembrandt, LLVM 14.0.6, DRM 3.49, 6.2.9)");
  const std::string expectation("Radeon R9 200 Series, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxIntel620)
{
  const std::string renderer("Mesa Intel(R) UHD Graphics 620 (KBL GT2)");
  const std::string expectation("Intel(R) HD Graphics 400, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestLinuxIntel4000)
{
  const std::string renderer("Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)");
  const std::string expectation("Intel(R) HD Graphics, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestMacIntel)
{
  const std::string renderer("Intel(R) HD Graphics 530");
  const std::string expectation("Intel(R) HD Graphics 400, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestMacApple)
{
  const std::string renderer("Apple M1");
  const std::string expectation("Apple M1, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestPipe)
{
  const std::string renderer("llvmpipe (LLVM 11.0.0, 128 bits)");
  const std::string expectation("llvmpipe, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

// -

TEST(SanitizeRenderer, TestAngleVega)
{
  const std::string renderer(
      "ANGLE (AMD, Radeon RX Vega Direct3D11 vs_5_0 ps_5_0, "
      "D3D11-27.20.22025.1006)");
  const std::string expectation(
      "ANGLE (AMD, Radeon R9 200 Series Direct3D11 vs_5_0 ps_5_0), or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestAngleRadeon)
{
  const std::string renderer(
      "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3D11 vs_5_0 ps_5_0, "
      "D3D11-27.20.1020.2002)");
  const std::string expectation(
      "ANGLE (AMD, Radeon HD 3200 Graphics Direct3D11 vs_5_0 ps_5_0), or "
      "similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestAngleWarp)
{
  const std::string renderer(
      "ANGLE (Unknown, Microsoft Basic Render Driver Direct3D11 vs_5_0 ps_5_0, "
      "D3D11-10.0.22000.1)");
  const std::string expectation =
      "ANGLE (Unknown, Microsoft Basic Render Driver Direct3D11 vs_5_0 "
      "ps_5_0), or similar";
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestAngle3070)
{
  const std::string renderer(
      "ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 Direct3D11 vs_5_0 ps_5_0, "
      "D3D11-10.0.22000.1)");
  const std::string expectation(
      "ANGLE (NVIDIA, NVIDIA GeForce GTX 980 Direct3D11 vs_5_0 ps_5_0), or "
      "similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestWindows3070)
{
  const std::string renderer("GeForce RTX 3070/PCIe/SSE2");
  const std::string expectation("GeForce GTX 980, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestAngleK600)
{
  const std::string renderer(
      "ANGLE (NVIDIA, NVIDIA Quadro K600 Direct3D11 vs_5_0 ps_5_0, somethig "
      "like D3D11-10.0.22000.1)");
  const std::string expectation(
      "ANGLE (NVIDIA, NVIDIA GeForce GTX 480 Direct3D11 vs_5_0 ps_5_0), or "
      "similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinuxK600)
{
  const std::string renderer("NVE7");
  const std::string expectation("GeForce GTX 480, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestLinux980)
{
  const std::string renderer("NV124");
  const std::string expectation("GeForce GTX 980, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestAdreno512)
{
  const std::string renderer("Adreno (TM) 512");
  const std::string expectation("Adreno (TM) 540, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestIntelArcWindowsAngle)
{
  const std::string renderer(
      "ANGLE (Intel, Intel(R) Arc(TM) A770 Graphics Direct3D11 vs_5_0 ps_5_0, "
      "D3D11-31.0.101.5084)");
  const std::string expectation(
      "ANGLE (Intel, Intel(R) Arc(TM) A750 Graphics Direct3D11 vs_5_0 ps_5_0), "
      "or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestIntelArcWindowsGl)
{
  const std::string renderer("Intel(R) Arc(TM) A770 Graphics");
  const std::string expectation("Intel(R) Arc(TM) A750 Graphics, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

// -
// Keep gtests for our known CI RENDERER strings (see
// test_renderer_strings.html) otherwise the first time we know we messed up is
// in CI results after an hour, instead of after running gtests locally.

TEST(SanitizeRenderer, TestCiAndroid)
{
  const std::string renderer("Adreno (TM) 540");
  const std::string expectation("Adreno (TM) 540, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestCiLinux)
{
  const std::string renderer("llvmpipe (LLVM 10.0.0, 256 bits)");
  const std::string expectation("llvmpipe, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestCiMac)
{
  const std::string renderer("Intel(R) UHD Graphics 630");
  const std::string expectation("Intel(R) HD Graphics 400, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestCiMac2)
{
  const std::string renderer("Apple M1");
  const std::string expectation("Apple M1, or similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}

TEST(SanitizeRenderer, TestCiWindows)
{
  const std::string renderer(
      "ANGLE (NVIDIA, NVIDIA Tesla M60 Direct3D11 vs_5_0 ps_5_0, "
      "D3D11-23.21.13.9181)");
  const std::string expectation(
      "ANGLE (NVIDIA, NVIDIA GeForce 8800 GTX Direct3D11 vs_5_0 ps_5_0), or "
      "similar");
  const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
  EXPECT_EQ(sanitized, expectation);
}