Integrate deprecation testing into DawnTestBase
This makes it a lot easier to modify old tests to test deprecation behavior, and means we can mark all of the places that are going to break in the deprecation CL (while we're thinking about it) instead of the removal CL (which is weeks later). It also makes it so all deprecation warnings in the tests will be caught. Turns out that they were already clean. Bug: dawn:520 Change-Id: I429f667207b88df04341179369bb6d24e034ca65 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31141 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
82cb8d8aba
commit
2bb8035ddc
|
@ -773,6 +773,11 @@ void DawnTestBase::TearDown() {
|
|||
for (size_t i = 0; i < mReadbackSlots.size(); ++i) {
|
||||
mReadbackSlots[i].buffer.Unmap();
|
||||
}
|
||||
|
||||
if (!UsesWire()) {
|
||||
EXPECT_EQ(mLastWarningCount,
|
||||
dawn_native::GetDeprecationWarningCountForTesting(device.Get()));
|
||||
}
|
||||
}
|
||||
|
||||
void DawnTestBase::StartExpectDeviceError() {
|
||||
|
|
|
@ -270,6 +270,8 @@ class DawnTestBase {
|
|||
DawnProcTable backendProcs = {};
|
||||
WGPUDevice backendDevice = nullptr;
|
||||
|
||||
size_t mLastWarningCount = 0;
|
||||
|
||||
// Helper methods to implement the EXPECT_ macros
|
||||
std::ostringstream& AddBufferExpectation(const char* file,
|
||||
int line,
|
||||
|
@ -408,6 +410,24 @@ class DawnTestBase {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define EXPECT_DEPRECATION_WARNING(statement) \
|
||||
do { \
|
||||
if (UsesWire()) { \
|
||||
statement; \
|
||||
} else { \
|
||||
size_t warningsBefore = \
|
||||
dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
|
||||
statement; \
|
||||
size_t warningsAfter = \
|
||||
dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
|
||||
EXPECT_EQ(mLastWarningCount, warningsBefore); \
|
||||
if (!IsDawnValidationSkipped()) { \
|
||||
EXPECT_EQ(warningsAfter, warningsBefore + 1); \
|
||||
} \
|
||||
mLastWarningCount = warningsAfter; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
template <typename Params = AdapterTestParam>
|
||||
class DawnTestWithParams : public DawnTestBase, public ::testing::TestWithParam<Params> {
|
||||
protected:
|
||||
|
|
|
@ -30,34 +30,8 @@ class DeprecationTests : public DawnTest {
|
|||
// Skip when validation is off because warnings might be emitted during validation calls
|
||||
DAWN_SKIP_TEST_IF(IsDawnValidationSkipped());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!UsesWire()) {
|
||||
EXPECT_EQ(mLastWarningCount,
|
||||
dawn_native::GetDeprecationWarningCountForTesting(device.Get()));
|
||||
}
|
||||
DawnTest::TearDown();
|
||||
}
|
||||
|
||||
size_t mLastWarningCount = 0;
|
||||
};
|
||||
|
||||
#define EXPECT_DEPRECATION_WARNING(statement) \
|
||||
do { \
|
||||
if (UsesWire()) { \
|
||||
statement; \
|
||||
} else { \
|
||||
size_t warningsBefore = \
|
||||
dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
|
||||
statement; \
|
||||
size_t warningsAfter = \
|
||||
dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
|
||||
EXPECT_EQ(mLastWarningCount, warningsBefore); \
|
||||
EXPECT_EQ(warningsAfter, warningsBefore + 1); \
|
||||
mLastWarningCount = warningsAfter; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Test that using BGLEntry.multisampled = true emits a deprecation warning.
|
||||
TEST_P(DeprecationTests, BGLEntryMultisampledDeprecated) {
|
||||
wgpu::BindGroupLayoutEntry entry{};
|
||||
|
|
Loading…
Reference in New Issue