| 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" |
| 11 #include "blimp/common/blob_cache/id_util.h" | 11 #include "blimp/common/blob_cache/id_util.h" |
| 12 #include "blimp/common/blob_cache/test_util.h" | 12 #include "blimp/common/blob_cache/test_util.h" |
| 13 #include "blimp/engine/mojo/blob_channel.mojom.h" | 13 #include "blimp/engine/mojo/blob_channel.mojom.h" |
| 14 #include "blimp/engine/mojo/blob_channel_service.h" | 14 #include "blimp/engine/mojo/blob_channel_service.h" |
| 15 #include "blimp/net/blob_channel/mock_blob_channel_sender.h" | 15 #include "blimp/net/blob_channel/mock_blob_channel_sender.h" |
| 16 #include "blimp/net/test_common.h" | 16 #include "blimp/net/test_common.h" |
| 17 #include "mojo/public/cpp/bindings/interface_request.h" | 17 #include "mojo/public/cpp/bindings/interface_request.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 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_( |
| 32 base::MakeUnique<BlobChannelService>(&mock_sender_)) {} |
| 31 | 33 |
| 32 void SetUp() override { | 34 void SetUp() override { |
| 33 // Set up communication path from the Proxy to a sender mock: | 35 // Set up communication path from the Proxy to a sender mock: |
| 34 // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ => | 36 // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ => |
| 35 // mock_sender_; | 37 // mock_sender_; |
| 36 mojom::BlobChannelPtr mojo_ptr; | 38 mojom::BlobChannelPtr mojo_ptr; |
| 37 BlobChannelService::Create(&mock_sender_, GetProxy(&mojo_ptr)); | 39 mojo_service_impl_->BindRequest(GetProxy(&mojo_ptr)); |
| 38 blob_channel_sender_proxy_ = | 40 blob_channel_sender_proxy_ = |
| 39 BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr)); | 41 BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr)); |
| 40 } | 42 } |
| 41 | 43 |
| 42 protected: | 44 protected: |
| 43 void DeliverMessages() { base::RunLoop().RunUntilIdle(); } | 45 void DeliverMessages() { base::RunLoop().RunUntilIdle(); } |
| 44 | 46 |
| 45 const std::string blob_id_ = CalculateBlobId(kBlobId); | 47 const std::string blob_id_ = CalculateBlobId(kBlobId); |
| 46 base::MessageLoop message_loop_; | 48 base::MessageLoop message_loop_; |
| 47 std::unique_ptr<BlobChannelService> mojo_service_impl_; | 49 std::unique_ptr<BlobChannelService> mojo_service_impl_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 | 77 |
| 76 blob_channel_sender_proxy_->DeliverBlob(blob_id_); | 78 blob_channel_sender_proxy_->DeliverBlob(blob_id_); |
| 77 DeliverMessages(); | 79 DeliverMessages(); |
| 78 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_)); | 80 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_)); |
| 79 EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_)); | 81 EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_)); |
| 80 } | 82 } |
| 81 | 83 |
| 82 } // namespace | 84 } // namespace |
| 83 } // namespace engine | 85 } // namespace engine |
| 84 } // namespace blimp | 86 } // namespace blimp |
| OLD | NEW |