diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 18:29:24 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 18:29:24 +0000 |
commit | 22339b123c68805c7c293c67f6f47ea45f0fd1a1 (patch) | |
tree | bb05e2e3eb0362338e921a4dce9d5c350437326e /webkit/blob/blob_storage_controller_unittest.cc | |
parent | e840afdedd33728491639312a268fbf37a48f078 (diff) | |
download | chromium_src-22339b123c68805c7c293c67f6f47ea45f0fd1a1.zip chromium_src-22339b123c68805c7c293c67f6f47ea45f0fd1a1.tar.gz chromium_src-22339b123c68805c7c293c67f6f47ea45f0fd1a1.tar.bz2 |
Support sending BlobData to browser process. Also support sending UploadData
with the blob info to browser process.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3108042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57707 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob/blob_storage_controller_unittest.cc')
-rw-r--r-- | webkit/blob/blob_storage_controller_unittest.cc | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/webkit/blob/blob_storage_controller_unittest.cc b/webkit/blob/blob_storage_controller_unittest.cc new file mode 100644 index 0000000..3bd0b63 --- /dev/null +++ b/webkit/blob/blob_storage_controller_unittest.cc @@ -0,0 +1,85 @@ +// Copyright (c) 2010 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 "base/file_path.h" +#include "base/time.h" +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "webkit/blob/blob_data.h" +#include "webkit/blob/blob_storage_controller.h" + +namespace webkit_blob { + +TEST(BlobStorageControllerTest, RegisterBlobUrl) { + // Setup a set of blob data for testing. + base::Time time1, time2; + base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", &time1); + base::Time::FromString(L"Mon, 14 Nov 1994, 11:30:49 GMT", &time2); + + scoped_refptr<BlobData> blob_data1 = new BlobData(); + blob_data1->AppendData("Data1"); + blob_data1->AppendData("Data2"); + blob_data1->AppendFile(FilePath(FILE_PATH_LITERAL("File1.txt")), + 10, 1024, time1); + + scoped_refptr<BlobData> blob_data2 = new BlobData(); + blob_data2->AppendData("Data3"); + blob_data2->AppendBlob(GURL("blob://url_1"), 8, 100); + blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File2.txt")), + 0, 20, time2); + + scoped_refptr<BlobData> canonicalized_blob_data2 = new BlobData(); + canonicalized_blob_data2->AppendData("Data3"); + canonicalized_blob_data2->AppendData("Data2", 3, 2); + canonicalized_blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File1.txt")), + 10, 98, time1); + canonicalized_blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File2.txt")), + 0, 20, time2); + + scoped_ptr<BlobStorageController> blob_storage_controller( + new BlobStorageController()); + + // Test registering a blob URL referring to the blob data containing only + // data and file. + GURL blob_url1("blob://url_1"); + blob_storage_controller->RegisterBlobUrl(blob_url1, blob_data1); + + BlobData* blob_data_found = + blob_storage_controller->GetBlobDataFromUrl(blob_url1); + ASSERT_TRUE(blob_data_found != NULL); + EXPECT_TRUE(*blob_data_found == *blob_data1); + + // Test registering a blob URL referring to the blob data containing data, + // file and blob. + GURL blob_url2("blob://url_2"); + blob_storage_controller->RegisterBlobUrl(blob_url2, blob_data2); + + blob_data_found = blob_storage_controller->GetBlobDataFromUrl(blob_url2); + ASSERT_TRUE(blob_data_found != NULL); + EXPECT_TRUE(*blob_data_found == *canonicalized_blob_data2); + + // Test registering a blob URL referring to existent blob URL. + GURL blob_url3("blob://url_3"); + blob_storage_controller->RegisterBlobUrlFrom(blob_url3, blob_url1); + + blob_data_found = blob_storage_controller->GetBlobDataFromUrl(blob_url3); + ASSERT_TRUE(blob_data_found != NULL); + EXPECT_TRUE(*blob_data_found == *blob_data1); + + // Test registering a blob URL referring to non-existent blob URL. + GURL nonexistent_blob_url("blob://url_none"); + GURL blob_url4("blob://url_4"); + blob_storage_controller->RegisterBlobUrlFrom(blob_url4, nonexistent_blob_url); + + blob_data_found = blob_storage_controller->GetBlobDataFromUrl(blob_url4); + EXPECT_FALSE(blob_data_found != NULL); + + // Test unregistering a blob URL. + blob_storage_controller->UnregisterBlobUrl(blob_url3); + blob_data_found = blob_storage_controller->GetBlobDataFromUrl(blob_url3); + EXPECT_FALSE(blob_data_found != NULL); +} + +} // namespace webkit_blob |