mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 06:45:16 +00:00
Split wire tests into multiple test files
Bug: dawn:104 Change-Id: I0dc46dabc92c98df13dbf596dea63aeaaea85d3d Reviewed-on: https://dawn-review.googlesource.com/c/4562 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
0f0c40de68
commit
1198270483
74
src/tests/unittests/wire/WireTest.cpp
Normal file
74
src/tests/unittests/wire/WireTest.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright 2019 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/unittests/wire/WireTest.h"
|
||||
|
||||
#include "dawn_wire/WireClient.h"
|
||||
#include "dawn_wire/WireServer.h"
|
||||
#include "utils/TerribleCommandBuffer.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace dawn_wire;
|
||||
|
||||
WireTest::WireTest(bool ignoreSetCallbackCalls) : mIgnoreSetCallbackCalls(ignoreSetCallbackCalls) {
|
||||
}
|
||||
|
||||
WireTest::~WireTest() {
|
||||
}
|
||||
|
||||
void WireTest::SetUp() {
|
||||
dawnProcTable mockProcs;
|
||||
dawnDevice mockDevice;
|
||||
api.GetProcTableAndDevice(&mockProcs, &mockDevice);
|
||||
|
||||
// This SetCallback call cannot be ignored because it is done as soon as we start the server
|
||||
EXPECT_CALL(api, OnDeviceSetErrorCallback(_, _, _)).Times(Exactly(1));
|
||||
if (mIgnoreSetCallbackCalls) {
|
||||
EXPECT_CALL(api, OnBuilderSetErrorCallback(_, _, _, _)).Times(AnyNumber());
|
||||
}
|
||||
EXPECT_CALL(api, DeviceTick(_)).Times(AnyNumber());
|
||||
|
||||
mS2cBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
||||
mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>(mWireServer.get());
|
||||
|
||||
mWireServer.reset(new WireServer(mockDevice, mockProcs, mS2cBuf.get()));
|
||||
mC2sBuf->SetHandler(mWireServer.get());
|
||||
|
||||
mWireClient.reset(new WireClient(mC2sBuf.get()));
|
||||
mS2cBuf->SetHandler(mWireClient.get());
|
||||
|
||||
device = mWireClient->GetDevice();
|
||||
dawnProcTable clientProcs = mWireClient->GetProcs();
|
||||
dawnSetProcs(&clientProcs);
|
||||
|
||||
apiDevice = mockDevice;
|
||||
}
|
||||
|
||||
void WireTest::TearDown() {
|
||||
dawnSetProcs(nullptr);
|
||||
|
||||
// Derived classes should call the base TearDown() first. The client must
|
||||
// be reset before any mocks are deleted.
|
||||
// Incomplete client callbacks will be called on deletion, so the mocks
|
||||
// cannot be null.
|
||||
mWireClient = nullptr;
|
||||
}
|
||||
|
||||
void WireTest::FlushClient() {
|
||||
ASSERT_TRUE(mC2sBuf->Flush());
|
||||
}
|
||||
|
||||
void WireTest::FlushServer() {
|
||||
ASSERT_TRUE(mS2cBuf->Flush());
|
||||
}
|
||||
Reference in New Issue
Block a user