Nuke Builders Part 3: remove validation test builder expectations
BUG=dawn:125
Change-Id: I64a0b957e39b60334916ad71fb4beee5d8baa9db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6162
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp
index 3408297..d83b767 100644
--- a/src/tests/unittests/validation/ValidationTest.cpp
+++ b/src/tests/unittests/validation/ValidationTest.cpp
@@ -54,22 +54,6 @@
void ValidationTest::TearDown() {
ASSERT_FALSE(mExpectError);
-
- for (auto& expectation : mExpectations) {
- std::string name = expectation.debugName;
- if (name.empty()) {
- name = "<no debug name set>";
- }
-
- 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 @@
auto self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(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<ValidationTest*>(static_cast<uintptr_t>(userdata1));
- size_t index = static_cast<size_t>(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 375c5b1..e4e06af 100644
--- a/src/tests/unittests/validation/ValidationTest.h
+++ b/src/tests/unittests/validation/ValidationTest.h
@@ -35,20 +35,6 @@
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<typename Builder>
- Builder AssertWillBeSuccess(Builder builder, std::string debugName = "");
- template<typename Builder>
- Builder AssertWillBeError(Builder builder, std::string debugName = "");
-
void StartExpectDeviceError();
bool EndExpectDeviceError();
std::string GetLastDeviceErrorMessage() const;
@@ -78,47 +64,6 @@
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<BuilderStatusExpectations> mExpectations;
-
- template<typename Builder>
- 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<typename Builder>
-Builder ValidationTest::AssertWillBeSuccess(Builder builder, std::string debugName) {
- return AddExpectation(builder, debugName, true);
-}
-
-template<typename Builder>
-Builder ValidationTest::AssertWillBeError(Builder builder, std::string debugName) {
- return AddExpectation(builder, debugName, false);
-}
-
-template<typename Builder>
-Builder ValidationTest::AddExpectation(Builder& builder, std::string debugName, bool expectSuccess) {
- uint64_t userdata1 = reinterpret_cast<uintptr_t>(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_