| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "storage/browser/blob/blob_memory_controller.h" |
| 6 |
| 7 #include "base/files/file_util.h" |
| 8 #include "base/test/test_simple_task_runner.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace storage { |
| 12 namespace { |
| 13 const std::string kBlobStorageDirectory = "blob_storage"; |
| 14 const size_t kTestBlobStorageMaxBlobMemorySize = 400; |
| 15 const size_t kTestBlobStorageMaxMemoryUsage = 500; |
| 16 const uint64_t kTestBlobStorageMaxDiskSpace = 1000; |
| 17 const size_t kTestBlobStorageInFlightMemory = 2; |
| 18 const uint64_t kTestBlobStorageMinFileSizeBytes = 2; |
| 19 |
| 20 void SetFileCreationInfo(BlobMemoryController::FileCreationInfo* output, |
| 21 const BlobMemoryController::FileCreationInfo& in) { |
| 22 *out = in; |
| 23 } |
| 24 |
| 25 class BlobMemoryControllerTest : public testing::Test { |
| 26 protected: |
| 27 void SetUp() override { |
| 28 ASSERT_EQ(true, base::GetTempDir(&temp_dir_)); |
| 29 directory_path_ = temp_dir_.Append(kBlobStorageDirectory); |
| 30 }; |
| 31 |
| 32 void SetTestMemoryLimits(BlobMemoryController* controller) { |
| 33 controller->SetMemoryLimits( |
| 34 kTestBlobStorageMaxBlobMemorySize, kTestBlobStorageMaxMemoryUsage, |
| 35 kTestBlobStorageMaxDiskSpace, kTestBlobStorageInFlightMemory, |
| 36 kTestBlobStorageMinFileSizeBytes); |
| 37 } |
| 38 |
| 39 base::FilePath temp_dir_; |
| 40 base::FilePath directory_path_; |
| 41 }; |
| 42 |
| 43 TEST_F(BlobMemoryControllerTest, TestNoDiskChecks) { |
| 44 BlobMemoryController controller; |
| 45 SetTestMemoryLimits(&controller); |
| 46 |
| 47 EXPECT_TRUE(controller.ShouldBeShortcut(500)); |
| 48 EXPECT_FALSE(controller.ShouldBeShortcut(501)); |
| 49 EXPECT_TRUE(controller.CanNewBlobFit(500)); |
| 50 EXPECT_FALSE(controller.CanNewBlobFit(501)); |
| 51 // No file saving |
| 52 EXPECT_FALSE(controller.ShouldRendererSaveToFile(1)); |
| 53 EXPECT_FALSE(controller.ShouldRendererSaveToFile(500)); |
| 54 EXPECT_FALSE(controller.ShouldRendererSaveToFile(501)); |
| 55 |
| 56 // Check we can't create files. |
| 57 BlobMemoryController::FileCreationInfo file_creation_info; |
| 58 } |
| 59 |
| 60 } // namespace |
| 61 } // namespace storage |
| OLD | NEW |