OLD | NEW |
---|---|
(Empty) | |
1 // 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
| |
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/bind.h" | |
8 #include "base/files/file_util.h" | |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/test/sequenced_worker_pool_owner.h" | |
11 #include "base/test/test_simple_task_runner.h" | |
12 #include "base/test/test_simple_task_runner.h" | |
13 #include "base/threading/thread_task_runner_handle.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
16 namespace storage { | |
17 namespace { | |
18 | |
19 using FileCreationInfo = BlobMemoryController::FileCreationInfo; | |
20 using base::TestSimpleTaskRunner; | |
21 | |
22 const std::string kBlobStorageDirectory = "blob_storage"; | |
23 // const size_t kTestBlobStorageMaxBlobMemorySize = 400; | |
24 // const size_t kTestBlobStorageMaxMemoryUsage = 500; | |
25 // const uint64_t kTestBlobStorageMaxDiskSpace = 1000; | |
26 // const size_t kTestBlobStorageInFlightMemory = 10; | |
27 // const uint64_t kTestBlobStorageMinFileSizeBytes = 10; | |
28 | |
29 // void SetFileCreationInfo(BlobMemoryController::FileCreationInfo* output, | |
30 // const BlobMemoryController::FileCreationInfo& in) { | |
31 // *output = in; | |
32 //} | |
33 // | |
34 // void SetPointer(bool* out, bool success) { | |
35 // *out = success; | |
36 //} | |
37 | |
38 class BlobMemoryControllerTest : public testing::Test { | |
39 protected: | |
40 BlobMemoryControllerTest() : file_pool_(2, "test-file-pool") {} | |
41 | |
42 void SetUp() override { | |
43 ASSERT_EQ(true, base::CreateNewTempDirectory("blob_storage", &temp_dir_)); | |
44 }; | |
45 | |
46 void TearDown() override { | |
47 files_created_.clear(); | |
48 ASSERT_EQ(true, base::DeleteFile(temp_dir_, true)); | |
49 } | |
50 | |
51 void SetTestMemoryLimits(BlobMemoryController* controller) { | |
52 // controller->SetMemoryLimits( | |
53 // kTestBlobStorageMaxBlobMemorySize, kTestBlobStorageMaxMemoryUsage, | |
54 // kTestBlobStorageMaxDiskSpace, kTestBlobStorageInFlightMemory, | |
55 // kTestBlobStorageMinFileSizeBytes); | |
56 } | |
57 | |
58 void SaveFileCreationInfo(FileCreationInfo info) { | |
59 files_created_.push_back(std::move(info)); | |
60 } | |
61 | |
62 base::Callback<void(FileCreationInfo info)> GetFileCreationCallback() { | |
63 return base::Bind(&BlobMemoryControllerTest::SaveFileCreationInfo, | |
64 base::Unretained(this)); | |
65 } | |
66 | |
67 base::MessageLoop | |
68 message_loop_; // Needed by SequencedWorkerPool to function. | |
69 base::FilePath temp_dir_; | |
70 std::vector<FileCreationInfo> files_created_; | |
71 | |
72 base::SequencedWorkerPoolOwner file_pool_; | |
73 }; | |
74 | |
75 // TEST_F(BlobMemoryControllerTest, TestBasicTempFiles) { | |
76 // BlobMemoryController controller; | |
77 // SetTestMemoryLimits(&controller); | |
78 // | |
79 // // Check we can't create files. | |
80 // controller.CreateTemporaryFileForRenderer(10ull, GetFileCreationCallback()); | |
81 // | |
82 // // Check that we can | |
83 // controller.EnableDisk(temp_dir_, file_pool_.pool()); | |
84 // controller.CreateTemporaryFileForRenderer(10, GetFileCreationCallback()); | |
85 // EXPECT_EQ(1, file_pool_.has_work_call_count()); | |
86 // base::RunLoop().RunUntilIdle(); | |
87 // base::RunLoop().RunUntilIdle(); | |
88 // | |
89 // LOG(ERROR) << files_created_[1].error; | |
90 //} | |
91 | |
92 } // namespace | |
93 } // namespace storage | |
OLD | NEW |