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 |
118 TEST_F(VFSTest, DeleteOnClose) { | 131 TEST_F(VFSTest, DeleteOnClose) { |
119 { | 132 { |
120 scoped_ptr<sqlite3_file> file(MakeFile()); | 133 scoped_ptr<sqlite3_file> file(MakeFile()); |
121 int out_flags; | 134 int out_flags; |
122 int rc = vfs()->xOpen( | 135 int rc = vfs()->xOpen( |
123 vfs(), kFileName, file.get(), | 136 vfs(), kFileName, file.get(), |
124 SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, | 137 SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, |
125 &out_flags); | 138 &out_flags); |
126 EXPECT_EQ(SQLITE_OK, rc); | 139 EXPECT_EQ(SQLITE_OK, rc); |
127 file->pMethods->xClose(file.get()); | 140 file->pMethods->xClose(file.get()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 EXPECT_EQ(SQLITE_OK, rc); | 321 EXPECT_EQ(SQLITE_OK, rc); |
309 | 322 |
310 rc = file->pMethods->xFileSize(file.get(), &size); | 323 rc = file->pMethods->xFileSize(file.get(), &size); |
311 EXPECT_EQ(SQLITE_OK, rc); | 324 EXPECT_EQ(SQLITE_OK, rc); |
312 EXPECT_EQ(kCharsToThree, size); | 325 EXPECT_EQ(kCharsToThree, size); |
313 | 326 |
314 file->pMethods->xClose(file.get()); | 327 file->pMethods->xClose(file.get()); |
315 } | 328 } |
316 | 329 |
317 } // namespace sql | 330 } // namespace sql |
OLD | NEW |