Autogenerate all of the wire callback mocks
This makes it less manual code and less error prone to add new callbacks to the wire. Bug: dawn:384 Change-Id: I8547af2dba8289d1badd41e53dd732c776fb5d06 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35600 Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
5ca12a825c
commit
8d38c0164c
|
@ -18,7 +18,7 @@ using namespace testing;
|
|||
|
||||
namespace {
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in c_methods(type) if len(method.arguments) < 10 %}
|
||||
{% for method in c_methods(type) %}
|
||||
{{as_cType(method.return_type.name)}} Forward{{as_MethodSuffix(type.name, method.name)}}(
|
||||
{{-as_cType(type.name)}} self
|
||||
{%- for arg in method.arguments -%}
|
||||
|
@ -44,124 +44,52 @@ void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, WGPUDevice* d
|
|||
*device = GetNewDevice();
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in c_methods(type) if len(method.arguments) < 10 %}
|
||||
{% for method in c_methods(type) %}
|
||||
table->{{as_varName(type.name, method.name)}} = reinterpret_cast<{{as_cProc(type.name, method.name)}}>(Forward{{as_MethodSuffix(type.name, method.name)}});
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
void ProcTableAsClass::DeviceSetUncapturedErrorCallback(WGPUDevice self,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->deviceErrorCallback = callback;
|
||||
object->userdata = userdata;
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in type.methods if has_callback_arguments(method) %}
|
||||
{% set Suffix = as_MethodSuffix(type.name, method.name) %}
|
||||
|
||||
OnDeviceSetUncapturedErrorCallback(self, callback, userdata);
|
||||
}
|
||||
{{as_cType(method.return_type.name)}} ProcTableAsClass::{{Suffix}}(
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in method.arguments -%}
|
||||
, {{as_annotated_cType(arg)}}
|
||||
{%- endfor -%}
|
||||
) {
|
||||
ProcTableAsClass::Object* object = reinterpret_cast<ProcTableAsClass::Object*>({{as_varName(type.name)}});
|
||||
{% for callback_arg in method.arguments if callback_arg.type.category == 'callback' %}
|
||||
object->m{{as_MethodSuffix(type.name, method.name)}}Callback = {{as_varName(callback_arg.name)}};
|
||||
{% endfor %}
|
||||
object->userdata = userdata;
|
||||
return On{{as_MethodSuffix(type.name, method.name)}}(
|
||||
{{-as_varName(type.name)}}
|
||||
{%- for arg in method.arguments -%}
|
||||
, {{as_varName(arg.name)}}
|
||||
{%- endfor -%}
|
||||
);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::DeviceSetDeviceLostCallback(WGPUDevice self,
|
||||
WGPUDeviceLostCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->deviceLostCallback = callback;
|
||||
object->userdata = userdata;
|
||||
|
||||
OnDeviceSetDeviceLostCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
bool ProcTableAsClass::DevicePopErrorScope(WGPUDevice self,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata) {
|
||||
return OnDevicePopErrorScopeCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::BufferMapAsync(WGPUBuffer self,
|
||||
WGPUMapModeFlags mode,
|
||||
size_t offset,
|
||||
size_t size,
|
||||
WGPUBufferMapCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->mapAsyncCallback = callback;
|
||||
object->userdata = userdata;
|
||||
|
||||
OnBufferMapAsyncCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::FenceOnCompletion(WGPUFence self,
|
||||
uint64_t value,
|
||||
WGPUFenceOnCompletionCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->fenceOnCompletionCallback = callback;
|
||||
object->userdata = userdata;
|
||||
|
||||
OnFenceOnCompletionCallback(self, value, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::DeviceCreateReadyComputePipeline(
|
||||
WGPUDevice self,
|
||||
WGPUComputePipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyComputePipelineCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->createReadyComputePipelineCallback = callback;
|
||||
object->userdata = userdata;
|
||||
|
||||
OnDeviceCreateReadyComputePipelineCallback(self, descriptor, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::DeviceCreateReadyRenderPipeline(
|
||||
WGPUDevice self,
|
||||
WGPURenderPipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyRenderPipelineCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->createReadyRenderPipelineCallback = callback;
|
||||
object->userdata = userdata;
|
||||
|
||||
OnDeviceCreateReadyRenderPipelineCallback(self, descriptor, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallDeviceErrorCallback(WGPUDevice device,
|
||||
WGPUErrorType type,
|
||||
const char* message) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
||||
object->deviceErrorCallback(type, message, object->userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallDeviceLostCallback(WGPUDevice device, const char* message) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
||||
object->deviceLostCallback(message, object->userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallMapAsyncCallback(WGPUBuffer buffer, WGPUBufferMapAsyncStatus status) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||
object->mapAsyncCallback(status, object->userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallFenceOnCompletionCallback(WGPUFence fence,
|
||||
WGPUFenceCompletionStatus status) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(fence);
|
||||
object->fenceOnCompletionCallback(status, object->userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallDeviceCreateReadyComputePipelineCallback(WGPUDevice device,
|
||||
WGPUCreateReadyPipelineStatus status,
|
||||
WGPUComputePipeline pipeline,
|
||||
const char* message) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
||||
object->createReadyComputePipelineCallback(status, pipeline, message, object->userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::CallDeviceCreateReadyRenderPipelineCallback(WGPUDevice device,
|
||||
WGPUCreateReadyPipelineStatus status,
|
||||
WGPURenderPipeline pipeline,
|
||||
const char* message) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
||||
object->createReadyRenderPipelineCallback(status, pipeline, message, object->userdata);
|
||||
}
|
||||
{% for callback_arg in method.arguments if callback_arg.type.category == 'callback' %}
|
||||
void ProcTableAsClass::Call{{Suffix}}Callback(
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in callback_arg.type.arguments -%}
|
||||
{%- if not loop.last -%}, {{as_annotated_cType(arg)}}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
) {
|
||||
ProcTableAsClass::Object* object = reinterpret_cast<ProcTableAsClass::Object*>({{as_varName(type.name)}});
|
||||
object->m{{Suffix}}Callback(
|
||||
{%- for arg in callback_arg.type.arguments -%}
|
||||
{%- if not loop.last -%}{{as_varName(arg.name)}}, {% endif -%}
|
||||
{%- endfor -%}
|
||||
object->userdata);
|
||||
}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{{as_cType(type.name)}} ProcTableAsClass::GetNew{{type.name.CamelCase()}}() {
|
||||
|
|
|
@ -39,7 +39,7 @@ class ProcTableAsClass {
|
|||
{% endfor %}
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in type.methods if len(method.arguments) < 10 and not has_callback_arguments(method) %}
|
||||
{% for method in type.methods if not has_callback_arguments(method) %}
|
||||
virtual {{as_cType(method.return_type.name)}} {{as_MethodSuffix(type.name, method.name)}}(
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in method.arguments -%}
|
||||
|
@ -47,87 +47,49 @@ class ProcTableAsClass {
|
|||
{%- endfor -%}
|
||||
) = 0;
|
||||
{% endfor %}
|
||||
|
||||
virtual void {{as_MethodSuffix(type.name, Name("reference"))}}({{as_cType(type.name)}} self) = 0;
|
||||
virtual void {{as_MethodSuffix(type.name, Name("release"))}}({{as_cType(type.name)}} self) = 0;
|
||||
|
||||
{% for method in type.methods if has_callback_arguments(method) %}
|
||||
{% set Suffix = as_MethodSuffix(type.name, method.name) %}
|
||||
//* Stores callback and userdata and calls the On* method.
|
||||
{{as_cType(method.return_type.name)}} {{Suffix}}(
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in method.arguments -%}
|
||||
, {{as_annotated_cType(arg)}}
|
||||
{%- endfor -%}
|
||||
);
|
||||
//* The virtual function to call after saving the callback and userdata in the proc.
|
||||
//* This function can be mocked.
|
||||
virtual {{as_cType(method.return_type.name)}} On{{Suffix}}(
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in method.arguments -%}
|
||||
, {{as_annotated_cType(arg)}}
|
||||
{%- endfor -%}
|
||||
) = 0;
|
||||
|
||||
//* Calls the stored callback.
|
||||
{% for callback_arg in method.arguments if callback_arg.type.category == 'callback' %}
|
||||
void Call{{as_MethodSuffix(type.name, method.name)}}Callback(
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in callback_arg.type.arguments -%}
|
||||
{%- if not loop.last -%}, {{as_annotated_cType(arg)}}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
);
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
// Stores callback and userdata and calls the On* methods
|
||||
void DeviceCreateReadyComputePipeline(WGPUDevice self,
|
||||
WGPUComputePipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyComputePipelineCallback callback,
|
||||
void* userdata);
|
||||
void DeviceCreateReadyRenderPipeline(WGPUDevice self,
|
||||
WGPURenderPipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyRenderPipelineCallback callback,
|
||||
void* userdata);
|
||||
void DeviceSetUncapturedErrorCallback(WGPUDevice self,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata);
|
||||
void DeviceSetDeviceLostCallback(WGPUDevice self,
|
||||
WGPUDeviceLostCallback callback,
|
||||
void* userdata);
|
||||
bool DevicePopErrorScope(WGPUDevice self, WGPUErrorCallback callback, void* userdata);
|
||||
void BufferMapAsync(WGPUBuffer self,
|
||||
WGPUMapModeFlags mode,
|
||||
size_t offset,
|
||||
size_t size,
|
||||
WGPUBufferMapCallback callback,
|
||||
void* userdata);
|
||||
void FenceOnCompletion(WGPUFence self,
|
||||
uint64_t value,
|
||||
WGPUFenceOnCompletionCallback callback,
|
||||
void* userdata);
|
||||
|
||||
// Special cased mockable methods
|
||||
virtual void OnDeviceCreateReadyComputePipelineCallback(
|
||||
WGPUDevice device,
|
||||
WGPUComputePipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyComputePipelineCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnDeviceCreateReadyRenderPipelineCallback(
|
||||
WGPUDevice device,
|
||||
WGPURenderPipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyRenderPipelineCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnDeviceSetUncapturedErrorCallback(WGPUDevice device,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnDeviceSetDeviceLostCallback(WGPUDevice device,
|
||||
WGPUDeviceLostCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual bool OnDevicePopErrorScopeCallback(WGPUDevice device,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnBufferMapAsyncCallback(WGPUBuffer buffer,
|
||||
WGPUBufferMapCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnFenceOnCompletionCallback(WGPUFence fence,
|
||||
uint64_t value,
|
||||
WGPUFenceOnCompletionCallback callback,
|
||||
void* userdata) = 0;
|
||||
|
||||
// Calls the stored callbacks
|
||||
void CallDeviceCreateReadyComputePipelineCallback(WGPUDevice device,
|
||||
WGPUCreateReadyPipelineStatus status,
|
||||
WGPUComputePipeline pipeline,
|
||||
const char* message);
|
||||
void CallDeviceCreateReadyRenderPipelineCallback(WGPUDevice device,
|
||||
WGPUCreateReadyPipelineStatus status,
|
||||
WGPURenderPipeline pipeline,
|
||||
const char* message);
|
||||
void CallDeviceErrorCallback(WGPUDevice device, WGPUErrorType type, const char* message);
|
||||
void CallDeviceLostCallback(WGPUDevice device, const char* message);
|
||||
void CallMapAsyncCallback(WGPUBuffer buffer, WGPUBufferMapAsyncStatus status);
|
||||
void CallFenceOnCompletionCallback(WGPUFence fence, WGPUFenceCompletionStatus status);
|
||||
|
||||
struct Object {
|
||||
ProcTableAsClass* procs = nullptr;
|
||||
WGPUErrorCallback deviceErrorCallback = nullptr;
|
||||
WGPUCreateReadyComputePipelineCallback createReadyComputePipelineCallback = nullptr;
|
||||
WGPUCreateReadyRenderPipelineCallback createReadyRenderPipelineCallback = nullptr;
|
||||
WGPUDeviceLostCallback deviceLostCallback = nullptr;
|
||||
WGPUBufferMapCallback mapAsyncCallback = nullptr;
|
||||
WGPUFenceOnCompletionCallback fenceOnCompletionCallback = nullptr;
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in type.methods if has_callback_arguments(method) %}
|
||||
{% for callback_arg in method.arguments if callback_arg.type.category == 'callback' %}
|
||||
{{as_cType(callback_arg.type.name)}} m{{as_MethodSuffix(type.name, method.name)}}Callback = nullptr;
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
void* userdata = 0;
|
||||
};
|
||||
|
||||
|
@ -144,7 +106,7 @@ class MockProcTable : public ProcTableAsClass {
|
|||
void IgnoreAllReleaseCalls();
|
||||
|
||||
{% for type in by_category["object"] %}
|
||||
{% for method in type.methods if len(method.arguments) < 10 and not has_callback_arguments(method) %}
|
||||
{% for method in type.methods if not has_callback_arguments(method) %}
|
||||
MOCK_METHOD({{as_cType(method.return_type.name)}},{{" "}}
|
||||
{{-as_MethodSuffix(type.name, method.name)}}, (
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
|
@ -156,28 +118,17 @@ class MockProcTable : public ProcTableAsClass {
|
|||
|
||||
MOCK_METHOD(void, {{as_MethodSuffix(type.name, Name("reference"))}}, ({{as_cType(type.name)}} self), (override));
|
||||
MOCK_METHOD(void, {{as_MethodSuffix(type.name, Name("release"))}}, ({{as_cType(type.name)}} self), (override));
|
||||
{% endfor %}
|
||||
|
||||
MOCK_METHOD(void,
|
||||
OnDeviceCreateReadyComputePipelineCallback,
|
||||
(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyComputePipelineCallback callback,
|
||||
void* userdata),
|
||||
(override));
|
||||
MOCK_METHOD(void,
|
||||
OnDeviceCreateReadyRenderPipelineCallback,
|
||||
(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor,
|
||||
WGPUCreateReadyRenderPipelineCallback callback,
|
||||
void* userdata),
|
||||
(override));
|
||||
MOCK_METHOD(void, OnDeviceSetUncapturedErrorCallback, (WGPUDevice device, WGPUErrorCallback callback, void* userdata), (override));
|
||||
MOCK_METHOD(void, OnDeviceSetDeviceLostCallback, (WGPUDevice device, WGPUDeviceLostCallback callback, void* userdata), (override));
|
||||
MOCK_METHOD(bool, OnDevicePopErrorScopeCallback, (WGPUDevice device, WGPUErrorCallback callback, void* userdata), (override));
|
||||
MOCK_METHOD(void,
|
||||
OnBufferMapAsyncCallback,
|
||||
(WGPUBuffer buffer, WGPUBufferMapCallback callback, void* userdata),
|
||||
(override));
|
||||
MOCK_METHOD(void, OnFenceOnCompletionCallback, (WGPUFence fence, uint64_t value, WGPUFenceOnCompletionCallback callback, void* userdata), (override));
|
||||
{% for method in type.methods if has_callback_arguments(method) %}
|
||||
MOCK_METHOD({{as_cType(method.return_type.name)}},{{" "-}}
|
||||
On{{as_MethodSuffix(type.name, method.name)}}, (
|
||||
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
||||
{%- for arg in method.arguments -%}
|
||||
, {{as_annotated_cType(arg)}}
|
||||
{%- endfor -%}
|
||||
), (override));
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
#endif // MOCK_WEBGPU_H
|
||||
|
|
|
@ -40,13 +40,12 @@ class MockFenceOnCompletionCallback {
|
|||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallbackFails(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
static void ToMockFenceOnCompletionFails(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
EXPECT_EQ(WGPUFenceCompletionStatus_DeviceLost, status);
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
mockFenceOnCompletionCallback = nullptr;
|
||||
}
|
||||
static void ToMockFenceOnCompletionCallbackSucceeds(WGPUFenceCompletionStatus status,
|
||||
void* userdata) {
|
||||
static void ToMockFenceOnCompletionSucceeds(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
EXPECT_EQ(WGPUFenceCompletionStatus_Success, status);
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
mockFenceOnCompletionCallback = nullptr;
|
||||
|
@ -429,7 +428,7 @@ TEST_P(DeviceLostTest, QueueSignalFenceFails) {
|
|||
// callback should have device lost status
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_DeviceLost, nullptr))
|
||||
.Times(1);
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallbackFails, nullptr));
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionFails, nullptr));
|
||||
|
||||
// completed value should not have changed from initial value
|
||||
EXPECT_EQ(fence.GetCompletedValue(), descriptor.initialValue);
|
||||
|
@ -447,7 +446,7 @@ TEST_P(DeviceLostTest, FenceOnCompletionFails) {
|
|||
// callback should have device lost status
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_DeviceLost, nullptr))
|
||||
.Times(1);
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallbackFails, nullptr));
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionFails, nullptr));
|
||||
ASSERT_DEVICE_ERROR(device.Tick());
|
||||
|
||||
// completed value should not have changed from initial value
|
||||
|
@ -466,7 +465,7 @@ TEST_P(DeviceLostTest, FenceOnCompletionBeforeLossFails) {
|
|||
// callback should have device lost status
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_DeviceLost, nullptr))
|
||||
.Times(1);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallbackFails, nullptr);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionFails, nullptr);
|
||||
SetCallbackAndLoseForTesting();
|
||||
ASSERT_DEVICE_ERROR(device.Tick());
|
||||
|
||||
|
@ -499,7 +498,7 @@ TEST_P(DeviceLostTest, FenceSignalTickOnCompletion) {
|
|||
// callback should have device lost status
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
|
||||
.Times(1);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallbackSucceeds, nullptr);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionSucceeds, nullptr);
|
||||
SetCallbackAndLoseForTesting();
|
||||
|
||||
EXPECT_EQ(fence.GetCompletedValue(), 2u);
|
||||
|
|
|
@ -26,7 +26,7 @@ class MockFenceOnCompletionCallback {
|
|||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
static void ToMockFenceOnCompletion(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
|
@ -121,10 +121,10 @@ TEST_P(FenceTests, OnCompletionOrdering) {
|
|||
.Times(1);
|
||||
}
|
||||
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, this + 2);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletion, this + 0);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletion, this + 3);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletion, this + 1);
|
||||
|
||||
WaitForCompletedValue(fence, 4);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ TEST_P(FenceTests, MultipleSignalOnCompletion) {
|
|||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
|
||||
.Times(1);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletion, nullptr);
|
||||
|
||||
WaitForCompletedValue(fence, 4);
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ TEST_P(FenceTests, SignalOnCompletionWait) {
|
|||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 6))
|
||||
.Times(1);
|
||||
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(5u, ToMockFenceOnCompletionCallback, this + 6);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletion, this + 2);
|
||||
fence.OnCompletion(5u, ToMockFenceOnCompletion, this + 6);
|
||||
|
||||
WaitForCompletedValue(fence, 6);
|
||||
}
|
||||
|
@ -169,13 +169,13 @@ TEST_P(FenceTests, SignalOnCompletionWaitStaggered) {
|
|||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 2))
|
||||
.Times(1);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletion, this + 2);
|
||||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 4))
|
||||
.Times(1);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, this + 4);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletion, this + 4);
|
||||
|
||||
WaitForCompletedValue(fence, 4);
|
||||
}
|
||||
|
@ -198,10 +198,10 @@ TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
|
|||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 3))
|
||||
.Times(1);
|
||||
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletion, this + 0);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletion, this + 1);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletion, this + 2);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletion, this + 3);
|
||||
|
||||
WaitForCompletedValue(fence, 4u);
|
||||
}
|
||||
|
@ -233,10 +233,10 @@ TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
|
|||
Call(WGPUFenceCompletionStatus_Unknown, this + 3))
|
||||
.Times(1);
|
||||
|
||||
testFence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
testFence.OnCompletion(3u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
testFence.OnCompletion(1u, ToMockFenceOnCompletion, this + 0);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletion, this + 1);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletion, this + 2);
|
||||
testFence.OnCompletion(3u, ToMockFenceOnCompletion, this + 3);
|
||||
}
|
||||
|
||||
// Wait for another fence to be sure all callbacks have cleared
|
||||
|
|
|
@ -34,7 +34,7 @@ class MockFenceOnCompletionCallback {
|
|||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
static void ToMockFenceOnCompletion(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
EXPECT_EQ(status, WGPUFenceCompletionStatus_Success);
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ TEST_P(QueueTimelineTests, MapReadSignalOnComplete) {
|
|||
wgpu::Fence fence = queue.CreateFence();
|
||||
|
||||
queue.Signal(fence, 1);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletion, this);
|
||||
|
||||
WaitForAllOperations();
|
||||
mMapReadBuffer.Unmap();
|
||||
|
@ -96,7 +96,7 @@ TEST_P(QueueTimelineTests, SignalMapReadOnComplete) {
|
|||
|
||||
mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this);
|
||||
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, this);
|
||||
WaitForAllOperations();
|
||||
mMapReadBuffer.Unmap();
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ TEST_P(QueueTimelineTests, SignalOnCompleteMapRead) {
|
|||
wgpu::Fence fence = queue.CreateFence();
|
||||
queue.Signal(fence, 2);
|
||||
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, this);
|
||||
|
||||
mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this);
|
||||
|
||||
|
@ -141,17 +141,17 @@ TEST_P(QueueTimelineTests, SurroundWithFenceSignals) {
|
|||
queue.Signal(fence, 2);
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletion, this + 0);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, this + 2);
|
||||
|
||||
mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this);
|
||||
queue.Signal(fence, 6);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
fence.OnCompletion(5u, ToMockFenceOnCompletionCallback, this + 5);
|
||||
fence.OnCompletion(6u, ToMockFenceOnCompletionCallback, this + 6);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletion, this + 3);
|
||||
fence.OnCompletion(5u, ToMockFenceOnCompletion, this + 5);
|
||||
fence.OnCompletion(6u, ToMockFenceOnCompletion, this + 6);
|
||||
|
||||
queue.Signal(fence, 8);
|
||||
fence.OnCompletion(8u, ToMockFenceOnCompletionCallback, this + 8);
|
||||
fence.OnCompletion(8u, ToMockFenceOnCompletion, this + 8);
|
||||
|
||||
WaitForAllOperations();
|
||||
mMapReadBuffer.Unmap();
|
||||
|
|
|
@ -30,7 +30,7 @@ struct FenceOnCompletionExpectation {
|
|||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
static void ToMockFenceOnCompletion(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class FenceValidationTest : public ValidationTest {
|
|||
expectation->status = status;
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(status, expectation)).Times(1);
|
||||
fence.OnCompletion(value, ToMockFenceOnCompletionCallback, expectation);
|
||||
fence.OnCompletion(value, ToMockFenceOnCompletion, expectation);
|
||||
}
|
||||
|
||||
wgpu::Queue queue;
|
||||
|
@ -99,11 +99,11 @@ TEST_F(FenceValidationTest, OnCompletionImmediate) {
|
|||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 0))
|
||||
.Times(1);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletion, this + 0);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 1))
|
||||
.Times(1);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletion, this + 1);
|
||||
}
|
||||
|
||||
// Test setting OnCompletion handlers for values > signaled value
|
||||
|
@ -115,13 +115,13 @@ TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) {
|
|||
// Cannot signal for values > signaled value
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Error, nullptr))
|
||||
.Times(1);
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr));
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr));
|
||||
|
||||
// Can set handler after signaling
|
||||
queue.Signal(fence, 2);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
|
||||
.Times(1);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr);
|
||||
|
||||
WaitForAllOperations(device);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
|
|||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
|
||||
queue.Signal(fence, 3);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
|
||||
.WillOnce(Invoke([&](WGPUFenceCompletionStatus status, void* userdata) {
|
||||
EXPECT_EQ(fence.GetCompletedValue(), 3u);
|
||||
|
@ -147,7 +147,7 @@ TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) {
|
|||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
|
||||
queue.Signal(fence, 2);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
|
||||
.Times(1);
|
||||
|
||||
|
|
|
@ -91,9 +91,10 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -117,9 +118,9 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
|||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
FlushClient();
|
||||
|
||||
|
@ -137,9 +138,10 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
|||
|
||||
// Return success
|
||||
uint32_t bufferContent = 0;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -160,9 +162,10 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -186,9 +189,9 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
|||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForReadButServerSideError) {
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
// Oh no! We are calling Unmap too early! However the callback gets fired only after we get
|
||||
// an answer from the server that the mapAsync call was an error.
|
||||
|
@ -210,9 +213,10 @@ TEST_F(WireBufferMappingTests, DestroyCalledTooEarlyForRead) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -236,9 +240,9 @@ TEST_F(WireBufferMappingTests, DestroyCalledTooEarlyForRead) {
|
|||
TEST_F(WireBufferMappingTests, DestroyCalledTooEarlyForReadButServerSideError) {
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
// Oh no! We are calling Destroy too early! However the callback gets fired only after we get
|
||||
// an answer from the server that the mapAsync call was an error.
|
||||
|
@ -260,9 +264,10 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -274,9 +279,9 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
// Map failure while the buffer is already mapped
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
FlushClient();
|
||||
|
||||
|
@ -292,9 +297,10 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -316,9 +322,10 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -343,9 +350,10 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
|||
uint32_t serverBufferContent = 31337;
|
||||
uint32_t updatedContent = 4242;
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&serverBufferContent));
|
||||
|
||||
|
@ -377,9 +385,9 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
|||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
FlushClient();
|
||||
|
||||
|
@ -397,9 +405,10 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
|||
|
||||
// Return success
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -420,9 +429,10 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -443,9 +453,10 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -457,9 +468,9 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
// Map failure while the buffer is already mapped
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
FlushClient();
|
||||
|
||||
|
@ -475,9 +486,10 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -499,9 +511,10 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
|||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&bufferContent));
|
||||
|
||||
|
@ -584,9 +597,10 @@ TEST_F(WireBufferMappingTests, MappedAtCreationThenMapSuccess) {
|
|||
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&apiBufferData));
|
||||
|
||||
|
@ -615,9 +629,9 @@ TEST_F(WireBufferMappingTests, MappedAtCreationThenMapFailure) {
|
|||
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
FlushClient();
|
||||
|
||||
|
@ -682,9 +696,10 @@ TEST_F(WireBufferMappingTests, MaxSizeMappableBufferOOMDirectly) {
|
|||
TEST_F(WireBufferMappingTests, MapThenDisconnect) {
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Write, 0, kBufferSize, ToMockBufferMapCallback, this);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize)).Times(1);
|
||||
|
||||
FlushClient();
|
||||
|
|
|
@ -106,7 +106,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineSuccess) {
|
|||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
||||
ToMockCreateReadyComputePipelineCallback, this);
|
||||
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipelineCallback(apiDevice, _, _, _))
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipeline(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateReadyComputePipelineCallback(
|
||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
||||
|
@ -135,7 +135,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineError) {
|
|||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
||||
ToMockCreateReadyComputePipelineCallback, this);
|
||||
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipelineCallback(apiDevice, _, _, _))
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipeline(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateReadyComputePipelineCallback(
|
||||
apiDevice, WGPUCreateReadyPipelineStatus_Error, nullptr, "Some error message");
|
||||
|
@ -168,7 +168,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineSuccess) {
|
|||
|
||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
||||
ToMockCreateReadyRenderPipelineCallback, this);
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipelineCallback(apiDevice, _, _, _))
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateReadyRenderPipelineCallback(
|
||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
||||
|
@ -201,7 +201,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineError) {
|
|||
|
||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
||||
ToMockCreateReadyRenderPipelineCallback, this);
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipelineCallback(apiDevice, _, _, _))
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateReadyRenderPipelineCallback(
|
||||
apiDevice, WGPUCreateReadyPipelineStatus_Error, nullptr, "Some error message");
|
||||
|
@ -235,7 +235,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineThenDisconnect) {
|
|||
|
||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
||||
ToMockCreateReadyRenderPipelineCallback, this);
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipelineCallback(apiDevice, _, _, _))
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyRenderPipeline(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateReadyRenderPipelineCallback(
|
||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
||||
|
@ -263,7 +263,7 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineThenDisconnect) {
|
|||
|
||||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
||||
ToMockCreateReadyComputePipelineCallback, this);
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipelineCallback(apiDevice, _, _, _))
|
||||
EXPECT_CALL(api, OnDeviceCreateReadyComputePipeline(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateReadyComputePipelineCallback(
|
||||
apiDevice, WGPUCreateReadyPipelineStatus_Success, nullptr, "");
|
||||
|
|
|
@ -80,7 +80,7 @@ TEST_F(WireDisconnectTests, ServerLostThenDisconnect) {
|
|||
wgpuDeviceSetDeviceLostCallback(device, mockDeviceLostCallback.Callback(),
|
||||
mockDeviceLostCallback.MakeUserdata(this));
|
||||
|
||||
api.CallDeviceLostCallback(apiDevice, "some reason");
|
||||
api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, "some reason");
|
||||
|
||||
// Flush the device lost return command.
|
||||
EXPECT_CALL(mockDeviceLostCallback, Call(StrEq("some reason"), this)).Times(Exactly(1));
|
||||
|
@ -98,7 +98,7 @@ TEST_F(WireDisconnectTests, ServerLostThenDisconnectInCallback) {
|
|||
wgpuDeviceSetDeviceLostCallback(device, mockDeviceLostCallback.Callback(),
|
||||
mockDeviceLostCallback.MakeUserdata(this));
|
||||
|
||||
api.CallDeviceLostCallback(apiDevice, "lost reason");
|
||||
api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, "lost reason");
|
||||
|
||||
// Disconnect the client inside the lost callback. We should see the callback
|
||||
// only once.
|
||||
|
@ -122,7 +122,7 @@ TEST_F(WireDisconnectTests, DisconnectThenServerLost) {
|
|||
|
||||
// Lose the device on the server. The client callback shouldn't be
|
||||
// called again.
|
||||
api.CallDeviceLostCallback(apiDevice, "lost reason");
|
||||
api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, "lost reason");
|
||||
EXPECT_CALL(mockDeviceLostCallback, Call(_, _)).Times(Exactly(0));
|
||||
FlushServer();
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ TEST_F(WireErrorCallbackTests, DeviceErrorCallback) {
|
|||
|
||||
// Calling the callback on the server side will result in the callback being called on the
|
||||
// client side
|
||||
api.CallDeviceErrorCallback(apiDevice, WGPUErrorType_Validation, "Some error message");
|
||||
api.CallDeviceSetUncapturedErrorCallbackCallback(apiDevice, WGPUErrorType_Validation,
|
||||
"Some error message");
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback,
|
||||
Call(WGPUErrorType_Validation, StrEq("Some error message"), this))
|
||||
|
@ -116,7 +117,7 @@ TEST_F(WireErrorCallbackTests, PushPopErrorScopeCallback) {
|
|||
|
||||
WGPUErrorCallback callback;
|
||||
void* userdata;
|
||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
|
||||
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
|
||||
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true)));
|
||||
|
||||
FlushClient();
|
||||
|
@ -146,7 +147,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
|
|||
WGPUErrorCallback callback2;
|
||||
void* userdata1;
|
||||
void* userdata2;
|
||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
|
||||
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
|
||||
.WillOnce(DoAll(SaveArg<1>(&callback1), SaveArg<2>(&userdata1), Return(true)))
|
||||
.WillOnce(DoAll(SaveArg<1>(&callback2), SaveArg<2>(&userdata2), Return(true)));
|
||||
|
||||
|
@ -180,7 +181,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
|
|||
WGPUErrorCallback callback2;
|
||||
void* userdata1;
|
||||
void* userdata2;
|
||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
|
||||
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
|
||||
.WillOnce(DoAll(SaveArg<1>(&callback1), SaveArg<2>(&userdata1), Return(true)))
|
||||
.WillOnce(DoAll(SaveArg<1>(&callback2), SaveArg<2>(&userdata2), Return(true)));
|
||||
|
||||
|
@ -209,7 +210,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeDeviceDestroyed) {
|
|||
|
||||
EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
|
||||
|
||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)).WillOnce(Return(true));
|
||||
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _)).WillOnce(Return(true));
|
||||
FlushClient();
|
||||
|
||||
// Incomplete callback called in Device destructor.
|
||||
|
@ -225,7 +226,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeThenDisconnect) {
|
|||
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(1);
|
||||
|
||||
EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
|
||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)).WillOnce(Return(true));
|
||||
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _)).WillOnce(Return(true));
|
||||
|
||||
FlushClient();
|
||||
|
||||
|
@ -266,7 +267,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeEmptyStack) {
|
|||
|
||||
WGPUErrorCallback callback;
|
||||
void* userdata;
|
||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
|
||||
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
|
||||
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true)));
|
||||
|
||||
FlushClient();
|
||||
|
@ -289,7 +290,7 @@ TEST_F(WireErrorCallbackTests, DeviceLostCallback) {
|
|||
|
||||
// Calling the callback on the server side will result in the callback being called on the
|
||||
// client side
|
||||
api.CallDeviceLostCallback(apiDevice, "Some error message");
|
||||
api.CallDeviceSetDeviceLostCallbackCallback(apiDevice, "Some error message");
|
||||
|
||||
EXPECT_CALL(*mockDeviceLostCallback, Call(StrEq("Some error message"), this)).Times(1);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace {
|
|||
};
|
||||
|
||||
std::unique_ptr<StrictMock<MockFenceOnCompletionCallback>> mockFenceOnCompletionCallback;
|
||||
void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
void ToMockFenceOnCompletion(WGPUFenceCompletionStatus status, void* userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class WireFenceTests : public WireTest {
|
|||
|
||||
// This callback is generated to update the completedValue of the fence
|
||||
// on the client
|
||||
EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, signalValue, _, _))
|
||||
EXPECT_CALL(api, OnFenceOnCompletion(apiFence, signalValue, _, _))
|
||||
.WillOnce(
|
||||
InvokeWithoutArgs([=]() { api.CallFenceOnCompletionCallback(apiFence, status); }))
|
||||
.RetiresOnSaturation();
|
||||
|
@ -120,11 +120,10 @@ TEST_F(WireFenceTests, QueueSignalValidationError) {
|
|||
|
||||
// Check that a success in the on completion callback is forwarded to the client.
|
||||
TEST_F(WireFenceTests, OnCompletionSuccess) {
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, nullptr);
|
||||
EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, 0u, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Success);
|
||||
}));
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletion, nullptr);
|
||||
EXPECT_CALL(api, OnFenceOnCompletion(apiFence, 0u, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Success);
|
||||
}));
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, _))
|
||||
|
@ -134,11 +133,10 @@ TEST_F(WireFenceTests, OnCompletionSuccess) {
|
|||
|
||||
// Check that an error in the on completion callback is forwarded to the client.
|
||||
TEST_F(WireFenceTests, OnCompletionError) {
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, nullptr);
|
||||
EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, 0u, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Error);
|
||||
}));
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletion, nullptr);
|
||||
EXPECT_CALL(api, OnFenceOnCompletion(apiFence, 0u, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Error);
|
||||
}));
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Error, _)).Times(1);
|
||||
|
@ -148,11 +146,10 @@ TEST_F(WireFenceTests, OnCompletionError) {
|
|||
// Test that registering a callback then wire disconnect calls the callback with
|
||||
// DeviceLost.
|
||||
TEST_F(WireFenceTests, OnCompletionThenDisconnect) {
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, this);
|
||||
EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, 0u, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Success);
|
||||
}));
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletion, this);
|
||||
EXPECT_CALL(api, OnFenceOnCompletion(apiFence, 0u, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Success);
|
||||
}));
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_DeviceLost, this))
|
||||
|
@ -167,16 +164,16 @@ TEST_F(WireFenceTests, OnCompletionAfterDisconnect) {
|
|||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_DeviceLost, this))
|
||||
.Times(1);
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, this);
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletion, this);
|
||||
}
|
||||
|
||||
// Without any flushes, it is valid to wait on a value less than or equal to
|
||||
// the last signaled value
|
||||
TEST_F(WireFenceTests, OnCompletionSynchronousValidationSuccess) {
|
||||
wgpuQueueSignal(queue, fence, 4u);
|
||||
wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, 0);
|
||||
wgpuFenceOnCompletion(fence, 3u, ToMockFenceOnCompletionCallback, 0);
|
||||
wgpuFenceOnCompletion(fence, 4u, ToMockFenceOnCompletionCallback, 0);
|
||||
wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletion, 0);
|
||||
wgpuFenceOnCompletion(fence, 3u, ToMockFenceOnCompletion, 0);
|
||||
wgpuFenceOnCompletion(fence, 4u, ToMockFenceOnCompletion, 0);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Unknown, _))
|
||||
.Times(3);
|
||||
|
@ -202,8 +199,8 @@ TEST_F(WireFenceTests, GetCompletedValueUpdateInCallback) {
|
|||
DoQueueSignal(3u);
|
||||
|
||||
// Register the callback
|
||||
wgpuFenceOnCompletion(fence, 3u, ToMockFenceOnCompletionCallback, this);
|
||||
EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, 3u, _, _))
|
||||
wgpuFenceOnCompletion(fence, 3u, ToMockFenceOnCompletion, this);
|
||||
EXPECT_CALL(api, OnFenceOnCompletion(apiFence, 3u, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Success);
|
||||
}))
|
||||
|
@ -226,7 +223,7 @@ TEST_F(WireFenceTests, GetCompletedValueNoUpdate) {
|
|||
// before the completed value is updated
|
||||
TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) {
|
||||
wgpuQueueSignal(queue, fence, 3u);
|
||||
wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletion, nullptr);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Unknown, _))
|
||||
.Times(1);
|
||||
}
|
||||
|
|
|
@ -346,9 +346,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
|
|||
ExpectServerReadHandleInitialize(serverHandle);
|
||||
|
||||
// Mock a successful callback
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mBufferContent));
|
||||
|
||||
|
@ -389,9 +390,9 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
|
|||
ServerReadHandle* serverHandle = ExpectServerReadHandleDeserialize();
|
||||
|
||||
// Mock a failed callback.
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
// Since the mapping failed, the handle is immediately destroyed.
|
||||
EXPECT_CALL(serverMemoryTransferService, OnReadHandleDestroy(serverHandle)).Times(1);
|
||||
|
@ -475,9 +476,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailur
|
|||
ExpectServerReadHandleInitialize(serverHandle);
|
||||
|
||||
// Mock a successful callback
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mBufferContent));
|
||||
|
||||
|
@ -518,9 +520,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDestroyBeforeUnmap) {
|
|||
ExpectServerReadHandleInitialize(serverHandle);
|
||||
|
||||
// Mock a successful callback
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Read, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mBufferContent));
|
||||
|
||||
|
@ -568,9 +571,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
|
|||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||
|
||||
// Mock a successful callback.
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mMappedBufferContent));
|
||||
|
||||
|
@ -620,9 +624,9 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
|
|||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||
|
||||
// Mock an error callback.
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs(
|
||||
[&]() { api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error); }));
|
||||
|
||||
// Since the mapping fails, the handle is immediately destroyed because it won't be written.
|
||||
EXPECT_CALL(serverMemoryTransferService, OnWriteHandleDestroy(serverHandle)).Times(1);
|
||||
|
@ -703,9 +707,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) {
|
|||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||
|
||||
// Mock a successful callback.
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mMappedBufferContent));
|
||||
|
||||
|
@ -742,9 +747,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) {
|
|||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||
|
||||
// Mock a successful callback.
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mMappedBufferContent));
|
||||
|
||||
|
@ -791,9 +797,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDestroyBeforeUnmap) {
|
|||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||
|
||||
// Mock a successful callback.
|
||||
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, OnBufferMapAsync(apiBuffer, WGPUMapMode_Write, 0, kBufferSize, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallBufferMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||
}));
|
||||
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer, 0, kBufferSize))
|
||||
.WillOnce(Return(&mMappedBufferContent));
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ class WireMultipleDeviceTests : public testing::Test {
|
|||
.WillOnce(Invoke([&](WGPUDevice device, WGPUErrorType type, const char* message) {
|
||||
errorMessage = message;
|
||||
// Mock the call to the error callback.
|
||||
wire->Api()->CallDeviceErrorCallback(device, type, message);
|
||||
wire->Api()->CallDeviceSetUncapturedErrorCallbackCallback(device, type, message);
|
||||
}));
|
||||
wire->FlushClient();
|
||||
|
||||
|
|
Loading…
Reference in New Issue