| 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 <string> | 5 #include <string> | 
| 6 | 6 | 
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" | 
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" | 
| 9 #include "base/guid.h" | 9 #include "base/guid.h" | 
| 10 #include "base/macros.h" | 10 #include "base/macros.h" | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 123   //   > .output version_nn.sql | 123   //   > .output version_nn.sql | 
| 124   //   > .dump | 124   //   > .dump | 
| 125   void LoadDatabase(const base::FilePath::StringType& file); | 125   void LoadDatabase(const base::FilePath::StringType& file); | 
| 126 | 126 | 
| 127  private: | 127  private: | 
| 128   base::ScopedTempDir temp_dir_; | 128   base::ScopedTempDir temp_dir_; | 
| 129 | 129 | 
| 130   DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); | 130   DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); | 
| 131 }; | 131 }; | 
| 132 | 132 | 
| 133 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 69; | 133 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 70; | 
| 134 | 134 | 
| 135 void WebDatabaseMigrationTest::LoadDatabase( | 135 void WebDatabaseMigrationTest::LoadDatabase( | 
| 136     const base::FilePath::StringType& file) { | 136     const base::FilePath::StringType& file) { | 
| 137   std::string contents; | 137   std::string contents; | 
| 138   ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); | 138   ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); | 
| 139 | 139 | 
| 140   sql::Connection connection; | 140   sql::Connection connection; | 
| 141   ASSERT_TRUE(connection.Open(GetDatabasePath())); | 141   ASSERT_TRUE(connection.Open(GetDatabasePath())); | 
| 142   ASSERT_TRUE(connection.Execute(contents.data())); | 142   ASSERT_TRUE(connection.Execute(contents.data())); | 
| 143 } | 143 } | 
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1127     ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1127     ASSERT_TRUE(connection.Open(GetDatabasePath())); | 
| 1128     ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1128     ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 
| 1129 | 1129 | 
| 1130     // Check version. | 1130     // Check version. | 
| 1131     EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1131     EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 
| 1132 | 1132 | 
| 1133     EXPECT_TRUE( | 1133     EXPECT_TRUE( | 
| 1134         connection.DoesColumnExist("keywords", "last_visited")); | 1134         connection.DoesColumnExist("keywords", "last_visited")); | 
| 1135   } | 1135   } | 
| 1136 } | 1136 } | 
|  | 1137 | 
|  | 1138 // Tests addition of sync metadata and model type state tables. | 
|  | 1139 TEST_F(WebDatabaseMigrationTest, MigrateVersion69ToCurrent) { | 
|  | 1140   ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_69.sql"))); | 
|  | 1141 | 
|  | 1142   // Verify pre-conditions. | 
|  | 1143   { | 
|  | 1144     sql::Connection connection; | 
|  | 1145     ASSERT_TRUE(connection.Open(GetDatabasePath())); | 
|  | 1146     ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 
|  | 1147 | 
|  | 1148     sql::MetaTable meta_table; | 
|  | 1149     ASSERT_TRUE(meta_table.Init(&connection, 69, 69)); | 
|  | 1150 | 
|  | 1151     EXPECT_FALSE(connection.DoesTableExist("autofill_sync_metadata")); | 
|  | 1152     EXPECT_FALSE(connection.DoesTableExist("autofill_model_type_state")); | 
|  | 1153   } | 
|  | 1154 | 
|  | 1155   DoMigration(); | 
|  | 1156 | 
|  | 1157   // Verify post-conditions. | 
|  | 1158   { | 
|  | 1159     sql::Connection connection; | 
|  | 1160     ASSERT_TRUE(connection.Open(GetDatabasePath())); | 
|  | 1161     ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 
|  | 1162 | 
|  | 1163     EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 
|  | 1164 | 
|  | 1165     EXPECT_TRUE(connection.DoesTableExist("autofill_sync_metadata")); | 
|  | 1166     EXPECT_TRUE(connection.DoesTableExist("autofill_model_type_state")); | 
|  | 1167   } | 
|  | 1168 } | 
| OLD | NEW | 
|---|