OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 <memory> |
5 #include "components/filesystem/public/interfaces/file_system.mojom.h" | 6 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
6 #include "mojo/application/public/cpp/application_impl.h" | 7 #include "mojo/application/public/cpp/application_impl.h" |
7 #include "mojo/application/public/cpp/application_test_base.h" | 8 #include "mojo/application/public/cpp/application_test_base.h" |
8 #include "mojo/util/capture_util.h" | 9 #include "mojo/util/capture_util.h" |
9 #include "sql/mojo/mojo_vfs.h" | 10 #include "sql/mojo/mojo_vfs.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/sqlite/sqlite3.h" | 12 #include "third_party/sqlite/sqlite3.h" |
12 | 13 |
13 namespace base { | 14 namespace std { |
14 | 15 |
15 // This deleter lets us be safe with sqlite3 objects, which aren't really the | 16 // This deleter lets us be safe with sqlite3 objects, which aren't really the |
16 // structs, but slabs of new uint8_t[size]. | 17 // structs, but slabs of new uint8_t[size]. |
17 template <> | 18 template <> |
18 struct DefaultDeleter<sqlite3_file> { | 19 struct default_delete<sqlite3_file> { |
19 inline void operator()(sqlite3_file* ptr) const { | 20 inline void operator()(sqlite3_file* ptr) const { |
20 // Why don't we call file->pMethods->xClose() here? Because it's not | 21 // Why don't we call file->pMethods->xClose() here? Because it's not |
21 // guaranteed to be valid. sqlite3_file "objects" can be in partially | 22 // guaranteed to be valid. sqlite3_file "objects" can be in partially |
22 // initialized states. | 23 // initialized states. |
23 delete [] reinterpret_cast<uint8_t*>(ptr); | 24 delete [] reinterpret_cast<uint8_t*>(ptr); |
24 } | 25 } |
25 }; | 26 }; |
26 | 27 |
27 } // namespace base | 28 } // namespace std |
28 | 29 |
29 namespace sql { | 30 namespace sql { |
30 | 31 |
31 const char kFileName[] = "TestingDatabase.db"; | 32 const char kFileName[] = "TestingDatabase.db"; |
32 | 33 |
33 class VFSTest : public mojo::test::ApplicationTestBase, | 34 class VFSTest : public mojo::test::ApplicationTestBase, |
34 public filesystem::FileSystemClient { | 35 public filesystem::FileSystemClient { |
35 public: | 36 public: |
36 VFSTest() : binding_(this) {} | 37 VFSTest() : binding_(this) {} |
37 ~VFSTest() override {} | 38 ~VFSTest() override {} |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 EXPECT_EQ(SQLITE_OK, rc); | 331 EXPECT_EQ(SQLITE_OK, rc); |
331 | 332 |
332 rc = file->pMethods->xFileSize(file.get(), &size); | 333 rc = file->pMethods->xFileSize(file.get(), &size); |
333 EXPECT_EQ(SQLITE_OK, rc); | 334 EXPECT_EQ(SQLITE_OK, rc); |
334 EXPECT_EQ(kCharsToThree, size); | 335 EXPECT_EQ(kCharsToThree, size); |
335 | 336 |
336 file->pMethods->xClose(file.get()); | 337 file->pMethods->xClose(file.get()); |
337 } | 338 } |
338 | 339 |
339 } // namespace sql | 340 } // namespace sql |
OLD | NEW |