OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file.h" | 5 #include "base/files/file.h" |
6 #include "base/files/file_enumerator.h" | 6 #include "base/files/file_enumerator.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 leveldb::Status status = env->GetChildren(dir.AsUTF8Unsafe(), &result); | 162 leveldb::Status status = env->GetChildren(dir.AsUTF8Unsafe(), &result); |
163 EXPECT_TRUE(status.ok()); | 163 EXPECT_TRUE(status.ok()); |
164 EXPECT_EQ(1U, result.size()); | 164 EXPECT_EQ(1U, result.size()); |
165 | 165 |
166 // And a second time should also return one result | 166 // And a second time should also return one result |
167 status = env->GetChildren(dir.AsUTF8Unsafe(), &result); | 167 status = env->GetChildren(dir.AsUTF8Unsafe(), &result); |
168 EXPECT_TRUE(status.ok()); | 168 EXPECT_TRUE(status.ok()); |
169 EXPECT_EQ(1U, result.size()); | 169 EXPECT_EQ(1U, result.size()); |
170 } | 170 } |
171 | 171 |
| 172 TEST(ChromiumEnv, TestWriteBufferSize) { |
| 173 // If can't get disk size, use leveldb defaults. |
| 174 const int64_t MB = 1024 * 1024; |
| 175 EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(-1)); |
| 176 |
| 177 // A very small disk (check lower clamp value). |
| 178 EXPECT_EQ(size_t(1 * MB), leveldb_env::WriteBufferSize(1 * MB)); |
| 179 |
| 180 // Some value on the linear equation between min and max. |
| 181 EXPECT_EQ(size_t(2.5 * MB), leveldb_env::WriteBufferSize(25 * MB)); |
| 182 |
| 183 // The disk size equating to the max buffer size |
| 184 EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(40 * MB)); |
| 185 |
| 186 // Make sure sizes larger than 40MB are clamped to max buffer size. |
| 187 EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(80 * MB)); |
| 188 |
| 189 // Check for very large disk size (catch overflow). |
| 190 EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(100 * MB * MB)); |
| 191 } |
| 192 |
172 int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); } | 193 int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); } |
OLD | NEW |