Add DeviceLostCallback to dawn.json and dawn_wire

Bug: dawn:68
Change-Id: I6d8dd071be4ec612c67245bfde218e31e7a998b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14660
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Natasha Lee
2019-12-18 18:59:20 +00:00
committed by Commit Bot service account
parent 3d2d62813f
commit 9bba4a936e
15 changed files with 136 additions and 12 deletions

View File

@@ -42,6 +42,16 @@ namespace {
mockDevicePopErrorScopeCallback->Call(type, message, userdata);
}
class MockDeviceLostCallback {
public:
MOCK_METHOD2(Call, void(const char* message, void* userdata));
};
std::unique_ptr<StrictMock<MockDeviceLostCallback>> mockDeviceLostCallback;
void ToMockDeviceLostCallback(const char* message, void* userdata) {
mockDeviceLostCallback->Call(message, userdata);
}
} // anonymous namespace
class WireErrorCallbackTests : public WireTest {
@@ -55,6 +65,7 @@ class WireErrorCallbackTests : public WireTest {
mockDeviceErrorCallback = std::make_unique<StrictMock<MockDeviceErrorCallback>>();
mockDevicePopErrorScopeCallback = std::make_unique<StrictMock<MockDevicePopErrorScopeCallback>>();
mockDeviceLostCallback = std::make_unique<StrictMock<MockDeviceLostCallback>>();
}
void TearDown() override {
@@ -62,6 +73,7 @@ class WireErrorCallbackTests : public WireTest {
mockDeviceErrorCallback = nullptr;
mockDevicePopErrorScopeCallback = nullptr;
mockDeviceLostCallback = nullptr;
}
void FlushServer() {
@@ -232,3 +244,19 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeEmptyStack) {
FlushServer();
}
}
// Test the return wire for device lost callback
TEST_F(WireErrorCallbackTests, DeviceLostCallback) {
wgpuDeviceSetDeviceLostCallback(device, ToMockDeviceLostCallback, this);
// Setting the error callback should stay on the client side and do nothing
FlushClient();
// Calling the callback on the server side will result in the callback being called on the
// client side
api.CallDeviceLostCallback(apiDevice, "Some error message");
EXPECT_CALL(*mockDeviceLostCallback, Call(StrEq("Some error message"), this)).Times(1);
FlushServer();
}

View File

@@ -43,6 +43,7 @@ void WireTest::SetUp() {
// This SetCallback call cannot be ignored because it is done as soon as we start the server
EXPECT_CALL(api, OnDeviceSetUncapturedErrorCallback(_, _, _)).Times(Exactly(1));
EXPECT_CALL(api, OnDeviceSetDeviceLostCallback(_, _, _)).Times(Exactly(1));
SetupIgnoredCallExpectations();
mS2cBuf = std::make_unique<utils::TerribleCommandBuffer>();