Use new gmock MOCK_FUNCTION macro.

Bug: None
Change-Id: If436fbf5c2392051caeadfc4a7482544d565b597
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19720
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-04-16 16:39:06 +00:00 committed by Commit Bot service account
parent d3bbcc3334
commit f941205370
13 changed files with 114 additions and 110 deletions

View File

@ -121,31 +121,25 @@ class MockProcTable : public ProcTableAsClass {
{% for type in by_category["object"] %} {% 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 len(method.arguments) < 10 and not has_callback_arguments(method) %}
MOCK_METHOD{{len(method.arguments) + 1}}( MOCK_METHOD({{as_cType(method.return_type.name)}},{{" "}}
{{-as_MethodSuffix(type.name, method.name)}}, {{-as_MethodSuffix(type.name, method.name)}}, (
{{as_cType(method.return_type.name)}}(
{{-as_cType(type.name)}} {{as_varName(type.name)}} {{-as_cType(type.name)}} {{as_varName(type.name)}}
{%- for arg in method.arguments -%} {%- for arg in method.arguments -%}
, {{as_annotated_cType(arg)}} , {{as_annotated_cType(arg)}}
{%- endfor -%} {%- endfor -%}
)); ), (override));
{% endfor %} {% endfor %}
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("reference"))}}, void({{as_cType(type.name)}} self)); MOCK_METHOD(void, {{as_MethodSuffix(type.name, Name("reference"))}}, ({{as_cType(type.name)}} self), (override));
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self)); MOCK_METHOD(void, {{as_MethodSuffix(type.name, Name("release"))}}, ({{as_cType(type.name)}} self), (override));
{% endfor %} {% endfor %}
MOCK_METHOD3(OnDeviceSetUncapturedErrorCallback, void(WGPUDevice device, WGPUErrorCallback callback, void* userdata)); MOCK_METHOD(void, OnDeviceSetUncapturedErrorCallback, (WGPUDevice device, WGPUErrorCallback callback, void* userdata), (override));
MOCK_METHOD3(OnDeviceSetDeviceLostCallback, MOCK_METHOD(void, OnDeviceSetDeviceLostCallback, (WGPUDevice device, WGPUDeviceLostCallback callback, void* userdata), (override));
void(WGPUDevice device, WGPUDeviceLostCallback callback, void* userdata)); MOCK_METHOD(bool, OnDevicePopErrorScopeCallback, (WGPUDevice device, WGPUErrorCallback callback, void* userdata), (override));
MOCK_METHOD3(OnDevicePopErrorScopeCallback, bool(WGPUDevice device, WGPUErrorCallback callback, void* userdata)); MOCK_METHOD(void, OnBufferMapReadAsyncCallback, (WGPUBuffer buffer, WGPUBufferMapReadCallback callback, void* userdata), (override));
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(WGPUBuffer buffer, WGPUBufferMapReadCallback callback, void* userdata)); MOCK_METHOD(void, OnBufferMapWriteAsyncCallback, (WGPUBuffer buffer, WGPUBufferMapWriteCallback callback, void* userdata), (override));
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(WGPUBuffer buffer, WGPUBufferMapWriteCallback callback, void* userdata)); MOCK_METHOD(void, OnFenceOnCompletionCallback, (WGPUFence fence, uint64_t value, WGPUFenceOnCompletionCallback callback, void* userdata), (override));
MOCK_METHOD4(OnFenceOnCompletionCallback,
void(WGPUFence fence,
uint64_t value,
WGPUFenceOnCompletionCallback callback,
void* userdata));
}; };
#endif // MOCK_WEBGPU_H #endif // MOCK_WEBGPU_H

View File

