| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 LevelDBServicePtr& leveldb() { return leveldb_; } | 52 LevelDBServicePtr& leveldb() { return leveldb_; } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 filesystem::FileSystemPtr files_; | 55 filesystem::FileSystemPtr files_; |
| 56 LevelDBServicePtr leveldb_; | 56 LevelDBServicePtr leveldb_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(LevelDBServiceTest); | 58 DISALLOW_COPY_AND_ASSIGN(LevelDBServiceTest); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // TODO(crbug.com/602820) Test is flaky. | 61 // TODO(crbug.com/602820) Test is flaky. |
| 62 #if defined(OS_LINUX) | 62 #if defined(OS_LINUX) || defined(OS_WIN) |
| 63 #define MAYBE_Basic DISABLED_Basic | 63 #define MAYBE_Basic DISABLED_Basic |
| 64 #else | 64 #else |
| 65 #define MAYBE_Basic Basic | 65 #define MAYBE_Basic Basic |
| 66 #endif | 66 #endif |
| 67 TEST_F(LevelDBServiceTest, MAYBE_Basic) { | 67 TEST_F(LevelDBServiceTest, MAYBE_Basic) { |
| 68 filesystem::DirectoryPtr directory; | 68 filesystem::DirectoryPtr directory; |
| 69 GetUserDataDir(&directory); | 69 GetUserDataDir(&directory); |
| 70 | 70 |
| 71 DatabaseError error; | 71 DatabaseError error; |
| 72 LevelDBDatabasePtr database; | 72 LevelDBDatabasePtr database; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 103 error = DatabaseError::INVALID_ARGUMENT; | 103 error = DatabaseError::INVALID_ARGUMENT; |
| 104 value.SetToEmpty(); | 104 value.SetToEmpty(); |
| 105 database->Get(mojo::Array<uint8_t>::From(std::string("key")), | 105 database->Get(mojo::Array<uint8_t>::From(std::string("key")), |
| 106 Capture(&error, &value)); | 106 Capture(&error, &value)); |
| 107 ASSERT_TRUE(database.WaitForIncomingResponse()); | 107 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 108 EXPECT_EQ(DatabaseError::NOT_FOUND, error); | 108 EXPECT_EQ(DatabaseError::NOT_FOUND, error); |
| 109 EXPECT_EQ("", value.To<std::string>()); | 109 EXPECT_EQ("", value.To<std::string>()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // TODO(crbug.com/602820) Test is flaky. | 112 // TODO(crbug.com/602820) Test is flaky. |
| 113 #if defined(OS_LINUX) | 113 #if defined(OS_LINUX) || defined(OS_WIN) |
| 114 #define MAYBE_WriteBatch DISABLED_WriteBatch | 114 #define MAYBE_WriteBatch DISABLED_WriteBatch |
| 115 #else | 115 #else |
| 116 #define MAYBE_WriteBatch WriteBatch | 116 #define MAYBE_WriteBatch WriteBatch |
| 117 #endif | 117 #endif |
| 118 TEST_F(LevelDBServiceTest, MAYBE_WriteBatch) { | 118 TEST_F(LevelDBServiceTest, MAYBE_WriteBatch) { |
| 119 DatabaseError error; | 119 DatabaseError error; |
| 120 LevelDBDatabasePtr database; | 120 LevelDBDatabasePtr database; |
| 121 leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); | 121 leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); |
| 122 ASSERT_TRUE(leveldb().WaitForIncomingResponse()); | 122 ASSERT_TRUE(leveldb().WaitForIncomingResponse()); |
| 123 EXPECT_EQ(DatabaseError::OK, error); | 123 EXPECT_EQ(DatabaseError::OK, error); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 error = DatabaseError::INVALID_ARGUMENT; | 197 error = DatabaseError::INVALID_ARGUMENT; |
| 198 value = nullptr; | 198 value = nullptr; |
| 199 database->Get(mojo::Array<uint8_t>::From(std::string("prefix-key2")), | 199 database->Get(mojo::Array<uint8_t>::From(std::string("prefix-key2")), |
| 200 Capture(&error, &value)); | 200 Capture(&error, &value)); |
| 201 ASSERT_TRUE(database.WaitForIncomingResponse()); | 201 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 202 EXPECT_EQ(DatabaseError::NOT_FOUND, error); | 202 EXPECT_EQ(DatabaseError::NOT_FOUND, error); |
| 203 EXPECT_EQ("", value.To<std::string>()); | 203 EXPECT_EQ("", value.To<std::string>()); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // TODO(crbug.com/602820) Test is flaky. | 206 // TODO(crbug.com/602820) Test is flaky. |
| 207 #if defined(OS_LINUX) | 207 #if defined(OS_LINUX) || defined(OS_WIN) |
| 208 #define MAYBE_Reconnect DISABLED_Reconnect | 208 #define MAYBE_Reconnect DISABLED_Reconnect |
| 209 #else | 209 #else |
| 210 #define MAYBE_Reconnect Reconnect | 210 #define MAYBE_Reconnect Reconnect |
| 211 #endif | 211 #endif |
| 212 TEST_F(LevelDBServiceTest, MAYBE_Reconnect) { | 212 TEST_F(LevelDBServiceTest, MAYBE_Reconnect) { |
| 213 DatabaseError error; | 213 DatabaseError error; |
| 214 | 214 |
| 215 { | 215 { |
| 216 filesystem::DirectoryPtr directory; | 216 filesystem::DirectoryPtr directory; |
| 217 GetUserDataDir(&directory); | 217 GetUserDataDir(&directory); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 mojo::Array<uint8_t> value; | 249 mojo::Array<uint8_t> value; |
| 250 database->Get(mojo::Array<uint8_t>::From(std::string("key")), | 250 database->Get(mojo::Array<uint8_t>::From(std::string("key")), |
| 251 Capture(&error, &value)); | 251 Capture(&error, &value)); |
| 252 ASSERT_TRUE(database.WaitForIncomingResponse()); | 252 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 253 EXPECT_EQ(DatabaseError::OK, error); | 253 EXPECT_EQ(DatabaseError::OK, error); |
| 254 EXPECT_EQ("value", value.To<std::string>()); | 254 EXPECT_EQ("value", value.To<std::string>()); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 // TODO(crbug.com/602820) Test is flaky. | 258 // TODO(crbug.com/602820) Test is flaky. |
| 259 #if defined(OS_LINUX) | 259 #if defined(OS_LINUX) || defined(OS_WIN) |
| 260 #define MAYBE_GetSnapshotSimple DISABLED_GetSnapshotSimple | 260 #define MAYBE_GetSnapshotSimple DISABLED_GetSnapshotSimple |
| 261 #else | 261 #else |
| 262 #define MAYBE_GetSnapshotSimple GetSnapshotSimple | 262 #define MAYBE_GetSnapshotSimple GetSnapshotSimple |
| 263 #endif | 263 #endif |
| 264 TEST_F(LevelDBServiceTest, MAYBE_GetSnapshotSimple) { | 264 TEST_F(LevelDBServiceTest, MAYBE_GetSnapshotSimple) { |
| 265 DatabaseError error; | 265 DatabaseError error; |
| 266 | 266 |
| 267 filesystem::DirectoryPtr directory; | 267 filesystem::DirectoryPtr directory; |
| 268 GetUserDataDir(&directory); | 268 GetUserDataDir(&directory); |
| 269 | 269 |
| 270 LevelDBDatabasePtr database; | 270 LevelDBDatabasePtr database; |
| 271 leveldb()->Open(std::move(directory), "test", GetProxy(&database), | 271 leveldb()->Open(std::move(directory), "test", GetProxy(&database), |
| 272 Capture(&error)); | 272 Capture(&error)); |
| 273 ASSERT_TRUE(leveldb().WaitForIncomingResponse()); | 273 ASSERT_TRUE(leveldb().WaitForIncomingResponse()); |
| 274 EXPECT_EQ(DatabaseError::OK, error); | 274 EXPECT_EQ(DatabaseError::OK, error); |
| 275 | 275 |
| 276 uint64_t snapshot_id = 0; | 276 uint64_t snapshot_id = 0; |
| 277 database->GetSnapshot(Capture(&snapshot_id)); | 277 database->GetSnapshot(Capture(&snapshot_id)); |
| 278 ASSERT_TRUE(database.WaitForIncomingResponse()); | 278 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 279 EXPECT_NE(static_cast<uint64_t>(0), snapshot_id); | 279 EXPECT_NE(static_cast<uint64_t>(0), snapshot_id); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // TODO(crbug.com/602820) Test is flaky. | 282 // TODO(crbug.com/602820) Test is flaky. |
| 283 #if defined(OS_LINUX) | 283 #if defined(OS_LINUX) || defined(OS_WIN) |
| 284 #define MAYBE_GetFromSnapshots DISABLED_GetFromSnapshots | 284 #define MAYBE_GetFromSnapshots DISABLED_GetFromSnapshots |
| 285 #else | 285 #else |
| 286 #define MAYBE_GetFromSnapshots GetFromSnapshots | 286 #define MAYBE_GetFromSnapshots GetFromSnapshots |
| 287 #endif | 287 #endif |
| 288 TEST_F(LevelDBServiceTest, MAYBE_GetFromSnapshots) { | 288 TEST_F(LevelDBServiceTest, MAYBE_GetFromSnapshots) { |
| 289 DatabaseError error; | 289 DatabaseError error; |
| 290 | 290 |
| 291 filesystem::DirectoryPtr directory; | 291 filesystem::DirectoryPtr directory; |
| 292 GetUserDataDir(&directory); | 292 GetUserDataDir(&directory); |
| 293 | 293 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 database->GetFromSnapshot( | 333 database->GetFromSnapshot( |
| 334 key_value_snapshot, | 334 key_value_snapshot, |
| 335 mojo::Array<uint8_t>::From(std::string("key")), | 335 mojo::Array<uint8_t>::From(std::string("key")), |
| 336 Capture(&error, &value)); | 336 Capture(&error, &value)); |
| 337 ASSERT_TRUE(database.WaitForIncomingResponse()); | 337 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 338 EXPECT_EQ(DatabaseError::OK, error); | 338 EXPECT_EQ(DatabaseError::OK, error); |
| 339 EXPECT_EQ("value", value.To<std::string>()); | 339 EXPECT_EQ("value", value.To<std::string>()); |
| 340 } | 340 } |
| 341 | 341 |
| 342 // TODO(crbug.com/602820) Test is flaky. | 342 // TODO(crbug.com/602820) Test is flaky. |
| 343 #if defined(OS_LINUX) | 343 #if defined(OS_LINUX) || defined(OS_WIN) |
| 344 #define MAYBE_InvalidArgumentOnInvalidSnapshot DISABLED_InvalidArgumentOnInvalid
Snapshot | 344 #define MAYBE_InvalidArgumentOnInvalidSnapshot DISABLED_InvalidArgumentOnInvalid
Snapshot |
| 345 #else | 345 #else |
| 346 #define MAYBE_InvalidArgumentOnInvalidSnapshot InvalidArgumentOnInvalidSnapshot | 346 #define MAYBE_InvalidArgumentOnInvalidSnapshot InvalidArgumentOnInvalidSnapshot |
| 347 #endif | 347 #endif |
| 348 TEST_F(LevelDBServiceTest, MAYBE_InvalidArgumentOnInvalidSnapshot) { | 348 TEST_F(LevelDBServiceTest, MAYBE_InvalidArgumentOnInvalidSnapshot) { |
| 349 filesystem::DirectoryPtr directory; | 349 filesystem::DirectoryPtr directory; |
| 350 GetUserDataDir(&directory); | 350 GetUserDataDir(&directory); |
| 351 | 351 |
| 352 LevelDBDatabasePtr database; | 352 LevelDBDatabasePtr database; |
| 353 DatabaseError error = DatabaseError::INVALID_ARGUMENT; | 353 DatabaseError error = DatabaseError::INVALID_ARGUMENT; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 key_values.SetToEmpty(); | 538 key_values.SetToEmpty(); |
| 539 database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), | 539 database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), |
| 540 Capture(&error, &key_values)); | 540 Capture(&error, &key_values)); |
| 541 ASSERT_TRUE(database.WaitForIncomingResponse()); | 541 ASSERT_TRUE(database.WaitForIncomingResponse()); |
| 542 EXPECT_EQ(DatabaseError::OK, error); | 542 EXPECT_EQ(DatabaseError::OK, error); |
| 543 EXPECT_TRUE(key_values.empty()); | 543 EXPECT_TRUE(key_values.empty()); |
| 544 } | 544 } |
| 545 | 545 |
| 546 } // namespace | 546 } // namespace |
| 547 } // namespace leveldb | 547 } // namespace leveldb |
| OLD | NEW |