| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/sync/syncable/directory_backing_store.h" | 5 #include "components/sync/syncable/directory_backing_store.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 class MigrationTest : public testing::TestWithParam<int> { | 59 class MigrationTest : public testing::TestWithParam<int> { |
| 60 public: | 60 public: |
| 61 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } | 61 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 std::string GetUsername() { | 64 std::string GetUsername() { |
| 65 return "nick@chromium.org"; | 65 return "nick@chromium.org"; |
| 66 } | 66 } |
| 67 | 67 |
| 68 base::FilePath GetDatabasePath() { | 68 base::FilePath GetDatabasePath() { |
| 69 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename); | 69 return temp_dir_.GetPath().Append(Directory::kSyncDatabaseFilename); |
| 70 } | 70 } |
| 71 | 71 |
| 72 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { | 72 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { |
| 73 Directory::MetahandlesMap tmp_handles_map; | 73 Directory::MetahandlesMap tmp_handles_map; |
| 74 JournalIndex delete_journals; | 74 JournalIndex delete_journals; |
| 75 MetahandleSet metahandles_to_purge; | 75 MetahandleSet metahandles_to_purge; |
| 76 Directory::KernelLoadInfo kernel_load_info; | 76 Directory::KernelLoadInfo kernel_load_info; |
| 77 return dbs->Load(&tmp_handles_map, &delete_journals, &metahandles_to_purge, | 77 return dbs->Load(&tmp_handles_map, &delete_journals, &metahandles_to_purge, |
| 78 &kernel_load_info) == OPENED; | 78 &kernel_load_info) == OPENED; |
| 79 } | 79 } |
| (...skipping 3433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 // The purpose of this test case is to make it easier to get a dump of the | 3513 // The purpose of this test case is to make it easier to get a dump of the |
| 3514 // database so you can implement a SetUpVersionYDatabase method. Here's what | 3514 // database so you can implement a SetUpVersionYDatabase method. Here's what |
| 3515 // you should do: | 3515 // you should do: |
| 3516 // | 3516 // |
| 3517 // 1. Say you're going from version X to version Y. Write the migration | 3517 // 1. Say you're going from version X to version Y. Write the migration |
| 3518 // method MigrateVersionXToY. | 3518 // method MigrateVersionXToY. |
| 3519 // 2. Update the test below to call SetUpVersionXDatabase and then | 3519 // 2. Update the test below to call SetUpVersionXDatabase and then |
| 3520 // MigrateVersionXToY. You now have a database at version Y. Let's dump it. | 3520 // MigrateVersionXToY. You now have a database at version Y. Let's dump it. |
| 3521 // 3. Set a breakpoint to stop execution just after the connection is | 3521 // 3. Set a breakpoint to stop execution just after the connection is |
| 3522 // destroyed. Examine temp_dir_ to find the version Y database that was | 3522 // destroyed. Examine temp_dir_ to find the version Y database that was |
| 3523 // created on disk. E.g. (gdb) p temp_dir_.path().value().c_str() | 3523 // created on disk. E.g. (gdb) p temp_dir_.GetPath().value().c_str() |
| 3524 // 4. Dump the database using the sqlite3 command line tool: | 3524 // 4. Dump the database using the sqlite3 command line tool: |
| 3525 // > .output foo_dump.sql | 3525 // > .output foo_dump.sql |
| 3526 // > .dump | 3526 // > .dump |
| 3527 // 5. Replace the timestamp columns with META_PROTO_TIMES(x) (or | 3527 // 5. Replace the timestamp columns with META_PROTO_TIMES(x) (or |
| 3528 // LEGACY_META_PROTO_TIMES(x) if before Version 77). Use this dump to write | 3528 // LEGACY_META_PROTO_TIMES(x) if before Version 77). Use this dump to write |
| 3529 // a SetupVersionYDatabase method. | 3529 // a SetupVersionYDatabase method. |
| 3530 TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) { | 3530 TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) { |
| 3531 { | 3531 { |
| 3532 sql::Connection connection; | 3532 sql::Connection connection; |
| 3533 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 3533 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4254 ASSERT_FALSE(dbs->SaveChanges(snapshot)); | 4254 ASSERT_FALSE(dbs->SaveChanges(snapshot)); |
| 4255 // At this point the handler has been posted but not executed. | 4255 // At this point the handler has been posted but not executed. |
| 4256 ASSERT_FALSE(was_called); | 4256 ASSERT_FALSE(was_called); |
| 4257 // Pump the message loop and see that it is executed. | 4257 // Pump the message loop and see that it is executed. |
| 4258 base::RunLoop().RunUntilIdle(); | 4258 base::RunLoop().RunUntilIdle(); |
| 4259 ASSERT_TRUE(was_called); | 4259 ASSERT_TRUE(was_called); |
| 4260 } | 4260 } |
| 4261 | 4261 |
| 4262 } // namespace syncable | 4262 } // namespace syncable |
| 4263 } // namespace syncer | 4263 } // namespace syncer |
| OLD | NEW |