@ -64,27 +64,30 @@ namespace dawn_wire { namespace client {
MockReadHandle* NewReadHandle(); MockReadHandle* NewReadHandle();
MockWriteHandle* NewWriteHandle(); MockWriteHandle* NewWriteHandle();
MOCK_METHOD1(OnCreateReadHandle, ReadHandle*(size_t)); MOCK_METHOD(ReadHandle*, OnCreateReadHandle, (size_t));
MOCK_METHOD1(OnCreateWriteHandle, WriteHandle*(size_t)); MOCK_METHOD(WriteHandle*, OnCreateWriteHandle, (size_t));
MOCK_METHOD1(OnReadHandleSerializeCreateSize, size_t(const ReadHandle*)); MOCK_METHOD(size_t, OnReadHandleSerializeCreateSize, (const ReadHandle*));
MOCK_METHOD2(OnReadHandleSerializeCreate, void(const ReadHandle*, void* serializePointer)); MOCK_METHOD(void, OnReadHandleSerializeCreate, (const ReadHandle*, void* serializePointer));
MOCK_METHOD5(OnReadHandleDeserializeInitialData, MOCK_METHOD(bool,
bool(const ReadHandle*, OnReadHandleDeserializeInitialData,
const uint32_t* deserializePointer, (const ReadHandle*,
size_t deserializeSize, const uint32_t* deserializePointer,
const void** data, size_t deserializeSize,
size_t* dataLength)); const void** data,
MOCK_METHOD1(OnReadHandleDestroy, void(const ReadHandle*)); size_t* dataLength));
MOCK_METHOD(void, OnReadHandleDestroy, (const ReadHandle*));
MOCK_METHOD1(OnWriteHandleSerializeCreateSize, size_t(const void* WriteHandle)); MOCK_METHOD(size_t, OnWriteHandleSerializeCreateSize, (const void* WriteHandle));
MOCK_METHOD2(OnWriteHandleSerializeCreate, MOCK_METHOD(void,
void(const void* WriteHandle, void* serializePointer)); OnWriteHandleSerializeCreate,
MOCK_METHOD1(OnWriteHandleOpen, std::pair<void*, size_t>(const void* WriteHandle)); (const void* WriteHandle, void* serializePointer));
MOCK_METHOD1(OnWriteHandleSerializeFlushSize, size_t(const void* WriteHandle)); MOCK_METHOD((std::pair<void*, size_t>), OnWriteHandleOpen, (const void* WriteHandle));
MOCK_METHOD2(OnWriteHandleSerializeFlush, MOCK_METHOD(size_t, OnWriteHandleSerializeFlushSize, (const void* WriteHandle));
void(const void* WriteHandle, void* serializePointer)); MOCK_METHOD(void,
MOCK_METHOD1(OnWriteHandleDestroy, void(const void* WriteHandle)); OnWriteHandleSerializeFlush,
(const void* WriteHandle, void* serializePointer));
MOCK_METHOD(void, OnWriteHandleDestroy, (const void* WriteHandle));
}; };
}} // namespace dawn_wire::client }} // namespace dawn_wire::client

View File

@ -65,30 +65,35 @@ namespace dawn_wire { namespace server {
MockReadHandle* NewReadHandle(); MockReadHandle* NewReadHandle();
MockWriteHandle* NewWriteHandle(); MockWriteHandle* NewWriteHandle();
MOCK_METHOD3(OnDeserializeReadHandle, MOCK_METHOD(bool,
bool(const uint32_t* deserializePointer, OnDeserializeReadHandle,
size_t deserializeSize, (const uint32_t* deserializePointer,
ReadHandle** readHandle)); size_t deserializeSize,
ReadHandle** readHandle));
MOCK_METHOD3(OnDeserializeWriteHandle, MOCK_METHOD(bool,
bool(const uint32_t* deserializePointer, OnDeserializeWriteHandle,
size_t deserializeSize, (const uint32_t* deserializePointer,
WriteHandle** writeHandle)); size_t deserializeSize,
WriteHandle** writeHandle));
MOCK_METHOD3(OnReadHandleSerializeInitialDataSize, MOCK_METHOD(size_t,
size_t(const ReadHandle* readHandle, const void* data, size_t dataLength)); OnReadHandleSerializeInitialDataSize,
MOCK_METHOD4(OnReadHandleSerializeInitialData, (const ReadHandle* readHandle, const void* data, size_t dataLength));
void(const ReadHandle* readHandle, MOCK_METHOD(void,
const void* data, OnReadHandleSerializeInitialData,
size_t dataLength, (const ReadHandle* readHandle,
void* serializePointer)); const void* data,
MOCK_METHOD1(OnReadHandleDestroy, void(const ReadHandle* readHandle)); size_t dataLength,
void* serializePointer));
MOCK_METHOD(void, OnReadHandleDestroy, (const ReadHandle* readHandle));
MOCK_METHOD3(OnWriteHandleDeserializeFlush, MOCK_METHOD(bool,
bool(const WriteHandle* writeHandle, OnWriteHandleDeserializeFlush,
const uint32_t* deserializePointer, (const WriteHandle* writeHandle,
size_t deserializeSize)); const uint32_t* deserializePointer,
MOCK_METHOD1(OnWriteHandleDestroy, void(const WriteHandle* writeHandle)); size_t deserializeSize));
MOCK_METHOD(void, OnWriteHandleDestroy, (const WriteHandle* writeHandle));
}; };
}} // namespace dawn_wire::server }} // namespace dawn_wire::server

