| 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/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 EXPECT_EQ(in_method, method); | 36 EXPECT_EQ(in_method, method); |
| 37 EXPECT_EQ(base::File::FILE_ERROR_MAX, error); | 37 EXPECT_EQ(base::File::FILE_ERROR_MAX, error); |
| 38 } | 38 } |
| 39 | 39 |
| 40 TEST(ErrorEncoding, FileError) { | 40 TEST(ErrorEncoding, FileError) { |
| 41 const MethodID in_method = leveldb_env::kWritableFileClose; | 41 const MethodID in_method = leveldb_env::kWritableFileClose; |
| 42 const base::File::Error fe = base::File::FILE_ERROR_INVALID_OPERATION; | 42 const base::File::Error fe = base::File::FILE_ERROR_INVALID_OPERATION; |
| 43 const Status s = MakeIOError("Somefile.txt", "message", in_method, fe); | 43 const Status s = MakeIOError("Somefile.txt", "message", in_method, fe); |
| 44 MethodID method; | 44 MethodID method; |
| 45 base::File::Error error; | 45 base::File::Error error; |
| 46 EXPECT_EQ(leveldb_env::METHOD_AND_PFE, | 46 EXPECT_EQ(leveldb_env::METHOD_AND_BFE, |
| 47 ParseMethodAndError(s, &method, &error)); | 47 ParseMethodAndError(s, &method, &error)); |
| 48 EXPECT_EQ(in_method, method); | 48 EXPECT_EQ(in_method, method); |
| 49 EXPECT_EQ(fe, error); | 49 EXPECT_EQ(fe, error); |
| 50 } | 50 } |
| 51 | 51 |
| 52 TEST(ErrorEncoding, NoEncodedMessage) { | 52 TEST(ErrorEncoding, NoEncodedMessage) { |
| 53 Status s = Status::IOError("Some message", "from leveldb itself"); | 53 Status s = Status::IOError("Some message", "from leveldb itself"); |
| 54 MethodID method = leveldb_env::kRandomAccessFileRead; | 54 MethodID method = leveldb_env::kRandomAccessFileRead; |
| 55 base::File::Error error = base::File::FILE_ERROR_MAX; | 55 base::File::Error error = base::File::FILE_ERROR_MAX; |
| 56 EXPECT_EQ(leveldb_env::NONE, ParseMethodAndError(s, &method, &error)); | 56 EXPECT_EQ(leveldb_env::NONE, ParseMethodAndError(s, &method, &error)); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 EXPECT_TRUE(status.ok()); | 222 EXPECT_TRUE(status.ok()); |
| 223 EXPECT_EQ(1U, result.size()); | 223 EXPECT_EQ(1U, result.size()); |
| 224 | 224 |
| 225 // And a second time should also return one result | 225 // And a second time should also return one result |
| 226 status = env->GetChildren(dir.AsUTF8Unsafe(), &result); | 226 status = env->GetChildren(dir.AsUTF8Unsafe(), &result); |
| 227 EXPECT_TRUE(status.ok()); | 227 EXPECT_TRUE(status.ok()); |
| 228 EXPECT_EQ(1U, result.size()); | 228 EXPECT_EQ(1U, result.size()); |
| 229 } | 229 } |
| 230 | 230 |
| 231 int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); } | 231 int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); } |
| OLD | NEW |