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

Side by Side Diff: components/webdata/common/web_database_migration_unittest.cc

Issue 310463005: Fill in more name fields with requestAutocomplete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: todo Created 6 years, 6 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/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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // > .output version_nn.sql 249 // > .output version_nn.sql
250 // > .dump 250 // > .dump
251 void LoadDatabase(const base::FilePath::StringType& file); 251 void LoadDatabase(const base::FilePath::StringType& file);
252 252
253 private: 253 private:
254 base::ScopedTempDir temp_dir_; 254 base::ScopedTempDir temp_dir_;
255 255
256 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 256 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
257 }; 257 };
258 258
259 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 56; 259 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 57;
260 260
261 void WebDatabaseMigrationTest::LoadDatabase( 261 void WebDatabaseMigrationTest::LoadDatabase(
262 const base::FilePath::StringType& file) { 262 const base::FilePath::StringType& file) {
263 std::string contents; 263 std::string contents;
264 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); 264 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents));
265 265
266 sql::Connection connection; 266 sql::Connection connection;
267 ASSERT_TRUE(connection.Open(GetDatabasePath())); 267 ASSERT_TRUE(connection.Open(GetDatabasePath()));
268 ASSERT_TRUE(connection.Execute(contents.data())); 268 ASSERT_TRUE(connection.Execute(contents.data()));
269 } 269 }
(...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7)); 2663 EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
2664 EXPECT_EQ(ASCIIToUTF16("US"), s_profiles.ColumnString16(8)); 2664 EXPECT_EQ(ASCIIToUTF16("US"), s_profiles.ColumnString16(8));
2665 EXPECT_EQ(1395948829, s_profiles.ColumnInt(9)); 2665 EXPECT_EQ(1395948829, s_profiles.ColumnInt(9));
2666 EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(10)); 2666 EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(10));
2667 EXPECT_EQ(std::string(), s_profiles.ColumnString(11)); 2667 EXPECT_EQ(std::string(), s_profiles.ColumnString(11));
2668 2668
2669 // No more entries expected. 2669 // No more entries expected.
2670 ASSERT_FALSE(s_profiles.Step()); 2670 ASSERT_FALSE(s_profiles.Step());
2671 } 2671 }
2672 } 2672 }
2673
2674 // Tests that migrating from version 56 to version 57 adds the full_name
2675 // column to autofill_profile_names table.
2676 TEST_F(WebDatabaseMigrationTest, MigrateVersion56ToCurrent) {
2677 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_56.sql")));
2678
2679 // Verify pre-conditions. These are expectations for version 56 of the
2680 // database.
2681 {
2682 sql::Connection connection;
2683 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2684 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2685
2686 EXPECT_FALSE(
2687 connection.DoesColumnExist("autofill_profile_names", "full_name"));
Ilya Sherman 2014/06/12 23:25:25 I'd prefer that you also verify that the table sta
Evan Stade 2014/06/14 01:17:24 Done.
2688 }
2689
2690 DoMigration();
2691
2692 // Verify post-conditions. These are expectations for current version of the
2693 // database.
2694 {
2695 sql::Connection connection;
2696 ASSERT_TRUE(connection.Open(GetDatabasePath()));
2697 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
2698
2699 // Check version.
2700 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
2701
2702 // The language_code column should have been added to autofill_profiles
2703 // table.
Ilya Sherman 2014/06/12 23:25:25 nit: Please update this comment.
Evan Stade 2014/06/14 01:17:23 Done.
2704 EXPECT_TRUE(
2705 connection.DoesColumnExist("autofill_profile_names", "full_name"));
2706
2707 // Data should have been preserved. Full name should have been set to the
2708 // empty string.
2709 sql::Statement s_names(
2710 connection.GetUniqueStatement(
2711 "SELECT guid, first_name, middle_name, last_name, full_name "
2712 "FROM autofill_profile_names"));
2713
2714 ASSERT_TRUE(s_names.Step());
2715 EXPECT_EQ("B41FE6E0-B13E-2A2A-BF0B-29FCE2C3ADBD", s_names.ColumnString(0));
2716 EXPECT_EQ(ASCIIToUTF16("Jon"), s_names.ColumnString16(1));
2717 EXPECT_EQ(ASCIIToUTF16(""), s_names.ColumnString16(2));
2718 EXPECT_EQ(ASCIIToUTF16("Smith"), s_names.ColumnString16(3));
2719 EXPECT_EQ(ASCIIToUTF16(""), s_names.ColumnString16(4));
Ilya Sherman 2014/06/12 23:25:25 nit: "base::string16()" is generally preferred ove
Evan Stade 2014/06/14 01:17:23 Done.
2720
2721 // No more entries expected.
2722 ASSERT_FALSE(s_names.Step());
2723 }
2724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698