From c2683a9459dda3f731a934e870902e99b4905fa6 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Tue, 28 Feb 2023 19:01:40 +0000 Subject: [PATCH] Fix AllowedErrorTests by returning error via move. Bug: dawn:1336 Change-Id: I966a2385e2a7e8a81ef97cd116b85a8036312e31 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122027 Kokoro: Kokoro Commit-Queue: Loko Kung Reviewed-by: Corentin Wallez --- .../unittests/native/AllowedErrorTests.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/dawn/tests/unittests/native/AllowedErrorTests.cpp b/src/dawn/tests/unittests/native/AllowedErrorTests.cpp index 118d11ee3a..78b45d2539 100644 --- a/src/dawn/tests/unittests/native/AllowedErrorTests.cpp +++ b/src/dawn/tests/unittests/native/AllowedErrorTests.cpp @@ -75,7 +75,7 @@ class AllowedErrorTests : public DawnMockTest { TEST_F(AllowedErrorTests, QueueSubmit) { EXPECT_CALL(*(mDeviceMock->GetQueueMock()), SubmitImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the device lost because of the error. EXPECT_CALL(mDeviceLostCb, @@ -93,7 +93,7 @@ TEST_F(AllowedErrorTests, QueueWriteBuffer) { wgpu::Buffer buffer = wgpu::Buffer::Acquire(ToAPI(bufferMock)); EXPECT_CALL(*(mDeviceMock->GetQueueMock()), WriteBufferImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the device lost because of the error. EXPECT_CALL(mDeviceLostCb, @@ -114,7 +114,7 @@ TEST_F(AllowedErrorTests, QueueWriteTexture) { wgpu::Texture texture = wgpu::Texture::Acquire(ToAPI(textureMock)); EXPECT_CALL(*(mDeviceMock->GetQueueMock()), WriteTextureImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the device lost because of the error. EXPECT_CALL(mDeviceLostCb, @@ -147,7 +147,7 @@ TEST_F(AllowedErrorTests, QueueCopyTextureForBrowserOomBuffer) { // Copying texture for browser internally allocates a buffer which we will cause to fail here. EXPECT_CALL(*mDeviceMock, CreateBufferImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the device lost because of the error. EXPECT_CALL(mDeviceLostCb, @@ -186,7 +186,7 @@ TEST_F(AllowedErrorTests, QueueCopyExternalTextureForBrowserOomBuffer) { // Copying texture for browser internally allocates a buffer which we will cause to fail here. EXPECT_CALL(*mDeviceMock, CreateBufferImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the device lost because of the error. EXPECT_CALL(mDeviceLostCb, @@ -205,7 +205,7 @@ TEST_F(AllowedErrorTests, CreateComputePipeline) { Ref computePipelineMock = ComputePipelineMock::Create(mDeviceMock, &desc); EXPECT_CALL(*computePipelineMock.Get(), Initialize) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); EXPECT_CALL(*mDeviceMock, CreateUninitializedComputePipelineImpl) .WillOnce(Return(ByMove(std::move(computePipelineMock)))); @@ -226,7 +226,7 @@ TEST_F(AllowedErrorTests, CreateRenderPipeline) { Ref renderPipelineMock = RenderPipelineMock::Create(mDeviceMock, &desc); EXPECT_CALL(*renderPipelineMock.Get(), Initialize) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); EXPECT_CALL(*mDeviceMock, CreateUninitializedRenderPipelineImpl) .WillOnce(Return(ByMove(std::move(renderPipelineMock)))); @@ -251,7 +251,7 @@ TEST_F(AllowedErrorTests, CreateComputePipelineAsync) { Ref computePipelineMock = ComputePipelineMock::Create(mDeviceMock, &desc); EXPECT_CALL(*computePipelineMock.Get(), Initialize) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); EXPECT_CALL(*mDeviceMock, CreateUninitializedComputePipelineImpl) .WillOnce(Return(ByMove(std::move(computePipelineMock)))); @@ -277,7 +277,7 @@ TEST_F(AllowedErrorTests, CreateRenderPipelineAsync) { Ref renderPipelineMock = RenderPipelineMock::Create(mDeviceMock, &desc); EXPECT_CALL(*renderPipelineMock.Get(), Initialize) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); EXPECT_CALL(*mDeviceMock, CreateUninitializedRenderPipelineImpl) .WillOnce(Return(ByMove(std::move(renderPipelineMock)))); @@ -300,7 +300,7 @@ TEST_F(AllowedErrorTests, CreateRenderPipelineAsync) { // OOM error from buffer creation is allowed and surfaced directly. TEST_F(AllowedErrorTests, CreateBuffer) { EXPECT_CALL(*mDeviceMock, CreateBufferImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the OOM error. EXPECT_CALL(mDeviceErrorCb, Call(WGPUErrorType_OutOfMemory, HasSubstr(kOomErrorMessage), this)) @@ -318,7 +318,7 @@ TEST_F(AllowedErrorTests, CreateBuffer) { // OOM error from texture creation is allowed and surfaced directly. TEST_F(AllowedErrorTests, CreateTexture) { EXPECT_CALL(*mDeviceMock, CreateTextureImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the OOM error. EXPECT_CALL(mDeviceErrorCb, Call(WGPUErrorType_OutOfMemory, HasSubstr(kOomErrorMessage), this)) @@ -337,7 +337,7 @@ TEST_F(AllowedErrorTests, CreateTexture) { // OOM error from query set creation is allowed and surfaced directly. TEST_F(AllowedErrorTests, CreateQuerySet) { EXPECT_CALL(*mDeviceMock, CreateQuerySetImpl) - .WillOnce(Return(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage))); + .WillOnce(Return(ByMove(DAWN_OUT_OF_MEMORY_ERROR(kOomErrorMessage)))); // Expect the OOM error. EXPECT_CALL(mDeviceErrorCb, Call(WGPUErrorType_OutOfMemory, HasSubstr(kOomErrorMessage), this))