| Index: blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc
|
| diff --git a/blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc b/blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1420a207640680ce9445e84bbc20697ac3b33a5f
|
| --- /dev/null
|
| +++ b/blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc
|
| @@ -0,0 +1,84 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "blimp/engine/renderer/blob_channel_sender_proxy.h"
|
| +
|
| +#include <utility>
|
| +
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "base/run_loop.h"
|
| +#include "blimp/common/blob_cache/id_util.h"
|
| +#include "blimp/common/blob_cache/test_util.h"
|
| +#include "blimp/engine/mojo/blob_channel.mojom.h"
|
| +#include "blimp/engine/mojo/blob_channel_service.h"
|
| +#include "blimp/net/blob_channel/mock_blob_channel_sender.h"
|
| +#include "blimp/net/test_common.h"
|
| +#include "mojo/public/cpp/bindings/interface_request.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace blimp {
|
| +namespace engine {
|
| +namespace {
|
| +
|
| +const char kBlobId[] = "foo";
|
| +const char kBlobPayload[] = "bar";
|
| +
|
| +class BlobChannelSenderProxyTest : public testing::Test {
|
| + public:
|
| + BlobChannelSenderProxyTest() {}
|
| +
|
| + void SetUp() override {
|
| + // Set up communication path from the Proxy to a sender mock:
|
| + // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ =>
|
| + // mock_sender_;
|
| + mojom::BlobChannelPtr mojo_ptr;
|
| + BlobChannelService::Create(&mock_sender_, GetProxy(&mojo_ptr));
|
| + blob_channel_sender_proxy_ =
|
| + BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr));
|
| + }
|
| +
|
| + protected:
|
| + void DeliverMessages() { base::RunLoop().RunUntilIdle(); }
|
| +
|
| + const std::string blob_id_ = CalculateBlobId(kBlobId);
|
| + base::MessageLoop message_loop_;
|
| + std::unique_ptr<BlobChannelService> mojo_service_impl_;
|
| + MockBlobChannelSender mock_sender_;
|
| + std::unique_ptr<BlobChannelSenderProxy> blob_channel_sender_proxy_;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxyTest);
|
| +};
|
| +
|
| +TEST_F(BlobChannelSenderProxyTest, PutBlob) {
|
| + EXPECT_CALL(mock_sender_,
|
| + PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
|
| + blob_channel_sender_proxy_->PutBlob(blob_id_,
|
| + CreateBlobDataPtr(kBlobPayload));
|
| + DeliverMessages();
|
| + EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
|
| + EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
|
| +}
|
| +
|
| +TEST_F(BlobChannelSenderProxyTest, DeliverBlob) {
|
| + EXPECT_CALL(mock_sender_,
|
| + PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
|
| + EXPECT_CALL(mock_sender_, DeliverBlob(blob_id_));
|
| +
|
| + blob_channel_sender_proxy_->PutBlob(blob_id_,
|
| + CreateBlobDataPtr(kBlobPayload));
|
| + DeliverMessages();
|
| + EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
|
| + EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
|
| +
|
| + blob_channel_sender_proxy_->DeliverBlob(blob_id_);
|
| + DeliverMessages();
|
| + EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
|
| + EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
|
| +}
|
| +
|
| +} // namespace
|
| +} // namespace engine
|
| +} // namespace blimp
|
|
|