Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/webdata/web_database_migration_unittest.cc

Issue 10696127: Force WebDatabase version to max(version, compatible version) before migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 2164
2165 // We were able to create the new tables, but unable to copy any data 2165 // We were able to create the new tables, but unable to copy any data
2166 // Given the initial bad state of the tables. 2166 // Given the initial bad state of the tables.
2167 ASSERT_FALSE(s2.Step()); 2167 ASSERT_FALSE(s2.Step());
2168 2168
2169 // Finally ensure the migration code cleaned up after itself. 2169 // Finally ensure the migration code cleaned up after itself.
2170 EXPECT_FALSE(connection.DoesTableExist("old_web_intents")); 2170 EXPECT_FALSE(connection.DoesTableExist("old_web_intents"));
2171 EXPECT_FALSE(connection.DoesTableExist("old_web_intents_defaults")); 2171 EXPECT_FALSE(connection.DoesTableExist("old_web_intents_defaults"));
2172 } 2172 }
2173 } 2173 }
2174
2175 // Check that current version is forced to compatible version before migration,
2176 // if the former is smaller.
2177 TEST_F(WebDatabaseMigrationTest, MigrateVersion45CompatibleToCurrent) {
2178 ASSERT_NO_FATAL_FAILURE(
2179 LoadDatabase(FILE_PATH_LITERAL("version_45_compatible.sql")));
2180
2181 // Verify pre-conditions. These are expectations for version 45 of the
2182 // database.
2183 {
2184 sql::Connection connection;
2185 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2186 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2187
2188 sql::MetaTable meta_table;
2189 // Database is actually version 45 but the version field states 40.
2190 ASSERT_TRUE(meta_table.Init(&connection, 40, 45));
2191 }
2192
2193 // Load the database via the WebDatabase class and migrate the database to
2194 // the current version.
2195 {
2196 WebDatabase db;
2197 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
2198 }
2199
2200 // Verify post-conditions. These are expectations for current version of the
2201 // database.
2202 {
2203 sql::Connection connection;
2204 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2205 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2206
2207 // Check version.
2208 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
2209 EXPECT_LE(45, VersionFromConnection(&connection));
2210 }
2211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698