forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ppapi: Unit tests for pepper command buffer proxy
Similar to the IPC command buffer proxy unit tests. R=piman BUG=824510 Change-Id: I14ecfc448e12d4f143b645cc9290c476fdbf5d0d Reviewed-on: https://chromium-review.googlesource.com/978959 Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Reviewed-by: Antoine Labour <piman@chromium.org> Cr-Commit-Position: refs/heads/master@{#545899}
- Loading branch information
Showing
6 changed files
with
130 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ppapi/proxy/ppapi_command_buffer_proxy.h" | ||
|
||
#include "ipc/ipc_test_sink.h" | ||
#include "ppapi/proxy/ppapi_messages.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace ppapi { | ||
class PpapiCommandBufferProxyTest : public testing::Test, | ||
public proxy::LockedSender { | ||
public: | ||
PpapiCommandBufferProxyTest() | ||
: proxy_(HostResource(), | ||
&flush_info_, | ||
this, | ||
gpu::Capabilities(), | ||
proxy::SerializedHandle(proxy::SerializedHandle::SHARED_MEMORY), | ||
gpu::CommandBufferId()) {} | ||
|
||
~PpapiCommandBufferProxyTest() override {} | ||
|
||
protected: | ||
// We can't verify sync message behavior with this setup. | ||
bool SendAndStayLocked(IPC::Message* msg) override { return sink_.Send(msg); } | ||
|
||
IPC::TestSink sink_; | ||
proxy::InstanceData::FlushInfo flush_info_; | ||
proxy::PpapiCommandBufferProxy proxy_; | ||
}; | ||
|
||
TEST_F(PpapiCommandBufferProxyTest, OrderingBarriersAreCoalescedWithFlush) { | ||
proxy_.OrderingBarrier(10); | ||
proxy_.OrderingBarrier(20); | ||
proxy_.OrderingBarrier(30); | ||
proxy_.Flush(40); | ||
|
||
EXPECT_EQ(1u, sink_.message_count()); | ||
const IPC::Message* msg = | ||
sink_.GetFirstMessageMatching(PpapiHostMsg_PPBGraphics3D_AsyncFlush::ID); | ||
ASSERT_TRUE(msg); | ||
PpapiHostMsg_PPBGraphics3D_AsyncFlush::Param params; | ||
ASSERT_TRUE(PpapiHostMsg_PPBGraphics3D_AsyncFlush::Read(msg, ¶ms)); | ||
int32_t sent_put_offset = std::get<1>(params); | ||
EXPECT_EQ(40, sent_put_offset); | ||
EXPECT_FALSE(flush_info_.flush_pending); | ||
EXPECT_EQ(40, flush_info_.put_offset); | ||
} | ||
|
||
TEST_F(PpapiCommandBufferProxyTest, FlushPendingWorkFlushesOrderingBarriers) { | ||
proxy_.OrderingBarrier(10); | ||
proxy_.OrderingBarrier(20); | ||
proxy_.OrderingBarrier(30); | ||
proxy_.FlushPendingWork(); | ||
|
||
EXPECT_EQ(1u, sink_.message_count()); | ||
const IPC::Message* msg = | ||
sink_.GetFirstMessageMatching(PpapiHostMsg_PPBGraphics3D_AsyncFlush::ID); | ||
ASSERT_TRUE(msg); | ||
PpapiHostMsg_PPBGraphics3D_AsyncFlush::Param params; | ||
ASSERT_TRUE(PpapiHostMsg_PPBGraphics3D_AsyncFlush::Read(msg, ¶ms)); | ||
int32_t sent_put_offset = std::get<1>(params); | ||
EXPECT_EQ(30, sent_put_offset); | ||
EXPECT_FALSE(flush_info_.flush_pending); | ||
EXPECT_EQ(30, flush_info_.put_offset); | ||
} | ||
|
||
TEST_F(PpapiCommandBufferProxyTest, EnsureWorkVisibleFlushesOrderingBarriers) { | ||
proxy_.OrderingBarrier(10); | ||
proxy_.OrderingBarrier(20); | ||
proxy_.OrderingBarrier(30); | ||
proxy_.EnsureWorkVisible(); | ||
|
||
EXPECT_EQ(2u, sink_.message_count()); | ||
const IPC::Message* msg = sink_.GetMessageAt(0); | ||
ASSERT_TRUE(msg); | ||
EXPECT_EQ(static_cast<uint32_t>(PpapiHostMsg_PPBGraphics3D_AsyncFlush::ID), | ||
msg->type()); | ||
PpapiHostMsg_PPBGraphics3D_AsyncFlush::Param params; | ||
ASSERT_TRUE(PpapiHostMsg_PPBGraphics3D_AsyncFlush::Read(msg, ¶ms)); | ||
int32_t sent_put_offset = std::get<1>(params); | ||
EXPECT_EQ(30, sent_put_offset); | ||
EXPECT_FALSE(flush_info_.flush_pending); | ||
EXPECT_EQ(30, flush_info_.put_offset); | ||
|
||
msg = sink_.GetMessageAt(1); | ||
ASSERT_TRUE(msg); | ||
EXPECT_EQ( | ||
static_cast<uint32_t>(PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible::ID), | ||
msg->type()); | ||
} | ||
|
||
} // namespace ppapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters