| OLD | NEW |
| 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 "blimp/engine/renderer/blob_channel_sender_proxy.h" | 5 #include "blimp/engine/renderer/blob_channel_sender_proxy.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace blimp { | 21 namespace blimp { |
| 22 namespace engine { | 22 namespace engine { |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 const char kBlobId[] = "foo"; | 25 const char kBlobId[] = "foo"; |
| 26 const char kBlobPayload[] = "bar"; | 26 const char kBlobPayload[] = "bar"; |
| 27 | 27 |
| 28 class BlobChannelSenderProxyTest : public testing::Test { | 28 class BlobChannelSenderProxyTest : public testing::Test { |
| 29 public: | 29 public: |
| 30 BlobChannelSenderProxyTest() | 30 BlobChannelSenderProxyTest() |
| 31 : mojo_service_impl_( | 31 : sender_weak_factory_(&mock_sender_), |
| 32 base::MakeUnique<BlobChannelService>(&mock_sender_)) {} | 32 mojo_service_impl_(base::MakeUnique<BlobChannelService>( |
| 33 sender_weak_factory_.GetWeakPtr(), |
| 34 message_loop_.task_runner())) {} |
| 33 | 35 |
| 34 void SetUp() override { | 36 void SetUp() override { |
| 35 // Set up communication path from the Proxy to a sender mock: | 37 // Set up communication path from the Proxy to a sender mock: |
| 36 // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ => | 38 // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ => |
| 37 // mock_sender_; | 39 // mock_sender_; |
| 38 mojom::BlobChannelPtr mojo_ptr; | 40 mojom::BlobChannelPtr mojo_ptr; |
| 39 mojo_service_impl_->BindRequest(GetProxy(&mojo_ptr)); | 41 mojo_service_impl_->BindRequest(GetProxy(&mojo_ptr)); |
| 40 blob_channel_sender_proxy_ = | 42 blob_channel_sender_proxy_ = |
| 41 BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr)); | 43 BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr)); |
| 42 } | 44 } |
| 43 | 45 |
| 44 protected: | 46 protected: |
| 45 void DeliverMessages() { base::RunLoop().RunUntilIdle(); } | 47 void DeliverMessages() { base::RunLoop().RunUntilIdle(); } |
| 46 | 48 |
| 47 const std::string blob_id_ = CalculateBlobId(kBlobId); | 49 const std::string blob_id_ = CalculateBlobId(kBlobId); |
| 48 base::MessageLoop message_loop_; | 50 base::MessageLoop message_loop_; |
| 51 std::unique_ptr<BlobChannelSenderProxy> blob_channel_sender_proxy_; |
| 52 MockBlobChannelSender mock_sender_; |
| 53 base::WeakPtrFactory<BlobChannelSender> sender_weak_factory_; |
| 49 std::unique_ptr<BlobChannelService> mojo_service_impl_; | 54 std::unique_ptr<BlobChannelService> mojo_service_impl_; |
| 50 MockBlobChannelSender mock_sender_; | |
| 51 std::unique_ptr<BlobChannelSenderProxy> blob_channel_sender_proxy_; | |
| 52 | 55 |
| 53 private: | 56 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxyTest); | 57 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxyTest); |
| 55 }; | 58 }; |
| 56 | 59 |
| 57 TEST_F(BlobChannelSenderProxyTest, PutBlob) { | 60 TEST_F(BlobChannelSenderProxyTest, PutBlob) { |
| 58 EXPECT_CALL(mock_sender_, | 61 EXPECT_CALL(mock_sender_, |
| 59 PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload))); | 62 PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload))); |
| 60 blob_channel_sender_proxy_->PutBlob(blob_id_, | 63 blob_channel_sender_proxy_->PutBlob(blob_id_, |
| 61 CreateBlobDataPtr(kBlobPayload)); | 64 CreateBlobDataPtr(kBlobPayload)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 | 80 |
| 78 blob_channel_sender_proxy_->DeliverBlob(blob_id_); | 81 blob_channel_sender_proxy_->DeliverBlob(blob_id_); |
| 79 DeliverMessages(); | 82 DeliverMessages(); |
| 80 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_)); | 83 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_)); |
| 81 EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_)); | 84 EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_)); |
| 82 } | 85 } |
| 83 | 86 |
| 84 } // namespace | 87 } // namespace |
| 85 } // namespace engine | 88 } // namespace engine |
| 86 } // namespace blimp | 89 } // namespace blimp |
| OLD | NEW |