Index: content/browser/blob_storage/blob_memory_controller_unittest.cc |
diff --git a/content/browser/blob_storage/blob_memory_controller_unittest.cc b/content/browser/blob_storage/blob_memory_controller_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eb2a9d0a56e766fca5a083ef2a111671a3e8bc5d |
--- /dev/null |
+++ b/content/browser/blob_storage/blob_memory_controller_unittest.cc |
@@ -0,0 +1,93 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
Marijn Kruisselbrink
2016/07/12 21:33:06
Wrong year in copyright.
And why is this file in /
dmurph
2016/07/14 01:04:30
Done. There isn't a test target for storage, so we
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "storage/browser/blob/blob_memory_controller.h" |
+ |
+#include "base/bind.h" |
+#include "base/files/file_util.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/test/sequenced_worker_pool_owner.h" |
+#include "base/test/test_simple_task_runner.h" |
+#include "base/test/test_simple_task_runner.h" |
+#include "base/threading/thread_task_runner_handle.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace storage { |
+namespace { |
+ |
+using FileCreationInfo = BlobMemoryController::FileCreationInfo; |
+using base::TestSimpleTaskRunner; |
+ |
+const std::string kBlobStorageDirectory = "blob_storage"; |
+// const size_t kTestBlobStorageMaxBlobMemorySize = 400; |
+// const size_t kTestBlobStorageMaxMemoryUsage = 500; |
+// const uint64_t kTestBlobStorageMaxDiskSpace = 1000; |
+// const size_t kTestBlobStorageInFlightMemory = 10; |
+// const uint64_t kTestBlobStorageMinFileSizeBytes = 10; |
+ |
+// void SetFileCreationInfo(BlobMemoryController::FileCreationInfo* output, |
+// const BlobMemoryController::FileCreationInfo& in) { |
+// *output = in; |
+//} |
+// |
+// void SetPointer(bool* out, bool success) { |
+// *out = success; |
+//} |
+ |
+class BlobMemoryControllerTest : public testing::Test { |
+ protected: |
+ BlobMemoryControllerTest() : file_pool_(2, "test-file-pool") {} |
+ |
+ void SetUp() override { |
+ ASSERT_EQ(true, base::CreateNewTempDirectory("blob_storage", &temp_dir_)); |
+ }; |
+ |
+ void TearDown() override { |
+ files_created_.clear(); |
+ ASSERT_EQ(true, base::DeleteFile(temp_dir_, true)); |
+ } |
+ |
+ void SetTestMemoryLimits(BlobMemoryController* controller) { |
+ // controller->SetMemoryLimits( |
+ // kTestBlobStorageMaxBlobMemorySize, kTestBlobStorageMaxMemoryUsage, |
+ // kTestBlobStorageMaxDiskSpace, kTestBlobStorageInFlightMemory, |
+ // kTestBlobStorageMinFileSizeBytes); |
+ } |
+ |
+ void SaveFileCreationInfo(FileCreationInfo info) { |
+ files_created_.push_back(std::move(info)); |
+ } |
+ |
+ base::Callback<void(FileCreationInfo info)> GetFileCreationCallback() { |
+ return base::Bind(&BlobMemoryControllerTest::SaveFileCreationInfo, |
+ base::Unretained(this)); |
+ } |
+ |
+ base::MessageLoop |
+ message_loop_; // Needed by SequencedWorkerPool to function. |
+ base::FilePath temp_dir_; |
+ std::vector<FileCreationInfo> files_created_; |
+ |
+ base::SequencedWorkerPoolOwner file_pool_; |
+}; |
+ |
+// TEST_F(BlobMemoryControllerTest, TestBasicTempFiles) { |
+// BlobMemoryController controller; |
+// SetTestMemoryLimits(&controller); |
+// |
+// // Check we can't create files. |
+// controller.CreateTemporaryFileForRenderer(10ull, GetFileCreationCallback()); |
+// |
+// // Check that we can |
+// controller.EnableDisk(temp_dir_, file_pool_.pool()); |
+// controller.CreateTemporaryFileForRenderer(10, GetFileCreationCallback()); |
+// EXPECT_EQ(1, file_pool_.has_work_call_count()); |
+// base::RunLoop().RunUntilIdle(); |
+// base::RunLoop().RunUntilIdle(); |
+// |
+// LOG(ERROR) << files_created_[1].error; |
+//} |
+ |
+} // namespace |
+} // namespace storage |