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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/engine/renderer/blob_channel_sender_proxy.h"
6
7 #include <utility>
8
9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h"
11 #include "blimp/common/blob_cache/id_util.h"
12 #include "blimp/common/blob_cache/test_util.h"
13 #include "blimp/engine/mojo/blob_channel.mojom.h"
14 #include "blimp/engine/mojo/blob_channel_service.h"
15 #include "blimp/net/blob_channel/mock_blob_channel_sender.h"
16 #include "blimp/net/test_common.h"
17 #include "mojo/public/cpp/bindings/interface_request.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 namespace blimp {
22 namespace engine {
23 namespace {
24
25 const char kBlobId[] = "foo";
26 const char kBlobPayload[] = "bar";
27
28 class BlobChannelSenderProxyTest : public testing::Test {
29 public:
30 BlobChannelSenderProxyTest() {}
31
32 void SetUp() override {
33 // Set up communication path from the Proxy to a sender mock:
34 // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ =>
35 // mock_sender_;
36 mojom::BlobChannelPtr mojo_ptr;
37 BlobChannelService::Create(&mock_sender_, GetProxy(&mojo_ptr));
38 blob_channel_sender_proxy_ =
39 BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr));
40 }
41
42 protected:
43 void DeliverMessages() { base::RunLoop().RunUntilIdle(); }
44
45 const std::string blob_id_ = CalculateBlobId(kBlobId);
46 base::MessageLoop message_loop_;
47 std::unique_ptr<BlobChannelService> mojo_service_impl_;
48 MockBlobChannelSender mock_sender_;
49 std::unique_ptr<BlobChannelSenderProxy> blob_channel_sender_proxy_;
50
51 private:
52 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxyTest);
53 };
54
55 TEST_F(BlobChannelSenderProxyTest, PutBlob) {
56 EXPECT_CALL(mock_sender_,
57 PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
58 blob_channel_sender_proxy_->PutBlob(blob_id_,
59 CreateBlobDataPtr(kBlobPayload));
60 DeliverMessages();
61 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
62 EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
63 }
64
65 TEST_F(BlobChannelSenderProxyTest, DeliverBlob) {
66 EXPECT_CALL(mock_sender_,
67 PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
68 EXPECT_CALL(mock_sender_, DeliverBlob(blob_id_));
69
70 blob_channel_sender_proxy_->PutBlob(blob_id_,
71 CreateBlobDataPtr(kBlobPayload));
72 DeliverMessages();
73 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
74 EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
75
76 blob_channel_sender_proxy_->DeliverBlob(blob_id_);
77 DeliverMessages();
78 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
79 EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
80 }
81
82 } // namespace
83 } // namespace engine
84 } // namespace blimp
OLDNEW
« 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