Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc

Issue 2033013003: Use shared memory for moving data over BlobChannel Mojo interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-master
Patch Set: IPC owners file added. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « blimp/engine/renderer/blob_channel_sender_proxy.cc ('k') | blimp/net/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc
diff --git a/blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc b/blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1420a207640680ce9445e84bbc20697ac3b33a5f
--- /dev/null
+++ b/blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc
@@ -0,0 +1,84 @@
+// Copyright 2016 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 "blimp/engine/renderer/blob_channel_sender_proxy.h"
+
+#include <utility>
+
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "blimp/common/blob_cache/id_util.h"
+#include "blimp/common/blob_cache/test_util.h"
+#include "blimp/engine/mojo/blob_channel.mojom.h"
+#include "blimp/engine/mojo/blob_channel_service.h"
+#include "blimp/net/blob_channel/mock_blob_channel_sender.h"
+#include "blimp/net/test_common.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blimp {
+namespace engine {
+namespace {
+
+const char kBlobId[] = "foo";
+const char kBlobPayload[] = "bar";
+
+class BlobChannelSenderProxyTest : public testing::Test {
+ public:
+ BlobChannelSenderProxyTest() {}
+
+ void SetUp() override {
+ // Set up communication path from the Proxy to a sender mock:
+ // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ =>
+ // mock_sender_;
+ mojom::BlobChannelPtr mojo_ptr;
+ BlobChannelService::Create(&mock_sender_, GetProxy(&mojo_ptr));
+ blob_channel_sender_proxy_ =
+ BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr));
+ }
+
+ protected:
+ void DeliverMessages() { base::RunLoop().RunUntilIdle(); }
+
+ const std::string blob_id_ = CalculateBlobId(kBlobId);
+ base::MessageLoop message_loop_;
+ std::unique_ptr<BlobChannelService> mojo_service_impl_;
+ MockBlobChannelSender mock_sender_;
+ std::unique_ptr<BlobChannelSenderProxy> blob_channel_sender_proxy_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxyTest);
+};
+
+TEST_F(BlobChannelSenderProxyTest, PutBlob) {
+ EXPECT_CALL(mock_sender_,
+ PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
+ blob_channel_sender_proxy_->PutBlob(blob_id_,
+ CreateBlobDataPtr(kBlobPayload));
+ DeliverMessages();
+ EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
+ EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
+}
+
+TEST_F(BlobChannelSenderProxyTest, DeliverBlob) {
+ EXPECT_CALL(mock_sender_,
+ PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
+ EXPECT_CALL(mock_sender_, DeliverBlob(blob_id_));
+
+ blob_channel_sender_proxy_->PutBlob(blob_id_,
+ CreateBlobDataPtr(kBlobPayload));
+ DeliverMessages();
+ EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
+ EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
+
+ blob_channel_sender_proxy_->DeliverBlob(blob_id_);
+ DeliverMessages();
+ EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
+ EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
+}
+
+} // namespace
+} // namespace engine
+} // namespace blimp
« no previous file with comments | « blimp/engine/renderer/blob_channel_sender_proxy.cc ('k') | blimp/net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698