| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "components/filesystem/public/interfaces/directory.mojom.h" | 6 #include "components/filesystem/public/interfaces/directory.mojom.h" |
| 7 #include "components/filesystem/public/interfaces/file_system.mojom.h" | 7 #include "components/filesystem/public/interfaces/file_system.mojom.h" |
| 8 #include "components/filesystem/public/interfaces/types.mojom.h" | 8 #include "components/filesystem/public/interfaces/types.mojom.h" |
| 9 #include "components/leveldb/public/interfaces/leveldb.mojom.h" | 9 #include "components/leveldb/public/interfaces/leveldb.mojom.h" |
| 10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 error = DatabaseError::OK; | 296 error = DatabaseError::OK; |
| 297 mojo::Array<uint8_t> value; | 297 mojo::Array<uint8_t> value; |
| 298 database->GetFromSnapshot( | 298 database->GetFromSnapshot( |
| 299 invalid_snapshot, | 299 invalid_snapshot, |
| 300 mojo::Array<uint8_t>::From(std::string("key")), | 300 mojo::Array<uint8_t>::From(std::string("key")), |
| 301 Capture(&error, &value)); | 301 Capture(&error, &value)); |
| 302 ASSERT_TRUE(database.WaitForIncomingResponse()); | 302 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 303 EXPECT_EQ(DatabaseError::INVALID_ARGUMENT, error); | 303 EXPECT_EQ(DatabaseError::INVALID_ARGUMENT, error); |
| 304 } | 304 } |
| 305 | 305 |
| 306 TEST_F(LevelDBApptest, MemoryDBReadWrite) { |
| 307 LevelDBDatabasePtr database; |
| 308 DatabaseError error = DatabaseError::INVALID_ARGUMENT; |
| 309 leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); |
| 310 ASSERT_TRUE(leveldb().WaitForIncomingResponse()); |
| 311 EXPECT_EQ(DatabaseError::OK, error); |
| 312 |
| 313 // Write a key to the database. |
| 314 error = DatabaseError::INVALID_ARGUMENT; |
| 315 database->Put(mojo::Array<uint8_t>::From(std::string("key")), |
| 316 mojo::Array<uint8_t>::From(std::string("value")), |
| 317 Capture(&error)); |
| 318 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 319 EXPECT_EQ(DatabaseError::OK, error); |
| 320 |
| 321 // Read the key back from the database. |
| 322 error = DatabaseError::INVALID_ARGUMENT; |
| 323 mojo::Array<uint8_t> value; |
| 324 database->Get(mojo::Array<uint8_t>::From(std::string("key")), |
| 325 Capture(&error, &value)); |
| 326 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 327 EXPECT_EQ(DatabaseError::OK, error); |
| 328 EXPECT_EQ("value", value.To<std::string>()); |
| 329 |
| 330 // Delete the key from the database. |
| 331 error = DatabaseError::INVALID_ARGUMENT; |
| 332 database->Delete(mojo::Array<uint8_t>::From(std::string("key")), |
| 333 Capture(&error)); |
| 334 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 335 EXPECT_EQ(DatabaseError::OK, error); |
| 336 |
| 337 // Read the key back from the database. |
| 338 error = DatabaseError::INVALID_ARGUMENT; |
| 339 value.SetToEmpty(); |
| 340 database->Get(mojo::Array<uint8_t>::From(std::string("key")), |
| 341 Capture(&error, &value)); |
| 342 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 343 EXPECT_EQ(DatabaseError::NOT_FOUND, error); |
| 344 EXPECT_EQ("", value.To<std::string>()); |
| 345 } |
| 346 |
| 347 |
| 306 } // namespace | 348 } // namespace |
| 307 } // namespace leveldb | 349 } // namespace leveldb |
| OLD | NEW |