mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Mock API: special case the SetErrorCallback procs.
Also add a suppression for these procs in wiretests, unless we are specifically testing them.
This commit is contained in:
committed by
Corentin Wallez
parent
0a58812f34
commit
1b7c5e3f70
@@ -18,16 +18,27 @@
|
||||
#include "wire/TerribleCommandBuffer.h"
|
||||
#include "wire/Wire.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace testing;
|
||||
using namespace nxt::wire;
|
||||
|
||||
class WireTests : public Test {
|
||||
class WireTestsBase : public Test {
|
||||
protected:
|
||||
WireTestsBase(bool ignoreSetCallbackCalls)
|
||||
: ignoreSetCallbackCalls(ignoreSetCallbackCalls) {
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
nxtProcTable mockProcs;
|
||||
nxtDevice mockDevice;
|
||||
api.GetProcTableAndDevice(&mockProcs, &mockDevice);
|
||||
|
||||
if (ignoreSetCallbackCalls) {
|
||||
EXPECT_CALL(api, OnDeviceSetErrorCallback(_, _, _)).Times(Exactly(1));
|
||||
EXPECT_CALL(api, OnBuilderSetErrorCallback(_, _, _, _)).Times(AnyNumber());
|
||||
}
|
||||
|
||||
s2cBuf = new TerribleCommandBuffer();
|
||||
c2sBuf = new TerribleCommandBuffer(wireServer);
|
||||
|
||||
@@ -63,12 +74,20 @@ class WireTests : public Test {
|
||||
nxtDevice device;
|
||||
|
||||
private:
|
||||
bool ignoreSetCallbackCalls = false;
|
||||
|
||||
CommandHandler* wireServer = nullptr;
|
||||
CommandHandler* wireClient = nullptr;
|
||||
TerribleCommandBuffer* s2cBuf = nullptr;
|
||||
TerribleCommandBuffer* c2sBuf = nullptr;
|
||||
};
|
||||
|
||||
class WireTests : public WireTestsBase {
|
||||
public:
|
||||
WireTests() : WireTestsBase(true) {
|
||||
}
|
||||
};
|
||||
|
||||
// One call gets forwarded correctly.
|
||||
TEST_F(WireTests, CallForwarded) {
|
||||
nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device);
|
||||
@@ -189,3 +208,11 @@ TEST_F(WireTests, OneObjectAsPointerArgument) {
|
||||
// - Test multiple objects as value work
|
||||
// - Object creation, then calls do nothing after error on builder
|
||||
// - Object creation then error then create object, then should do nothing.
|
||||
// - Device error gets forwarded properly
|
||||
// - Builder error
|
||||
// - An error gets forwarded properly
|
||||
// - No other call to builder after error
|
||||
// - No call to object after error
|
||||
// - No error -> success
|
||||
// - Builder destroyed on client side -> gets unknown
|
||||
// - Same for getresult then destroyed object
|
||||
|
||||
Reference in New Issue
Block a user