[Tests] Add validation test of Device::GetAHardwareBufferProperties()

Bug: dawn:2476
Change-Id: If649c2391dd69fd0d6bff4cdcfdc2d1049172cef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/190660
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
diff --git a/src/dawn/tests/unittests/validation/DeviceValidationTests.cpp b/src/dawn/tests/unittests/validation/DeviceValidationTests.cpp
index f8179d5..fb6c192 100644
--- a/src/dawn/tests/unittests/validation/DeviceValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/DeviceValidationTests.cpp
@@ -243,5 +243,28 @@
     device.Tick();
 }
 
+class DeviceGetAHardwareBufferPropertiesValidationTest : public ValidationTest {
+    void SetUp() override {
+        ValidationTest::SetUp();
+        DAWN_SKIP_TEST_IF(UsesWire());
+    }
+};
+
+// Test that calling GetAHardwareBufferProperties will generate an error
+// if the required feature is not present.
+TEST_F(DeviceGetAHardwareBufferPropertiesValidationTest,
+       GetAHardwareBufferPropertiesRequiresAHBFeature) {
+    // The parameter values shouldn't matter, as the call should fail validation
+    // before calling into the implementation (verified by checking the error
+    // message).
+    void* handle = nullptr;
+    wgpu::AHardwareBufferProperties* properties = nullptr;
+
+    ASSERT_DEVICE_ERROR(
+        device.GetAHardwareBufferProperties(handle, properties),
+        testing::HasSubstr(
+            "without the FeatureName::SharedTextureMemoryAHardwareBuffer feature being set"));
+}
+
 }  // anonymous namespace
 }  // namespace dawn