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

Unified Diff: content/browser/blob_storage/blob_memory_controller_unittest.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 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: 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

Powered by Google App Engine
This is Rietveld 408576698