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

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: fix gn dependency warning & rebase 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
« no previous file with comments | « blimp/net/blimp_connection_unittest.cc ('k') | blimp/net/blob_channel/blob_channel_receiver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/location.h" 7 #include "base/location.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "blimp/common/blob_cache/id_util.h" 13 #include "blimp/common/blob_cache/id_util.h"
14 #include "blimp/common/blob_cache/in_memory_blob_cache.h" 14 #include "blimp/common/blob_cache/in_memory_blob_cache.h"
15 #include "blimp/common/blob_cache/test_util.h" 15 #include "blimp/common/blob_cache/test_util.h"
16 #include "blimp/net/blob_channel/blob_channel_receiver.h" 16 #include "blimp/net/blob_channel/blob_channel_receiver.h"
17 #include "blimp/net/blob_channel/blob_channel_sender.h" 17 #include "blimp/net/blob_channel/blob_channel_sender.h"
18 #include "blimp/net/blob_channel/blob_channel_sender_impl.h"
18 #include "blimp/net/blob_channel/mock_blob_channel_receiver.h" 19 #include "blimp/net/blob_channel/mock_blob_channel_receiver.h"
19 #include "blimp/net/test_common.h" 20 #include "blimp/net/test_common.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace blimp { 23 namespace blimp {
23 namespace { 24 namespace {
24 25
25 using testing::_; 26 using testing::_;
26 using testing::SaveArg; 27 using testing::SaveArg;
27 28
28 const char kBlobId[] = "foo1"; 29 const char kBlobId[] = "foo1";
29 const char kBlobPayload[] = "bar1"; 30 const char kBlobPayload[] = "bar1";
30 31
31 // Routes sender delegate calls to a receiver delegate object. 32 // Routes sender delegate calls to a receiver delegate object.
32 // The caller is responsible for ensuring that the receiver delegate is deleted 33 // The caller is responsible for ensuring that the receiver delegate is deleted
33 // after |this| is deleted. 34 // after |this| is deleted.
34 class SenderDelegateProxy : public BlobChannelSender::Delegate { 35 class SenderDelegateProxy : public BlobChannelSenderImpl::Delegate {
35 public: 36 public:
36 explicit SenderDelegateProxy(BlobChannelReceiver* receiver) 37 explicit SenderDelegateProxy(BlobChannelReceiver* receiver)
37 : receiver_(receiver) {} 38 : receiver_(receiver) {}
38 ~SenderDelegateProxy() override {} 39 ~SenderDelegateProxy() override {}
39 40
40 private: 41 private:
41 // BlobChannelSender implementation. 42 // BlobChannelSender implementation.
42 void DeliverBlob(const BlobId& id, BlobDataPtr data) override { 43 void DeliverBlob(const BlobId& id, BlobDataPtr data) override {
43 base::ThreadTaskRunnerHandle::Get()->PostTask( 44 base::ThreadTaskRunnerHandle::Get()->PostTask(
44 FROM_HERE, base::Bind(&BlobChannelReceiver::OnBlobReceived, 45 FROM_HERE, base::Bind(&BlobChannelReceiver::OnBlobReceived,
(...skipping 16 matching lines...) Expand all
61 receiver_delegate_ = receiver_delegate.get(); 62 receiver_delegate_ = receiver_delegate.get();
62 63
63 EXPECT_CALL(*receiver_delegate, SetReceiver(_)) 64 EXPECT_CALL(*receiver_delegate, SetReceiver(_))
64 .WillOnce(SaveArg<0>(&stored_receiver)); 65 .WillOnce(SaveArg<0>(&stored_receiver));
65 66
66 receiver_ = BlobChannelReceiver::Create( 67 receiver_ = BlobChannelReceiver::Create(
67 base::WrapUnique(new InMemoryBlobCache), std::move(receiver_delegate)); 68 base::WrapUnique(new InMemoryBlobCache), std::move(receiver_delegate));
68 69
69 EXPECT_EQ(receiver_.get(), stored_receiver); 70 EXPECT_EQ(receiver_.get(), stored_receiver);
70 71
71 sender_.reset(new BlobChannelSender( 72 sender_.reset(new BlobChannelSenderImpl(
72 base::WrapUnique(new InMemoryBlobCache), 73 base::WrapUnique(new InMemoryBlobCache),
73 base::WrapUnique(new SenderDelegateProxy(receiver_.get())))); 74 base::WrapUnique(new SenderDelegateProxy(receiver_.get()))));
74 } 75 }
75 76
76 ~BlobChannelIntegrationTest() override {} 77 ~BlobChannelIntegrationTest() override {}
77 78
78 protected: 79 protected:
79 MockBlobChannelReceiverDelegate* receiver_delegate_; 80 MockBlobChannelReceiverDelegate* receiver_delegate_;
80 std::unique_ptr<BlobChannelReceiver> receiver_; 81 std::unique_ptr<BlobChannelReceiver> receiver_;
81 std::unique_ptr<BlobChannelSender> sender_; 82 std::unique_ptr<BlobChannelSender> sender_;
(...skipping 12 matching lines...) Expand all
94 95
95 EXPECT_EQ(nullptr, receiver_->Get(blob_id).get()); 96 EXPECT_EQ(nullptr, receiver_->Get(blob_id).get());
96 sender_->DeliverBlob(blob_id); 97 sender_->DeliverBlob(blob_id);
97 98
98 base::RunLoop().RunUntilIdle(); 99 base::RunLoop().RunUntilIdle();
99 EXPECT_EQ(kBlobPayload, receiver_->Get(blob_id)->data); 100 EXPECT_EQ(kBlobPayload, receiver_->Get(blob_id)->data);
100 } 101 }
101 102
102 } // namespace 103 } // namespace
103 } // namespace blimp 104 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_connection_unittest.cc ('k') | blimp/net/blob_channel/blob_channel_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698