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

Unified Diff: blimp/net/blob_channel/helium_blob_channel_unittest.cc

Issue 1970463004: Blimp: Add BlobChannel Helium messages and delegate impls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: blimp/net/blob_channel/helium_blob_channel_unittest.cc
diff --git a/blimp/net/blob_channel/helium_blob_channel_unittest.cc b/blimp/net/blob_channel/helium_blob_channel_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..38a81e8387c6fcedf337cf83094fa41e63c77f7c
--- /dev/null
+++ b/blimp/net/blob_channel/helium_blob_channel_unittest.cc
@@ -0,0 +1,73 @@
+// 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 <memory>
+
+#include "base/memory/ptr_util.h"
+#include "blimp/common/blob_cache/id_util.h"
+#include "blimp/common/blob_cache/test_util.h"
+#include "blimp/net/blob_channel/helium_blob_receiver_delegate.h"
+#include "blimp/net/blob_channel/helium_blob_sender_delegate.h"
+#include "blimp/net/blob_channel/mock_blob_channel_receiver.h"
+#include "blimp/net/test_common.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blimp {
+namespace {
+
+using testing::_;
+using testing::SaveArg;
+
+const char kBlobId[] = "foo1";
+const char kBlobPayload[] = "bar1";
+
+class HeliumBlobChannelTest : public testing::Test {
+ public:
+ HeliumBlobChannelTest() : receiver_delegate_(new HeliumBlobReceiverDelegate) {
+ receiver_delegate_->SetReceiver(&mock_receiver_);
+ sender_delegate_.set_outgoing_message_processor(
+ base::WrapUnique(receiver_delegate_));
+ }
+
+ ~HeliumBlobChannelTest() override {}
+
+ protected:
+ const std::string blob_id_ = CalculateBlobId(kBlobId);
+
+ MockBlobChannelReceiver mock_receiver_;
+ HeliumBlobReceiverDelegate* receiver_delegate_;
+ HeliumBlobSenderDelegate sender_delegate_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HeliumBlobChannelTest);
+};
+
+// Verifies the content of BlimpMessages generated by the Sender.
+TEST_F(HeliumBlobChannelTest, TransferBlobContents) {
+ BlimpMessage captured_msg;
+ MockBlimpMessageProcessor* mock_processor = new MockBlimpMessageProcessor;
+ EXPECT_CALL(*mock_processor, MockableProcessMessage(_, _))
+ .WillOnce(SaveArg<0>(&captured_msg));
+ sender_delegate_.set_outgoing_message_processor(
+ base::WrapUnique(mock_processor));
+
+ sender_delegate_.DeliverBlob(blob_id_, CreateBlobDataPtr(kBlobPayload));
+
+ EXPECT_EQ(BlobChannelMessage::TypeCase::kTransferBlob,
+ captured_msg.blob_channel().type_case());
+ EXPECT_EQ(blob_id_, captured_msg.blob_channel().transfer_blob().blob_id());
+ EXPECT_EQ(kBlobPayload,
+ captured_msg.blob_channel().transfer_blob().payload());
+}
+
+// Verifies that the Receiver understands messages sent by the Sender.
+TEST_F(HeliumBlobChannelTest, TransferBlobCompatibility) {
+ EXPECT_CALL(mock_receiver_,
+ OnBlobReceived(blob_id_, BlobDataPtrEqualsString(kBlobPayload)));
+ sender_delegate_.DeliverBlob(blob_id_, CreateBlobDataPtr(kBlobPayload));
+}
+
+} // namespace
+} // namespace blimp
« no previous file with comments | « blimp/net/blob_channel/blob_channel_receiver_unittest.cc ('k') | blimp/net/blob_channel/helium_blob_receiver_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698