mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Add wire tests and mocks for the MemoryTransferService
This CL tests integration of the MemoryTransferService with buffer mapping. It tests the basic success and error cases for buffer mapping, and it tests mocked failures of each fallible MemoryTransferService method that an embedder could implement. Change-Id: Iece660fb49664cc6a09a0b0b8dbe59e2882a6017 Bug: dawn:156 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8841 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
6a5418a760
commit
72724b8d25
1122
src/tests/unittests/wire/WireMemoryTransferServiceTests.cpp
Normal file
1122
src/tests/unittests/wire/WireMemoryTransferServiceTests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,14 @@ WireTest::WireTest() {
|
||||
WireTest::~WireTest() {
|
||||
}
|
||||
|
||||
client::MemoryTransferService* WireTest::GetClientMemoryTransferService() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
server::MemoryTransferService* WireTest::GetServerMemoryTransferService() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WireTest::SetUp() {
|
||||
DawnProcTable mockProcs;
|
||||
DawnDevice mockDevice;
|
||||
@@ -43,12 +51,14 @@ void WireTest::SetUp() {
|
||||
serverDesc.device = mockDevice;
|
||||
serverDesc.procs = &mockProcs;
|
||||
serverDesc.serializer = mS2cBuf.get();
|
||||
serverDesc.memoryTransferService = GetServerMemoryTransferService();
|
||||
|
||||
mWireServer.reset(new WireServer(serverDesc));
|
||||
mC2sBuf->SetHandler(mWireServer.get());
|
||||
|
||||
WireClientDescriptor clientDesc = {};
|
||||
clientDesc.serializer = mC2sBuf.get();
|
||||
clientDesc.memoryTransferService = GetClientMemoryTransferService();
|
||||
|
||||
mWireClient.reset(new WireClient(clientDesc));
|
||||
mS2cBuf->SetHandler(mWireClient.get());
|
||||
@@ -69,17 +79,18 @@ void WireTest::TearDown() {
|
||||
// cannot be null.
|
||||
api.IgnoreAllReleaseCalls();
|
||||
mWireClient = nullptr;
|
||||
mWireServer = nullptr;
|
||||
}
|
||||
|
||||
void WireTest::FlushClient() {
|
||||
ASSERT_TRUE(mC2sBuf->Flush());
|
||||
void WireTest::FlushClient(bool success) {
|
||||
ASSERT_EQ(mC2sBuf->Flush(), success);
|
||||
|
||||
Mock::VerifyAndClearExpectations(&api);
|
||||
SetupIgnoredCallExpectations();
|
||||
}
|
||||
|
||||
void WireTest::FlushServer() {
|
||||
ASSERT_TRUE(mS2cBuf->Flush());
|
||||
void WireTest::FlushServer(bool success) {
|
||||
ASSERT_EQ(mS2cBuf->Flush(), success);
|
||||
}
|
||||
|
||||
dawn_wire::WireServer* WireTest::GetWireServer() {
|
||||
|
||||
@@ -69,6 +69,12 @@ inline testing::Matcher<MatcherLambdaArgument<Lambda>> MatchesLambda(Lambda lamb
|
||||
namespace dawn_wire {
|
||||
class WireClient;
|
||||
class WireServer;
|
||||
namespace client {
|
||||
class MemoryTransferService;
|
||||
} // namespace client
|
||||
namespace server {
|
||||
class MemoryTransferService;
|
||||
} // namespace server
|
||||
} // namespace dawn_wire
|
||||
|
||||
namespace utils {
|
||||
@@ -82,8 +88,9 @@ class WireTest : public testing::Test {
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
void FlushClient();
|
||||
void FlushServer();
|
||||
|
||||
void FlushClient(bool success = true);
|
||||
void FlushServer(bool success = true);
|
||||
|
||||
testing::StrictMock<MockProcTable> api;
|
||||
DawnDevice apiDevice;
|
||||
@@ -97,6 +104,9 @@ class WireTest : public testing::Test {
|
||||
private:
|
||||
void SetupIgnoredCallExpectations();
|
||||
|
||||
virtual dawn_wire::client::MemoryTransferService* GetClientMemoryTransferService();
|
||||
virtual dawn_wire::server::MemoryTransferService* GetServerMemoryTransferService();
|
||||
|
||||
std::unique_ptr<dawn_wire::WireServer> mWireServer;
|
||||
std::unique_ptr<dawn_wire::WireClient> mWireClient;
|
||||
std::unique_ptr<utils::TerribleCommandBuffer> mS2cBuf;
|
||||
|
||||
Reference in New Issue
Block a user