diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp index 3408297aa7..d83b767833 100644 --- a/src/tests/unittests/validation/ValidationTest.cpp +++ b/src/tests/unittests/validation/ValidationTest.cpp @@ -54,22 +54,6 @@ ValidationTest::~ValidationTest() { void ValidationTest::TearDown() { ASSERT_FALSE(mExpectError); - - for (auto& expectation : mExpectations) { - std::string name = expectation.debugName; - if (name.empty()) { - name = ""; - } - - ASSERT_TRUE(expectation.gotStatus) << "Didn't get a status for " << name; - - ASSERT_NE(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, expectation.status) << "Got unknown status for " << name; - - bool wasSuccess = expectation.status == DAWN_BUILDER_ERROR_STATUS_SUCCESS; - ASSERT_EQ(expectation.expectSuccess, wasSuccess) - << "Got wrong status value for " << name - << ", status was " << expectation.status << " with \"" << expectation.statusMessage << "\""; - } } void ValidationTest::StartExpectDeviceError() { @@ -89,32 +73,11 @@ void ValidationTest::OnDeviceError(const char* message, DawnCallbackUserdata use auto self = reinterpret_cast(static_cast(userdata)); self->mDeviceErrorMessage = message; - // Skip this one specific error that is raised when a builder is used after it got an error - // this is important because we don't want to wrap all creation tests in ASSERT_DEVICE_ERROR. - // Yes the error message is misleading. - if (self->mDeviceErrorMessage == "Builder cannot be used after GetResult") { - return; - } - ASSERT_TRUE(self->mExpectError) << "Got unexpected device error: " << message; ASSERT_FALSE(self->mError) << "Got two errors in expect block"; self->mError = true; } -// static -void ValidationTest::OnBuilderErrorStatus(DawnBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2) { - auto* self = reinterpret_cast(static_cast(userdata1)); - size_t index = static_cast(userdata2); - - ASSERT_LT(index, self->mExpectations.size()); - - auto& expectation = self->mExpectations[index]; - ASSERT_FALSE(expectation.gotStatus); - expectation.gotStatus = true; - expectation.status = status; - expectation.statusMessage = message; -} - ValidationTest::DummyRenderPass::DummyRenderPass(const dawn::Device& device) : attachmentFormat(dawn::TextureFormat::R8G8B8A8Unorm), width(400), height(400) { diff --git a/src/tests/unittests/validation/ValidationTest.h b/src/tests/unittests/validation/ValidationTest.h index 375c5b1fae..e4e06af9a1 100644 --- a/src/tests/unittests/validation/ValidationTest.h +++ b/src/tests/unittests/validation/ValidationTest.h @@ -35,20 +35,6 @@ class ValidationTest : public testing::Test { void TearDown() override; - // Use these methods to add expectations on the validation of a builder. The expectations are - // checked on test teardown. Adding an expectation is done like the following: - // - // dawn::Foo foo = AssertWillBe[Success|Error](device.CreateFooBuilder(), "my foo") - // .SetBar(1) - // .GetResult(); - // - // The string argument is optional but will be printed when an expectations is missed, this - // will help debug tests where multiple expectations are added. - template - Builder AssertWillBeSuccess(Builder builder, std::string debugName = ""); - template - Builder AssertWillBeError(Builder builder, std::string debugName = ""); - void StartExpectDeviceError(); bool EndExpectDeviceError(); std::string GetLastDeviceErrorMessage() const; @@ -78,47 +64,6 @@ class ValidationTest : public testing::Test { std::string mDeviceErrorMessage; bool mExpectError = false; bool mError = false; - - struct BuilderStatusExpectations { - bool expectSuccess; - std::string debugName; - - bool gotStatus = false; - std::string statusMessage; - DawnBuilderErrorStatus status; - }; - std::vector mExpectations; - - template - Builder AddExpectation(Builder& builder, std::string debugName, bool expectSuccess); - - static void OnBuilderErrorStatus(DawnBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2); }; -// Template implementation details - -template -Builder ValidationTest::AssertWillBeSuccess(Builder builder, std::string debugName) { - return AddExpectation(builder, debugName, true); -} - -template -Builder ValidationTest::AssertWillBeError(Builder builder, std::string debugName) { - return AddExpectation(builder, debugName, false); -} - -template -Builder ValidationTest::AddExpectation(Builder& builder, std::string debugName, bool expectSuccess) { - uint64_t userdata1 = reinterpret_cast(this); - uint64_t userdata2 = mExpectations.size(); - builder.SetErrorCallback(OnBuilderErrorStatus, userdata1, userdata2); - - mExpectations.emplace_back(); - auto& expectation = mExpectations.back(); - expectation.expectSuccess = expectSuccess; - expectation.debugName = debugName; - - return std::move(builder); -} - #endif // TESTS_UNITTESTS_VALIDATIONTEST_H_