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 |
index ae0e796c5e34ea4fb555ab52b32889cf6f736503..84541c4e547969c950980f12d3cc220d8b068610 100644 |
--- a/content/browser/blob_storage/blob_memory_controller_unittest.cc |
+++ b/content/browser/blob_storage/blob_memory_controller_unittest.cc |
@@ -34,6 +34,8 @@ const uint64_t kTestBlobStorageMaxDiskSpace = 1000; |
const uint64_t kTestBlobStorageMinFileSizeBytes = 10; |
const uint64_t kTestBlobStorageMaxFileSizeBytes = 100; |
+const uint64_t kTestSmallBlobStorageMaxDiskSpace = 100; |
+ |
class BlobMemoryControllerTest : public testing::Test { |
protected: |
BlobMemoryControllerTest() {} |
@@ -74,6 +76,17 @@ class BlobMemoryControllerTest : public testing::Test { |
controller->set_limits_for_testing(limits); |
} |
+ void SetSmallDiskTestMemoryLimits(BlobMemoryController* controller) { |
+ BlobStorageLimits limits; |
+ limits.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes; |
+ limits.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes; |
+ limits.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize; |
+ limits.max_blob_disk_space = kTestSmallBlobStorageMaxDiskSpace; |
+ limits.min_page_file_size = kTestBlobStorageMinFileSizeBytes; |
+ limits.max_file_size = kTestBlobStorageMaxFileSizeBytes; |
+ controller->set_limits_for_testing(limits); |
+ } |
+ |
void SaveFileCreationInfo(std::vector<FileCreationInfo> info, bool success) { |
file_quota_result_ = success; |
if (success) { |
@@ -159,6 +172,16 @@ TEST_F(BlobMemoryControllerTest, Strategy) { |
EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy( |
0, kTestBlobStorageMaxDiskSpace + 1)); |
} |
+ { |
+ BlobMemoryController controller(temp_dir_.GetPath(), file_runner_); |
+ SetSmallDiskTestMemoryLimits(&controller); |
+ |
+ EXPECT_TRUE(controller.CanReserveQuota(kTestBlobStorageMaxBlobMemorySize)); |
+ // Since our disk is too small, this should be sent with shared memory. |
+ EXPECT_EQ( |
+ Strategy::SHARED_MEMORY, |
+ controller.DetermineStrategy(0, kTestBlobStorageMaxBlobMemorySize)); |
+ } |
} |
TEST_F(BlobMemoryControllerTest, GrantMemory) { |
@@ -281,7 +304,6 @@ TEST_F(BlobMemoryControllerTest, PageToDisk) { |
} |
TEST_F(BlobMemoryControllerTest, NoDiskTooLarge) { |
- const std::string kId = "id"; |
BlobMemoryController controller(temp_dir_.GetPath(), nullptr); |
SetTestMemoryLimits(&controller); |
@@ -291,7 +313,6 @@ TEST_F(BlobMemoryControllerTest, NoDiskTooLarge) { |
} |
TEST_F(BlobMemoryControllerTest, TooLargeForDisk) { |
- const std::string kId = "id"; |
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_); |
SetTestMemoryLimits(&controller); |