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

Side by Side Diff: blimp/net/blob_channel/blob_channel_integration_test.cc

Issue 1985863002: Incorporate BlobChannel into Blimp image encode/decode pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-helium
Patch Set: wez and nyquist feedback Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "blimp/common/blob_cache/id_util.h" 10 #include "blimp/common/blob_cache/id_util.h"
11 #include "blimp/common/blob_cache/in_memory_blob_cache.h" 11 #include "blimp/common/blob_cache/in_memory_blob_cache.h"
12 #include "blimp/common/blob_cache/test_util.h" 12 #include "blimp/common/blob_cache/test_util.h"
13 #include "blimp/net/blob_channel/blob_channel_receiver.h" 13 #include "blimp/net/blob_channel/blob_channel_receiver.h"
14 #include "blimp/net/blob_channel/blob_channel_sender.h" 14 #include "blimp/net/blob_channel/blob_channel_sender.h"
15 #include "blimp/net/blob_channel/blob_channel_sender_impl.h"
15 #include "blimp/net/blob_channel/mock_blob_channel_receiver.h" 16 #include "blimp/net/blob_channel/mock_blob_channel_receiver.h"
16 #include "blimp/net/test_common.h" 17 #include "blimp/net/test_common.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace blimp { 20 namespace blimp {
20 namespace { 21 namespace {
21 22
22 using testing::_; 23 using testing::_;
23 using testing::SaveArg; 24 using testing::SaveArg;
24 25
25 const char kBlobId[] = "foo1"; 26 const char kBlobId[] = "foo1";
26 const char kBlobPayload[] = "bar1"; 27 const char kBlobPayload[] = "bar1";
27 28
28 // Routes sender delegate calls to a receiver delegate object. 29 // Routes sender delegate calls to a receiver delegate object.
29 // The caller is responsible for ensuring that the receiver delegate is deleted 30 // The caller is responsible for ensuring that the receiver delegate is deleted
30 // after |this| is deleted. 31 // after |this| is deleted.
31 class SenderDelegateProxy : public BlobChannelSender::Delegate { 32 class SenderDelegateProxy : public BlobChannelSenderImpl::Delegate {
32 public: 33 public:
33 explicit SenderDelegateProxy(BlobChannelReceiver* receiver) 34 explicit SenderDelegateProxy(BlobChannelReceiver* receiver)
34 : receiver_(receiver) {} 35 : receiver_(receiver) {}
35 ~SenderDelegateProxy() override {} 36 ~SenderDelegateProxy() override {}
36 37
37 private: 38 private:
38 // BlobChannelSender implementation. 39 // BlobChannelSender implementation.
39 void DeliverBlob(const BlobId& id, BlobDataPtr data) override { 40 void DeliverBlob(const BlobId& id, BlobDataPtr data) override {
40 base::MessageLoop::current()->PostTask( 41 base::MessageLoop::current()->PostTask(
41 FROM_HERE, base::Bind(&BlobChannelReceiver::OnBlobReceived, 42 FROM_HERE, base::Bind(&BlobChannelReceiver::OnBlobReceived,
(...skipping 16 matching lines...) Expand all
58 receiver_delegate_ = receiver_delegate.get(); 59 receiver_delegate_ = receiver_delegate.get();
59 60
60 EXPECT_CALL(*receiver_delegate, SetReceiver(_)) 61 EXPECT_CALL(*receiver_delegate, SetReceiver(_))
61 .WillOnce(SaveArg<0>(&stored_receiver)); 62 .WillOnce(SaveArg<0>(&stored_receiver));
62 63
63 receiver_ = BlobChannelReceiver::Create( 64 receiver_ = BlobChannelReceiver::Create(
64 base::WrapUnique(new InMemoryBlobCache), std::move(receiver_delegate)); 65 base::WrapUnique(new InMemoryBlobCache), std::move(receiver_delegate));
65 66
66 EXPECT_EQ(receiver_.get(), stored_receiver); 67 EXPECT_EQ(receiver_.get(), stored_receiver);
67 68
68 sender_.reset(new BlobChannelSender( 69 sender_.reset(new BlobChannelSenderImpl(
69 base::WrapUnique(new InMemoryBlobCache), 70 base::WrapUnique(new InMemoryBlobCache),
70 base::WrapUnique(new SenderDelegateProxy(receiver_.get())))); 71 base::WrapUnique(new SenderDelegateProxy(receiver_.get()))));
71 } 72 }
72 73
73 ~BlobChannelIntegrationTest() override {} 74 ~BlobChannelIntegrationTest() override {}
74 75
75 protected: 76 protected:
76 MockBlobChannelReceiverDelegate* receiver_delegate_; 77 MockBlobChannelReceiverDelegate* receiver_delegate_;
77 std::unique_ptr<BlobChannelReceiver> receiver_; 78 std::unique_ptr<BlobChannelReceiver> receiver_;
78 std::unique_ptr<BlobChannelSender> sender_; 79 std::unique_ptr<BlobChannelSender> sender_;
(...skipping 12 matching lines...) Expand all
91 92
92 EXPECT_EQ(nullptr, receiver_->Get(blob_id).get()); 93 EXPECT_EQ(nullptr, receiver_->Get(blob_id).get());
93 sender_->DeliverBlob(blob_id); 94 sender_->DeliverBlob(blob_id);
94 95
95 base::RunLoop().RunUntilIdle(); 96 base::RunLoop().RunUntilIdle();
96 EXPECT_EQ(kBlobPayload, receiver_->Get(blob_id)->data); 97 EXPECT_EQ(kBlobPayload, receiver_->Get(blob_id)->data);
97 } 98 }
98 99
99 } // namespace 100 } // namespace
100 } // namespace blimp 101 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698