| 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 "components/filesystem/public/interfaces/file_system.mojom.h" | 5 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
| 6 #include "mojo/application/public/cpp/application_impl.h" | 6 #include "mojo/application/public/cpp/application_impl.h" |
| 7 #include "mojo/application/public/cpp/application_test_base.h" | 7 #include "mojo/application/public/cpp/application_test_base.h" |
| 8 #include "mojo/util/capture_util.h" | 8 #include "mojo/util/capture_util.h" |
| 9 #include "sql/mojo/mojo_vfs.h" | 9 #include "sql/mojo/mojo_vfs.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 scoped_ptr<sqlite3_file> file2(MakeFile()); | 108 scoped_ptr<sqlite3_file> file2(MakeFile()); |
| 109 rc = vfs()->xOpen(vfs(), kFileName, file2.get(), | 109 rc = vfs()->xOpen(vfs(), kFileName, file2.get(), |
| 110 SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, | 110 SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, |
| 111 &out_flags); | 111 &out_flags); |
| 112 EXPECT_EQ(SQLITE_OK, rc); | 112 EXPECT_EQ(SQLITE_OK, rc); |
| 113 | 113 |
| 114 file->pMethods->xClose(file.get()); | 114 file->pMethods->xClose(file.get()); |
| 115 file->pMethods->xClose(file2.get()); | 115 file->pMethods->xClose(file2.get()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 TEST_F(VFSTest, NullFilenameOpen) { | |
| 119 // Opening a file with a null filename should return a valid file object. | |
| 120 scoped_ptr<sqlite3_file> file(MakeFile()); | |
| 121 int out_flags; | |
| 122 int rc = vfs()->xOpen( | |
| 123 vfs(), nullptr, file.get(), | |
| 124 SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, | |
| 125 &out_flags); | |
| 126 EXPECT_EQ(SQLITE_OK, rc); | |
| 127 | |
| 128 file->pMethods->xClose(file.get()); | |
| 129 } | |
| 130 | |
| 131 TEST_F(VFSTest, DeleteOnClose) { | 118 TEST_F(VFSTest, DeleteOnClose) { |
| 132 { | 119 { |
| 133 scoped_ptr<sqlite3_file> file(MakeFile()); | 120 scoped_ptr<sqlite3_file> file(MakeFile()); |
| 134 int out_flags; | 121 int out_flags; |
| 135 int rc = vfs()->xOpen( | 122 int rc = vfs()->xOpen( |
| 136 vfs(), kFileName, file.get(), | 123 vfs(), kFileName, file.get(), |
| 137 SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, | 124 SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, |
| 138 &out_flags); | 125 &out_flags); |
| 139 EXPECT_EQ(SQLITE_OK, rc); | 126 EXPECT_EQ(SQLITE_OK, rc); |
| 140 file->pMethods->xClose(file.get()); | 127 file->pMethods->xClose(file.get()); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 EXPECT_EQ(SQLITE_OK, rc); | 308 EXPECT_EQ(SQLITE_OK, rc); |
| 322 | 309 |
| 323 rc = file->pMethods->xFileSize(file.get(), &size); | 310 rc = file->pMethods->xFileSize(file.get(), &size); |
| 324 EXPECT_EQ(SQLITE_OK, rc); | 311 EXPECT_EQ(SQLITE_OK, rc); |
| 325 EXPECT_EQ(kCharsToThree, size); | 312 EXPECT_EQ(kCharsToThree, size); |
| 326 | 313 |
| 327 file->pMethods->xClose(file.get()); | 314 file->pMethods->xClose(file.get()); |
| 328 } | 315 } |
| 329 | 316 |
| 330 } // namespace sql | 317 } // namespace sql |
| OLD | NEW |