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

Side by Side Diff: content/browser/fileapi/fileapi_message_filter_unittest.cc

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed copyright Created 5 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/fileapi/fileapi_message_filter.h" 5 #include "content/browser/fileapi/fileapi_message_filter.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/process/process_handle.h" 13 #include "base/process/process_handle.h"
14 #include "content/browser/child_process_security_policy_impl.h" 14 #include "content/browser/child_process_security_policy_impl.h"
15 #include "content/browser/fileapi/chrome_blob_storage_context.h" 15 #include "content/browser/fileapi/chrome_blob_storage_context.h"
16 #include "content/browser/streams/stream_registry.h" 16 #include "content/browser/streams/stream_registry.h"
17 #include "content/common/fileapi/file_system_messages.h" 17 #include "content/common/fileapi/file_system_messages.h"
18 #include "content/common/fileapi/webblob_messages.h" 18 #include "content/common/fileapi/webblob_messages.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/common/common_param_traits.h" 20 #include "content/public/common/common_param_traits.h"
21 #include "content/public/test/mock_render_process_host.h" 21 #include "content/public/test/mock_render_process_host.h"
22 #include "content/public/test/test_browser_context.h" 22 #include "content/public/test/test_browser_context.h"
23 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
24 #include "content/public/test/test_file_system_context.h" 24 #include "content/public/test/test_file_system_context.h"
25 #include "net/base/io_buffer.h" 25 #include "net/base/io_buffer.h"
26 #include "storage/browser/blob/blob_storage_context.h" 26 #include "storage/browser/blob/blob_storage_context.h"
27 #include "storage/browser/fileapi/file_system_context.h" 27 #include "storage/browser/fileapi/file_system_context.h"
28 #include "storage/common/blob/blob_data.h" 28 #include "storage/common/data_element.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 namespace content { 31 namespace content {
32 32
33 namespace { 33 namespace {
34 34
35 const char kFakeBlobInternalUrlSpec[] = 35 const char kFakeBlobInternalUrlSpec[] =
36 "blob:blobinternal%3A///dc83ede4-9bbd-453b-be2e-60fd623fcc93"; 36 "blob:blobinternal%3A///dc83ede4-9bbd-453b-be2e-60fd623fcc93";
37 const char kFakeBlobInternalUrlSpec2[] = 37 const char kFakeBlobInternalUrlSpec2[] =
38 "blob:blobinternal%3A///d28ae2e7-d233-4dda-9598-d135fe5d403e"; 38 "blob:blobinternal%3A///d28ae2e7-d233-4dda-9598-d135fe5d403e";
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 TEST_F(FileAPIMessageFilterTest, BuildNonEmptyStream) { 190 TEST_F(FileAPIMessageFilterTest, BuildNonEmptyStream) {
191 StreamRegistry* stream_registry = stream_context_->registry(); 191 StreamRegistry* stream_registry = stream_context_->registry();
192 192
193 const GURL kUrl(kFakeBlobInternalUrlSpec); 193 const GURL kUrl(kFakeBlobInternalUrlSpec);
194 194
195 EXPECT_EQ(NULL, stream_registry->GetStream(kUrl).get()); 195 EXPECT_EQ(NULL, stream_registry->GetStream(kUrl).get());
196 196
197 StreamHostMsg_StartBuilding start_message(kUrl, kFakeContentType); 197 StreamHostMsg_StartBuilding start_message(kUrl, kFakeContentType);
198 EXPECT_TRUE(filter_->OnMessageReceived(start_message)); 198 EXPECT_TRUE(filter_->OnMessageReceived(start_message));
199 199
200 storage::BlobData::Item item; 200 storage::DataElement item;
201 const std::string kFakeData = "foobarbaz"; 201 const std::string kFakeData = "foobarbaz";
202 item.SetToBytes(kFakeData.data(), kFakeData.size()); 202 item.SetToBytes(kFakeData.data(), kFakeData.size());
203 StreamHostMsg_AppendBlobDataItem append_message(kUrl, item); 203 StreamHostMsg_AppendBlobDataItem append_message(kUrl, item);
204 EXPECT_TRUE(filter_->OnMessageReceived(append_message)); 204 EXPECT_TRUE(filter_->OnMessageReceived(append_message));
205 205
206 StreamHostMsg_FinishBuilding finish_message(kUrl); 206 StreamHostMsg_FinishBuilding finish_message(kUrl);
207 EXPECT_TRUE(filter_->OnMessageReceived(finish_message)); 207 EXPECT_TRUE(filter_->OnMessageReceived(finish_message));
208 208
209 // Run loop to finish transfer and commit finalize command. 209 // Run loop to finish transfer and commit finalize command.
210 message_loop_.RunUntilIdle(); 210 message_loop_.RunUntilIdle();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_TRUE(filter_->OnMessageReceived(start_message)); 297 EXPECT_TRUE(filter_->OnMessageReceived(start_message));
298 298
299 StreamHostMsg_Clone clone_message(kDestUrl, kUrl); 299 StreamHostMsg_Clone clone_message(kDestUrl, kUrl);
300 EXPECT_TRUE(filter_->OnMessageReceived(clone_message)); 300 EXPECT_TRUE(filter_->OnMessageReceived(clone_message));
301 301
302 ASSERT_FALSE(stream_registry->GetStream(kUrl).get() == NULL); 302 ASSERT_FALSE(stream_registry->GetStream(kUrl).get() == NULL);
303 ASSERT_FALSE(stream_registry->GetStream(kDestUrl).get() == NULL); 303 ASSERT_FALSE(stream_registry->GetStream(kDestUrl).get() == NULL);
304 } 304 }
305 305
306 } // namespace content 306 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698