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

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

Issue 1528233004: [Blob] Blob paging to disk patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-disk1
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | content/browser/fileapi/blob_storage_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..207d2af655942c8955ae90dddae265bc479c9482
--- /dev/null
+++ b/content/browser/blob_storage/blob_memory_controller_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2015 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 "storage/browser/blob/blob_memory_controller.h"
+
+#include "base/files/file_util.h"
+#include "base/test/test_simple_task_runner.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace storage {
+namespace {
+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 = 2;
+const uint64_t kTestBlobStorageMinFileSizeBytes = 2;
+
+void SetFileCreationInfo(BlobMemoryController::FileCreationInfo* output,
+ const BlobMemoryController::FileCreationInfo& in) {
+ *out = in;
+}
+
+class BlobMemoryControllerTest : public testing::Test {
+ protected:
+ void SetUp() override {
+ ASSERT_EQ(true, base::GetTempDir(&temp_dir_));
+ directory_path_ = temp_dir_.Append(kBlobStorageDirectory);
+ };
+
+ void SetTestMemoryLimits(BlobMemoryController* controller) {
+ controller->SetMemoryLimits(
+ kTestBlobStorageMaxBlobMemorySize, kTestBlobStorageMaxMemoryUsage,
+ kTestBlobStorageMaxDiskSpace, kTestBlobStorageInFlightMemory,
+ kTestBlobStorageMinFileSizeBytes);
+ }
+
+ base::FilePath temp_dir_;
+ base::FilePath directory_path_;
+};
+
+TEST_F(BlobMemoryControllerTest, TestNoDiskChecks) {
+ BlobMemoryController controller;
+ SetTestMemoryLimits(&controller);
+
+ EXPECT_TRUE(controller.ShouldBeShortcut(500));
+ EXPECT_FALSE(controller.ShouldBeShortcut(501));
+ EXPECT_TRUE(controller.CanNewBlobFit(500));
+ EXPECT_FALSE(controller.CanNewBlobFit(501));
+ // No file saving
+ EXPECT_FALSE(controller.ShouldRendererSaveToFile(1));
+ EXPECT_FALSE(controller.ShouldRendererSaveToFile(500));
+ EXPECT_FALSE(controller.ShouldRendererSaveToFile(501));
+
+ // Check we can't create files.
+ BlobMemoryController::FileCreationInfo file_creation_info;
+}
+
+} // namespace
+} // namespace storage
« no previous file with comments | « no previous file | content/browser/fileapi/blob_storage_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698