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

Side by Side Diff: blimp/engine/renderer/blob_channel_sender_proxy_unittest.cc

Issue 2629743003: Remove all blimp engine code (Closed)
Patch Set: Use consistent comment style in //chrome Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "blimp/engine/renderer/blob_channel_sender_proxy.h"
6
7 #include <utility>
8
9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h"
12 #include "blimp/common/blob_cache/id_util.h"
13 #include "blimp/common/blob_cache/test_util.h"
14 #include "blimp/engine/mojo/blob_channel.mojom.h"
15 #include "blimp/engine/mojo/blob_channel_service.h"
16 #include "blimp/net/blob_channel/mock_blob_channel_sender.h"
17 #include "blimp/net/test_common.h"
18 #include "mojo/public/cpp/bindings/interface_request.h"
19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21
22 namespace blimp {
23 namespace engine {
24 namespace {
25
26 const char kBlobId[] = "foo";
27 const char kBlobPayload[] = "bar";
28
29 class BlobChannelSenderProxyTest : public testing::Test {
30 public:
31 BlobChannelSenderProxyTest()
32 : sender_weak_factory_(&mock_sender_),
33 mojo_service_impl_(base::MakeUnique<BlobChannelService>(
34 sender_weak_factory_.GetWeakPtr(),
35 message_loop_.task_runner())) {}
36
37 void SetUp() override {
38 // Set up communication path from the Proxy to a sender mock:
39 // blob_channel_sender_proxy_ => (mojo) => mojo_service_impl_ =>
40 // mock_sender_;
41 mojom::BlobChannelPtr mojo_ptr;
42 mojo_service_impl_->BindRequest(MakeRequest(&mojo_ptr));
43 blob_channel_sender_proxy_ =
44 BlobChannelSenderProxy::CreateForTest(std::move(mojo_ptr));
45 }
46
47 protected:
48 void DeliverMessages() { base::RunLoop().RunUntilIdle(); }
49
50 const std::string blob_id_ = CalculateBlobId(kBlobId);
51 base::MessageLoop message_loop_;
52 std::unique_ptr<BlobChannelSenderProxy> blob_channel_sender_proxy_;
53 MockBlobChannelSender mock_sender_;
54 base::WeakPtrFactory<BlobChannelSender> sender_weak_factory_;
55 std::unique_ptr<BlobChannelService> mojo_service_impl_;
56
57 private:
58 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderProxyTest);
59 };
60
61 TEST_F(BlobChannelSenderProxyTest, PutBlob) {
62 EXPECT_CALL(mock_sender_,
63 PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
64 blob_channel_sender_proxy_->PutBlob(blob_id_,
65 CreateBlobDataPtr(kBlobPayload));
66 DeliverMessages();
67 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
68 EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
69 }
70
71 TEST_F(BlobChannelSenderProxyTest, DeliverBlob) {
72 EXPECT_CALL(mock_sender_,
73 PutBlob(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
74 EXPECT_CALL(mock_sender_, DeliverBlob(blob_id_));
75
76 blob_channel_sender_proxy_->PutBlob(blob_id_,
77 CreateBlobDataPtr(kBlobPayload));
78 DeliverMessages();
79 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
80 EXPECT_FALSE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
81
82 blob_channel_sender_proxy_->DeliverBlob(blob_id_);
83 DeliverMessages();
84 EXPECT_TRUE(blob_channel_sender_proxy_->IsInEngineCache(blob_id_));
85 EXPECT_TRUE(blob_channel_sender_proxy_->IsInClientCache(blob_id_));
86 }
87
88 } // namespace
89 } // namespace engine
90 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/renderer/blob_channel_sender_proxy.cc ('k') | blimp/engine/renderer/engine_image_serialization_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698