OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "sql/test/test_helpers.h" | 5 #include "sql/test/test_helpers.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 bool CorruptSizeInHeader(const base::FilePath& db_path) { | 48 bool CorruptSizeInHeader(const base::FilePath& db_path) { |
49 // See http://www.sqlite.org/fileformat.html#database_header | 49 // See http://www.sqlite.org/fileformat.html#database_header |
50 const size_t kHeaderSize = 100; | 50 const size_t kHeaderSize = 100; |
51 const size_t kPageSizeOffset = 16; | 51 const size_t kPageSizeOffset = 16; |
52 const size_t kFileChangeCountOffset = 24; | 52 const size_t kFileChangeCountOffset = 24; |
53 const size_t kPageCountOffset = 28; | 53 const size_t kPageCountOffset = 28; |
54 const size_t kVersionValidForOffset = 92; // duplicate kFileChangeCountOffset | 54 const size_t kVersionValidForOffset = 92; // duplicate kFileChangeCountOffset |
55 | 55 |
56 unsigned char header[kHeaderSize]; | 56 unsigned char header[kHeaderSize]; |
57 | 57 |
58 file_util::ScopedFILE file(file_util::OpenFile(db_path, "rb+")); | 58 file_util::ScopedFILE file(base::OpenFile(db_path, "rb+")); |
59 if (!file.get()) | 59 if (!file.get()) |
60 return false; | 60 return false; |
61 | 61 |
62 if (0 != fseek(file.get(), 0, SEEK_SET)) | 62 if (0 != fseek(file.get(), 0, SEEK_SET)) |
63 return false; | 63 return false; |
64 if (1u != fread(header, sizeof(header), 1, file.get())) | 64 if (1u != fread(header, sizeof(header), 1, file.get())) |
65 return false; | 65 return false; |
66 | 66 |
67 int64 db_size = 0; | 67 int64 db_size = 0; |
68 if (!base::GetFileSize(db_path, &db_size)) | 68 if (!base::GetFileSize(db_path, &db_size)) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); | 157 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); |
158 | 158 |
159 // SQLite should always return a row of data. | 159 // SQLite should always return a row of data. |
160 EXPECT_TRUE(statement.Step()); | 160 EXPECT_TRUE(statement.Step()); |
161 | 161 |
162 return statement.ColumnString(0); | 162 return statement.ColumnString(0); |
163 } | 163 } |
164 | 164 |
165 } // namespace test | 165 } // namespace test |
166 } // namespace sql | 166 } // namespace sql |
OLD | NEW |