OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2072 Directory::KernelLoadInfo load_info; | 2072 Directory::KernelLoadInfo load_info; |
2073 | 2073 |
2074 ASSERT_TRUE(dbs->Load(&entry_bucket, &load_info)); | 2074 ASSERT_TRUE(dbs->Load(&entry_bucket, &load_info)); |
2075 // Check that the initial value is the serialization of an empty ChipBag. | 2075 // Check that the initial value is the serialization of an empty ChipBag. |
2076 sync_pb::ChipBag chip_bag; | 2076 sync_pb::ChipBag chip_bag; |
2077 std::string serialized_chip_bag; | 2077 std::string serialized_chip_bag; |
2078 ASSERT_TRUE(chip_bag.SerializeToString(&serialized_chip_bag)); | 2078 ASSERT_TRUE(chip_bag.SerializeToString(&serialized_chip_bag)); |
2079 EXPECT_EQ(serialized_chip_bag, load_info.kernel_info.bag_of_chips); | 2079 EXPECT_EQ(serialized_chip_bag, load_info.kernel_info.bag_of_chips); |
2080 } | 2080 } |
2081 | 2081 |
2082 TEST_F(DirectoryBackingStoreTest, MigrateVersion80To81) { | |
2083 sql::Connection connection; | |
2084 ASSERT_TRUE(connection.OpenInMemory()); | |
2085 | |
2086 // Unfortunately there isn't a SetUpVersion80Database to use | |
rlarocque
2012/09/27 23:10:12
You should fix this. I believe it was Nicolas who
| |
2087 // and I (vishwath) don't know enough about the bag_of_chips | |
2088 // to write it myself (yet). So assuming the previous test | |
2089 // passed, create at ver 79 and migrate up to 81 instead. | |
2090 SetupVersion79Database(&connection); | |
2091 | |
2092 sql::Statement s(connection.GetUniqueStatement( | |
2093 "SELECT id FROM metas WHERE unique_server_tag = 'google_chrome'")); | |
2094 ASSERT_TRUE(s.Step()); | |
2095 ASSERT_EQ(s.ColumnType(3), COLUMN_TYPE_INTEGER); | |
2096 | |
2097 scoped_ptr<TestDirectoryBackingStore> dbs( | |
2098 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
2099 ASSERT_TRUE(dbs->MigrateVersion79To80()); | |
2100 ASSERT_TRUE(dbs->MigrateVersion80To81()); | |
2101 | |
2102 sql::Statement s(connection.GetUniqueStatement( | |
2103 "SELECT id FROM metas WHERE unique_server_tag = 'google_chrome'")); | |
2104 ASSERT_TRUE(s.Step()); | |
2105 ASSERT_EQ(s.ColumnType(3), COLUMN_TYPE_TEXT); | |
rlarocque
2012/09/27 23:10:12
Shouldn't you check the values stored in the colum
| |
2106 } | |
2107 | |
2082 TEST_P(MigrationTest, ToCurrentVersion) { | 2108 TEST_P(MigrationTest, ToCurrentVersion) { |
2083 sql::Connection connection; | 2109 sql::Connection connection; |
2084 ASSERT_TRUE(connection.OpenInMemory()); | 2110 ASSERT_TRUE(connection.OpenInMemory()); |
2085 switch (GetParam()) { | 2111 switch (GetParam()) { |
2086 case 67: | 2112 case 67: |
2087 SetUpVersion67Database(&connection); | 2113 SetUpVersion67Database(&connection); |
2088 break; | 2114 break; |
2089 case 68: | 2115 case 68: |
2090 SetUpVersion68Database(&connection); | 2116 SetUpVersion68Database(&connection); |
2091 break; | 2117 break; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2452 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | 2478 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); |
2453 EXPECT_EQ(24U, guid1.size()); | 2479 EXPECT_EQ(24U, guid1.size()); |
2454 EXPECT_EQ(24U, guid2.size()); | 2480 EXPECT_EQ(24U, guid2.size()); |
2455 // In theory this test can fail, but it won't before the universe | 2481 // In theory this test can fail, but it won't before the universe |
2456 // dies of heat death. | 2482 // dies of heat death. |
2457 EXPECT_NE(guid1, guid2); | 2483 EXPECT_NE(guid1, guid2); |
2458 } | 2484 } |
2459 | 2485 |
2460 } // namespace syncable | 2486 } // namespace syncable |
2461 } // namespace syncer | 2487 } // namespace syncer |
OLD | NEW |