View File

@ -24,7 +24,7 @@ using namespace testing;
class MockDeviceLostCallback { class MockDeviceLostCallback {
public: public:
MOCK_METHOD2(Call, void(const char* message, void* userdata)); MOCK_METHOD(void, Call, (const char* message, void* userdata));
}; };
static std::unique_ptr<MockDeviceLostCallback> mockDeviceLostCallback; static std::unique_ptr<MockDeviceLostCallback> mockDeviceLostCallback;
@ -36,7 +36,7 @@ static void ToMockDeviceLostCallback(const char* message, void* userdata) {
class MockFenceOnCompletionCallback { class MockFenceOnCompletionCallback {
public: public:
MOCK_METHOD2(Call, void(WGPUFenceCompletionStatus status, void* userdata)); MOCK_METHOD(void, Call, (WGPUFenceCompletionStatus status, void* userdata));
}; };
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback; static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;

View File

@ -22,7 +22,7 @@ using namespace testing;
class MockFenceOnCompletionCallback { class MockFenceOnCompletionCallback {
public: public:
MOCK_METHOD2(Call, void(WGPUFenceCompletionStatus status, void* userdata)); MOCK_METHOD(void, Call, (WGPUFenceCompletionStatus status, void* userdata));
}; };
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback; static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
@ -32,7 +32,7 @@ static void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, vo
class MockPopErrorScopeCallback { class MockPopErrorScopeCallback {
public: public:
MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata)); MOCK_METHOD(void, Call, (WGPUErrorType type, const char* message, void* userdata));
}; };
static std::unique_ptr<MockPopErrorScopeCallback> mockPopErrorScopeCallback; static std::unique_ptr<MockPopErrorScopeCallback> mockPopErrorScopeCallback;

View File

@ -28,7 +28,7 @@ namespace {
class MockDestructor { class MockDestructor {
public: public:
MOCK_METHOD2(Call, void(void*, DestructedClass)); MOCK_METHOD(void, Call, (void*, DestructedClass));
}; };
std::unique_ptr<StrictMock<MockDestructor>> mockDestructor; std::unique_ptr<StrictMock<MockDestructor>> mockDestructor;

View File

@ -22,11 +22,12 @@ using namespace testing;
class MockBufferMapReadCallback { class MockBufferMapReadCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(void,
void(WGPUBufferMapAsyncStatus status, Call,
const uint32_t* ptr, (WGPUBufferMapAsyncStatus status,
uint64_t dataLength, const uint32_t* ptr,
void* userdata)); uint64_t dataLength,
void* userdata));
}; };
static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback; static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
@ -41,11 +42,10 @@ static void ToMockBufferMapReadCallback(WGPUBufferMapAsyncStatus status,
class MockBufferMapWriteCallback { class MockBufferMapWriteCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(
void(WGPUBufferMapAsyncStatus status, void,
uint32_t* ptr, Call,
uint64_t dataLength, (WGPUBufferMapAsyncStatus status, uint32_t* ptr, uint64_t dataLength, void* userdata));
void* userdata));
}; };
static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback; static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;

View File

@ -20,7 +20,7 @@ using namespace testing;
class MockDevicePopErrorScopeCallback { class MockDevicePopErrorScopeCallback {
public: public:
MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata)); MOCK_METHOD(void, Call, (WGPUErrorType type, const char* message, void* userdata));
}; };
static std::unique_ptr<MockDevicePopErrorScopeCallback> mockDevicePopErrorScopeCallback; static std::unique_ptr<MockDevicePopErrorScopeCallback> mockDevicePopErrorScopeCallback;

View File

