| Index: content/child/blob_storage/blob_transport_controller_unittest.cc
|
| diff --git a/content/child/blob_storage/blob_transport_controller_unittest.cc b/content/child/blob_storage/blob_transport_controller_unittest.cc
|
| index 6c5d48f5126f38f8d21f461665ccab3e65c368dd..800484db12568c77aa2376d83d94c2eeb10b6aac 100644
|
| --- a/content/child/blob_storage/blob_transport_controller_unittest.cc
|
| +++ b/content/child/blob_storage/blob_transport_controller_unittest.cc
|
| @@ -6,6 +6,8 @@
|
|
|
| #include "base/memory/shared_memory.h"
|
| #include "content/child/blob_storage/blob_consolidation.h"
|
| +#include "content/common/fileapi/webblob_messages.h"
|
| +#include "ipc/ipc_sender.h"
|
| #include "storage/common/blob_storage/blob_item_bytes_request.h"
|
| #include "storage/common/blob_storage/blob_item_bytes_response.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| @@ -18,6 +20,14 @@ using storage::DataElement;
|
| namespace content {
|
| namespace {
|
|
|
| +class MockIPCSender : public IPC::Sender {
|
| + public:
|
| + MockIPCSender() {}
|
| + ~MockIPCSender() override {}
|
| +
|
| + MOCK_METHOD1(Send, bool(IPC::Message* msg));
|
| +};
|
| +
|
| BlobItemBytesResponse ResponseWithData(size_t request_number,
|
| const std::string& str) {
|
| BlobItemBytesResponse response(request_number);
|
| @@ -100,8 +110,7 @@ TEST_F(BlobTransportControllerTest, Responses) {
|
| consolidation->AddDataItem(CreateData("Hello3"));
|
| // See the above test for the expected descriptions layout.
|
|
|
| - holder->blob_storage_.insert(
|
| - std::make_pair(kBlobUUID, make_scoped_ptr(consolidation)));
|
| + holder->blob_storage_[kBlobUUID] = make_scoped_ptr(consolidation);
|
|
|
| std::vector<BlobItemBytesRequest> requests;
|
| std::vector<base::SharedMemoryHandle> memory_handles;
|
| @@ -159,8 +168,7 @@ TEST_F(BlobTransportControllerTest, SharedMemory) {
|
| consolidation->AddDataItem(CreateData("Hello3"));
|
| // See the above test for the expected descriptions layout.
|
|
|
| - holder->blob_storage_.insert(
|
| - std::make_pair(kBlobUUID, make_scoped_ptr(consolidation)));
|
| + holder->blob_storage_[kBlobUUID] = make_scoped_ptr(consolidation);
|
|
|
| std::vector<BlobItemBytesRequest> requests;
|
| std::vector<base::SharedMemoryHandle> memory_handles;
|
| @@ -198,22 +206,38 @@ TEST_F(BlobTransportControllerTest, TestPublicMethods) {
|
| const std::string kBlobUUID = "uuid";
|
| const std::string KRefBlobUUID = "refuuid";
|
| const std::string kBadBlobUUID = "uuuidBad";
|
| + MockIPCSender mock_sender;
|
| +
|
| BlobTransportController* holder = BlobTransportController::GetInstance();
|
|
|
| BlobConsolidation* consolidation = new BlobConsolidation();
|
| consolidation->AddBlobItem(KRefBlobUUID, 10, 10);
|
| + IPC::Message* message = nullptr;
|
| + EXPECT_CALL(mock_sender, Send(testing::_))
|
| + .WillOnce(
|
| + testing::DoAll(testing::SaveArg<0>(&message), testing::Return(true)))
|
| + .RetiresOnSaturation();
|
| holder->InitiateBlobTransfer(kBlobUUID, "", make_scoped_ptr(consolidation),
|
| - nullptr);
|
| + &mock_sender);
|
| + EXPECT_NE(nullptr, message);
|
| holder->OnCancel(kBlobUUID,
|
| storage::IPCBlobCreationCancelCode::OUT_OF_MEMORY);
|
| EXPECT_FALSE(holder->IsTransporting(kBlobUUID));
|
| + delete ((BlobStorageMsg_StartBuildingBlob*)message);
|
| + message = nullptr;
|
|
|
| consolidation = new BlobConsolidation();
|
| consolidation->AddBlobItem(KRefBlobUUID, 10, 10);
|
| + EXPECT_CALL(mock_sender, Send(testing::_))
|
| + .WillOnce(
|
| + testing::DoAll(testing::SaveArg<0>(&message), testing::Return(true)))
|
| + .RetiresOnSaturation();
|
| holder->InitiateBlobTransfer(kBlobUUID, "", make_scoped_ptr(consolidation),
|
| - nullptr);
|
| + &mock_sender);
|
| + EXPECT_NE(nullptr, message);
|
| holder->OnDone(kBlobUUID);
|
| EXPECT_FALSE(holder->IsTransporting(kBlobUUID));
|
| + delete ((BlobStorageMsg_StartBuildingBlob*)message);
|
| }
|
|
|
| TEST_F(BlobTransportControllerTest, ResponsesErrors) {
|
| @@ -226,8 +250,7 @@ TEST_F(BlobTransportControllerTest, ResponsesErrors) {
|
| BlobConsolidation* consolidation = new BlobConsolidation();
|
| consolidation->AddBlobItem(KRefBlobUUID, 10, 10);
|
|
|
| - holder->blob_storage_.insert(
|
| - std::make_pair(kBlobUUID, make_scoped_ptr(consolidation)));
|
| + holder->blob_storage_[kBlobUUID] = make_scoped_ptr(consolidation);
|
|
|
| std::vector<BlobItemBytesRequest> requests;
|
| std::vector<base::SharedMemoryHandle> memory_handles;
|
|
|