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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3198 ASSERT_TRUE(dbs->MigrateVersion77To78()); | 3198 ASSERT_TRUE(dbs->MigrateVersion77To78()); |
3199 ASSERT_EQ(78, dbs->GetVersion()); | 3199 ASSERT_EQ(78, dbs->GetVersion()); |
3200 | 3200 |
3201 ASSERT_FALSE(dbs->needs_column_refresh()); | 3201 ASSERT_FALSE(dbs->needs_column_refresh()); |
3202 } | 3202 } |
3203 | 3203 |
3204 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics")); | 3204 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics")); |
3205 } | 3205 } |
3206 | 3206 |
3207 TEST_F(DirectoryBackingStoreTest, MigrateVersion78To79) { | 3207 TEST_F(DirectoryBackingStoreTest, MigrateVersion78To79) { |
3208 const int kInitialNextId = -65542; | |
3209 | |
3210 sql::Connection connection; | 3208 sql::Connection connection; |
3211 ASSERT_TRUE(connection.OpenInMemory()); | 3209 ASSERT_TRUE(connection.OpenInMemory()); |
3212 SetUpVersion78Database(&connection); | 3210 SetUpVersion78Database(&connection); |
3213 | 3211 |
3214 // Double-check the original next_id is what we think it is. | |
3215 sql::Statement s(connection.GetUniqueStatement( | |
3216 "SELECT next_id FROM share_info")); | |
3217 s.Step(); | |
3218 ASSERT_EQ(kInitialNextId, s.ColumnInt(0)); | |
3219 | |
3220 scoped_ptr<TestDirectoryBackingStore> dbs( | 3212 scoped_ptr<TestDirectoryBackingStore> dbs( |
3221 new TestDirectoryBackingStore(GetUsername(), &connection)); | 3213 new TestDirectoryBackingStore(GetUsername(), &connection)); |
3222 ASSERT_FALSE(dbs->needs_column_refresh()); | 3214 ASSERT_FALSE(dbs->needs_column_refresh()); |
3223 ASSERT_TRUE(dbs->MigrateVersion78To79()); | 3215 ASSERT_TRUE(dbs->MigrateVersion78To79()); |
3224 ASSERT_EQ(79, dbs->GetVersion()); | 3216 ASSERT_EQ(79, dbs->GetVersion()); |
3225 ASSERT_FALSE(dbs->needs_column_refresh()); | 3217 ASSERT_FALSE(dbs->needs_column_refresh()); |
3226 | |
3227 // Ensure the next_id has been incremented. | |
3228 Directory::MetahandlesMap handles_map; | |
3229 JournalIndex delete_journals; | |
3230 MetahandleSet metahandles_to_purge; | |
3231 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map); | |
3232 Directory::KernelLoadInfo load_info; | |
3233 | |
3234 s.Clear(); | |
3235 ASSERT_TRUE(dbs->Load(&handles_map, &delete_journals, &metahandles_to_purge, | |
3236 &load_info)); | |
3237 EXPECT_LE(load_info.kernel_info.next_id, kInitialNextId - 65536); | |
3238 } | 3218 } |
3239 | 3219 |
3240 TEST_F(DirectoryBackingStoreTest, MigrateVersion79To80) { | 3220 TEST_F(DirectoryBackingStoreTest, MigrateVersion79To80) { |
3241 sql::Connection connection; | 3221 sql::Connection connection; |
3242 ASSERT_TRUE(connection.OpenInMemory()); | 3222 ASSERT_TRUE(connection.OpenInMemory()); |
3243 SetUpVersion79Database(&connection); | 3223 SetUpVersion79Database(&connection); |
3244 | 3224 |
3245 scoped_ptr<TestDirectoryBackingStore> dbs( | 3225 scoped_ptr<TestDirectoryBackingStore> dbs( |
3246 new TestDirectoryBackingStore(GetUsername(), &connection)); | 3226 new TestDirectoryBackingStore(GetUsername(), &connection)); |
3247 ASSERT_FALSE(dbs->needs_column_refresh()); | 3227 ASSERT_FALSE(dbs->needs_column_refresh()); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4118 ASSERT_FALSE(dbs->SaveChanges(snapshot)); | 4098 ASSERT_FALSE(dbs->SaveChanges(snapshot)); |
4119 // At this point the handler has been posted but not executed. | 4099 // At this point the handler has been posted but not executed. |
4120 ASSERT_FALSE(was_called); | 4100 ASSERT_FALSE(was_called); |
4121 // Pump the message loop and see that it is executed. | 4101 // Pump the message loop and see that it is executed. |
4122 base::RunLoop().RunUntilIdle(); | 4102 base::RunLoop().RunUntilIdle(); |
4123 ASSERT_TRUE(was_called); | 4103 ASSERT_TRUE(was_called); |
4124 } | 4104 } |
4125 | 4105 |
4126 } // namespace syncable | 4106 } // namespace syncable |
4127 } // namespace syncer | 4107 } // namespace syncer |
OLD | NEW |