@ -20,7 +20,7 @@ using namespace testing;
class MockFenceOnCompletionCallback { class MockFenceOnCompletionCallback {
public: public:
MOCK_METHOD2(Call, void(WGPUFenceCompletionStatus status, void* userdata)); MOCK_METHOD(void, Call, (WGPUFenceCompletionStatus status, void* userdata));
}; };
struct FenceOnCompletionExpectation { struct FenceOnCompletionExpectation {

View File

@ -22,11 +22,12 @@ namespace {
// Mock classes to add expectations on the wire calling callbacks // Mock classes to add expectations on the wire calling callbacks
class MockBufferMapReadCallback { class MockBufferMapReadCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(void,
void(WGPUBufferMapAsyncStatus status, Call,
const uint32_t* ptr, (WGPUBufferMapAsyncStatus status,
uint64_t dataLength, const uint32_t* ptr,
void* userdata)); uint64_t dataLength,
void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback; std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback;
@ -41,11 +42,10 @@ namespace {
class MockBufferMapWriteCallback { class MockBufferMapWriteCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(
void(WGPUBufferMapAsyncStatus status, void,
uint32_t* ptr, Call,
uint64_t dataLength, (WGPUBufferMapAsyncStatus status, uint32_t* ptr, uint64_t dataLength, void* userdata));
void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback; std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback;
@ -61,12 +61,13 @@ namespace {
class MockBufferCreateMappedCallback { class MockBufferCreateMappedCallback {
public: public:
MOCK_METHOD5(Call, MOCK_METHOD(void,
void(WGPUBufferMapAsyncStatus status, Call,
WGPUBuffer buffer, (WGPUBufferMapAsyncStatus status,
uint32_t* ptr, WGPUBuffer buffer,
uint64_t dataLength, uint32_t* ptr,
void* userdata)); uint64_t dataLength,
void* userdata));
}; };
} // anonymous namespace } // anonymous namespace

View File

@ -22,7 +22,7 @@ namespace {
// Mock classes to add expectations on the wire calling callbacks // Mock classes to add expectations on the wire calling callbacks
class MockDeviceErrorCallback { class MockDeviceErrorCallback {
public: public:
MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata)); MOCK_METHOD(void, Call, (WGPUErrorType type, const char* message, void* userdata));
}; };
std::unique_ptr<StrictMock<MockDeviceErrorCallback>> mockDeviceErrorCallback; std::unique_ptr<StrictMock<MockDeviceErrorCallback>> mockDeviceErrorCallback;
@ -32,7 +32,7 @@ namespace {
class MockDevicePopErrorScopeCallback { class MockDevicePopErrorScopeCallback {
public: public:
MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata)); MOCK_METHOD(void, Call, (WGPUErrorType type, const char* message, void* userdata));
}; };
std::unique_ptr<StrictMock<MockDevicePopErrorScopeCallback>> mockDevicePopErrorScopeCallback; std::unique_ptr<StrictMock<MockDevicePopErrorScopeCallback>> mockDevicePopErrorScopeCallback;
@ -44,7 +44,7 @@ namespace {
class MockDeviceLostCallback { class MockDeviceLostCallback {
public: public:
MOCK_METHOD2(Call, void(const char* message, void* userdata)); MOCK_METHOD(void, Call, (const char* message, void* userdata));
}; };
std::unique_ptr<StrictMock<MockDeviceLostCallback>> mockDeviceLostCallback; std::unique_ptr<StrictMock<MockDeviceLostCallback>> mockDeviceLostCallback;

View File

@ -21,7 +21,7 @@ namespace {
class MockFenceOnCompletionCallback { class MockFenceOnCompletionCallback {
public: public:
MOCK_METHOD2(Call, void(WGPUFenceCompletionStatus status, void* userdata)); MOCK_METHOD(void, Call, (WGPUFenceCompletionStatus status, void* userdata));
}; };
std::unique_ptr<StrictMock<MockFenceOnCompletionCallback>> mockFenceOnCompletionCallback; std::unique_ptr<StrictMock<MockFenceOnCompletionCallback>> mockFenceOnCompletionCallback;

View File

@ -25,11 +25,12 @@ namespace {
// Mock classes to add expectations on the wire calling callbacks // Mock classes to add expectations on the wire calling callbacks
class MockBufferMapReadCallback { class MockBufferMapReadCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(void,
void(WGPUBufferMapAsyncStatus status, Call,
const uint32_t* ptr, (WGPUBufferMapAsyncStatus status,
uint64_t dataLength, const uint32_t* ptr,
void* userdata)); uint64_t dataLength,
void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback; std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback;
@ -44,11 +45,10 @@ namespace {
class MockBufferMapWriteCallback { class MockBufferMapWriteCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD(
void(WGPUBufferMapAsyncStatus status, void,
uint32_t* ptr, Call,
uint64_t dataLength, (WGPUBufferMapAsyncStatus status, uint32_t* ptr, uint64_t dataLength, void* userdata));
void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback; std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback;
@ -62,12 +62,13 @@ namespace {
class MockBufferCreateMappedCallback { class MockBufferCreateMappedCallback {
public: public:
MOCK_METHOD5(Call, MOCK_METHOD(void,
void(WGPUBufferMapAsyncStatus status, Call,
WGPUBuffer buffer, (WGPUBufferMapAsyncStatus status,
uint32_t* ptr, WGPUBuffer buffer,
uint64_t dataLength, uint32_t* ptr,
void* userdata)); uint64_t dataLength,
void* userdata));
}; };
} // anonymous namespace } // anonymous namespace