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

Side by Side Diff: blimp/net/blob_channel/blob_channel_sender_unittest.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
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 <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "blimp/common/blob_cache/mock_blob_cache.h" 9 #include "blimp/common/blob_cache/mock_blob_cache.h"
10 #include "blimp/net/blob_channel/blob_channel_sender.h" 10 #include "blimp/net/blob_channel/blob_channel_sender_impl.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace blimp { 14 namespace blimp {
15 namespace { 15 namespace {
16 16
17 using testing::_; 17 using testing::_;
18 using testing::Pointee; 18 using testing::Pointee;
19 using testing::Return; 19 using testing::Return;
20 20
21 const char kBlobId[] = "blob-1"; 21 const char kBlobId[] = "blob-1";
22 const char kBlobPayload[] = "blob-1-payload"; 22 const char kBlobPayload[] = "blob-1-payload";
23 23
24 // Helper function for creating a cache payload vector from a string. 24 // Helper function for creating a cache payload vector from a string.
25 BlobDataPtr CreatePayload(const std::string& input) { 25 BlobDataPtr CreatePayload(const std::string& input) {
26 BlobDataPtr output(new BlobData(input)); 26 BlobDataPtr output(new BlobData(input));
27 return output; 27 return output;
28 } 28 }
29 29
30 MATCHER_P(BlobDataEqual, expected, "") { 30 MATCHER_P(BlobDataEqual, expected, "") {
31 return expected->data == arg->data; 31 return expected->data == arg->data;
32 } 32 }
33 33
34 class MockSenderDelegate : public BlobChannelSender::Delegate { 34 class MockSenderDelegate : public BlobChannelSenderImpl::Delegate {
35 public: 35 public:
36 MockSenderDelegate() {} 36 MockSenderDelegate() {}
37 ~MockSenderDelegate() override {} 37 ~MockSenderDelegate() override {}
38 38
39 MOCK_METHOD2(DeliverBlob, void(const BlobId&, BlobDataPtr)); 39 MOCK_METHOD2(DeliverBlob, void(const BlobId&, BlobDataPtr));
40 }; 40 };
41 41
42 class BlobChannelSenderTest : public testing::Test { 42 class BlobChannelSenderTest : public testing::Test {
43 public: 43 public:
44 BlobChannelSenderTest() 44 BlobChannelSenderTest()
45 : mock_delegate_(new testing::StrictMock<MockSenderDelegate>), 45 : mock_delegate_(new testing::StrictMock<MockSenderDelegate>),
46 mock_cache_(new testing::StrictMock<MockBlobCache>), 46 mock_cache_(new testing::StrictMock<MockBlobCache>),
47 blob_sender_(new BlobChannelSender(base::WrapUnique(mock_cache_), 47 blob_sender_(
48 base::WrapUnique(mock_delegate_))) {} 48 new BlobChannelSenderImpl(base::WrapUnique(mock_cache_),
49 base::WrapUnique(mock_delegate_))) {}
49 ~BlobChannelSenderTest() override {} 50 ~BlobChannelSenderTest() override {}
50 51
51 testing::StrictMock<MockSenderDelegate>* mock_delegate_; 52 testing::StrictMock<MockSenderDelegate>* mock_delegate_;
52 testing::StrictMock<MockBlobCache>* mock_cache_; 53 testing::StrictMock<MockBlobCache>* mock_cache_;
53 std::unique_ptr<BlobChannelSender> blob_sender_; 54 std::unique_ptr<BlobChannelSender> blob_sender_;
54 }; 55 };
55 56
56 TEST_F(BlobChannelSenderTest, TestPutBlob) { 57 TEST_F(BlobChannelSenderTest, TestPutBlob) {
57 EXPECT_CALL(*mock_cache_, 58 EXPECT_CALL(*mock_cache_,
58 Put(kBlobId, BlobDataEqual(CreatePayload(kBlobPayload)))); 59 Put(kBlobId, BlobDataEqual(CreatePayload(kBlobPayload))));
(...skipping 13 matching lines...) Expand all
72 .WillOnce(Return(false)) 73 .WillOnce(Return(false))
73 .WillOnce(Return(true)); 74 .WillOnce(Return(true));
74 EXPECT_CALL(*mock_cache_, Put(kBlobId, BlobDataEqual(payload))); 75 EXPECT_CALL(*mock_cache_, Put(kBlobId, BlobDataEqual(payload)));
75 EXPECT_CALL(*mock_cache_, Get(kBlobId)).WillOnce(Return(payload)); 76 EXPECT_CALL(*mock_cache_, Get(kBlobId)).WillOnce(Return(payload));
76 blob_sender_->PutBlob(kBlobId, payload); 77 blob_sender_->PutBlob(kBlobId, payload);
77 blob_sender_->DeliverBlob(kBlobId); 78 blob_sender_->DeliverBlob(kBlobId);
78 } 79 }
79 80
80 } // namespace 81 } // namespace
81 } // namespace blimp 82 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blob_channel/blob_channel_sender_impl.cc ('k') | blimp/net/blob_channel/helium_blob_sender_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698