#include "gpu/config/webgpu_blocklist.h"
#include "build/build_config.h"
#include "gpu/config/webgpu_blocklist_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/dawn/include/dawn/webgpu.h"
#include "ui/gl/buildflags.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace gpu {
bool IsWebGPUAdapterBlocklisted(const WGPUAdapterInfo& info,
const char* blocklist_string = "") { … }
class WebGPUBlocklistTest : public testing::Test { … };
#if BUILDFLAG(IS_ANDROID)
TEST_F(WebGPUBlocklistTest, BlockAndroidVendorId) {
const auto* build_info = base::android::BuildInfo::GetInstance();
WGPUAdapterInfo info1 = {};
info1.vendorID = 0x13B5;
WGPUAdapterInfo info2 = {};
info2.vendorID = 0x5143;
WGPUAdapterInfo info3 = {};
info3.vendorID = 0x8086;
if (build_info->sdk_int() < base::android::SDK_VERSION_S) {
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info1));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info2));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info3));
return;
}
EXPECT_FALSE(IsWebGPUAdapterBlocklisted(info1));
EXPECT_FALSE(IsWebGPUAdapterBlocklisted(info2));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info3));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info1, "13b5"));
EXPECT_FALSE(IsWebGPUAdapterBlocklisted(info2, "13b5"));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info1, "*"));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info2, "*"));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info1, "13b5|5143"));
EXPECT_TRUE(IsWebGPUAdapterBlocklisted(info2, "13b5|5143"));
}
#else
TEST_F(WebGPUBlocklistTest, BlockVendorId) { … }
TEST_F(WebGPUBlocklistTest, BlockDeviceIdOrArch) { … }
TEST_F(WebGPUBlocklistTest, BlockDriverDescription) { … }
#endif
}