Commit ecbc1581 authored by Parastoo Geranmayeh's avatar Parastoo Geranmayeh Committed by Commit Bot

[AF] Save is_client_validity_states_updated

of the Autofill profile in the database table.

Add the column in the table, migrate to a new version.
Save the flag, and retrieve it when needed.

Change-Id: I398c9efa73673b68916192ff2db13aa6d1473b2f
Reviewed-on: https://chromium-review.googlesource.com/c/1258057Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarCait Phillips <caitkp@chromium.org>
Commit-Queue: Parastoo Geranmayeh <parastoog@google.com>
Cr-Commit-Position: refs/heads/master@{#596778}
parent ec5a9b62
...@@ -95,15 +95,12 @@ void BindAutofillProfileToStatement(const AutofillProfile& profile, ...@@ -95,15 +95,12 @@ void BindAutofillProfileToStatement(const AutofillProfile& profile,
s->BindString(index++, profile.origin()); s->BindString(index++, profile.origin());
s->BindString(index++, profile.language_code()); s->BindString(index++, profile.language_code());
s->BindInt64(index++, profile.GetClientValidityBitfieldValue()); s->BindInt64(index++, profile.GetClientValidityBitfieldValue());
s->BindBool(index++, profile.is_client_validity_states_updated());
} }
std::unique_ptr<AutofillProfile> AutofillProfileFromStatement( void AddAutofillProfileDetailsFromStatement(const sql::Statement& s,
const sql::Statement& s) { AutofillProfile* profile) {
std::unique_ptr<AutofillProfile> profile(new AutofillProfile); int index = 1; // 0 is for the guid.
int index = 0;
profile->set_guid(s.ColumnString(index++));
DCHECK(base::IsValidGUID(profile->guid()));
profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(index++)); profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(index++));
profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++)); profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++));
profile->SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, profile->SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
...@@ -119,8 +116,7 @@ std::unique_ptr<AutofillProfile> AutofillProfileFromStatement( ...@@ -119,8 +116,7 @@ std::unique_ptr<AutofillProfile> AutofillProfileFromStatement(
profile->set_origin(s.ColumnString(index++)); profile->set_origin(s.ColumnString(index++));
profile->set_language_code(s.ColumnString(index++)); profile->set_language_code(s.ColumnString(index++));
profile->SetClientValidityFromBitfieldValue(s.ColumnInt64(index++)); profile->SetClientValidityFromBitfieldValue(s.ColumnInt64(index++));
profile->set_is_client_validity_states_updated(s.ColumnBool(index++));
return profile;
} }
void BindEncryptedCardToColumn(sql::Statement* s, void BindEncryptedCardToColumn(sql::Statement* s,
...@@ -483,6 +479,9 @@ bool AutofillTable::MigrateToVersion(int version, ...@@ -483,6 +479,9 @@ bool AutofillTable::MigrateToVersion(int version,
case 78: case 78:
*update_compatible_version = true; *update_compatible_version = true;
return MigrateToVersion78AddModelTypeColumns(); return MigrateToVersion78AddModelTypeColumns();
case 80:
*update_compatible_version = true;
return MigrateToVersion80AddIsClientValidityStatesUpdatedColumn();
} }
return true; return true;
} }
...@@ -806,8 +805,9 @@ bool AutofillTable::AddAutofillProfile(const AutofillProfile& profile) { ...@@ -806,8 +805,9 @@ bool AutofillTable::AddAutofillProfile(const AutofillProfile& profile) {
"INSERT INTO autofill_profiles" "INSERT INTO autofill_profiles"
"(guid, company_name, street_address, dependent_locality, city, state," "(guid, company_name, street_address, dependent_locality, city, state,"
" zipcode, sorting_code, country_code, use_count, use_date, " " zipcode, sorting_code, country_code, use_count, use_date, "
" date_modified, origin, language_code, validity_bitfield)" " date_modified, origin, language_code, validity_bitfield, "
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")); " is_client_validity_states_updated)"
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"));
BindAutofillProfileToStatement(profile, AutofillClock::Now(), &s); BindAutofillProfileToStatement(profile, AutofillClock::Now(), &s);
if (!s.Run()) if (!s.Run())
...@@ -836,14 +836,15 @@ bool AutofillTable::UpdateAutofillProfile(const AutofillProfile& profile) { ...@@ -836,14 +836,15 @@ bool AutofillTable::UpdateAutofillProfile(const AutofillProfile& profile) {
"SET guid=?, company_name=?, street_address=?, dependent_locality=?, " "SET guid=?, company_name=?, street_address=?, dependent_locality=?, "
" city=?, state=?, zipcode=?, sorting_code=?, country_code=?, " " city=?, state=?, zipcode=?, sorting_code=?, country_code=?, "
" use_count=?, use_date=?, date_modified=?, origin=?, " " use_count=?, use_date=?, date_modified=?, origin=?, "
" language_code=?, validity_bitfield=? " " language_code=?, validity_bitfield=?, "
" is_client_validity_states_updated=?"
"WHERE guid=?")); "WHERE guid=?"));
BindAutofillProfileToStatement(profile, BindAutofillProfileToStatement(profile,
update_modification_date update_modification_date
? AutofillClock::Now() ? AutofillClock::Now()
: old_profile->modification_date(), : old_profile->modification_date(),
&s); &s);
s.BindString(15, profile.guid()); s.BindString(16, profile.guid());
bool result = s.Run(); bool result = s.Run();
DCHECK_GT(db_->GetLastChangeCount(), 0); DCHECK_GT(db_->GetLastChangeCount(), 0);
...@@ -886,27 +887,33 @@ std::unique_ptr<AutofillProfile> AutofillTable::GetAutofillProfile( ...@@ -886,27 +887,33 @@ std::unique_ptr<AutofillProfile> AutofillTable::GetAutofillProfile(
sql::Statement s(db_->GetUniqueStatement( sql::Statement s(db_->GetUniqueStatement(
"SELECT guid, company_name, street_address, dependent_locality, city," "SELECT guid, company_name, street_address, dependent_locality, city,"
" state, zipcode, sorting_code, country_code, use_count, use_date," " state, zipcode, sorting_code, country_code, use_count, use_date,"
" date_modified, origin, language_code, validity_bitfield " " date_modified, origin, language_code, validity_bitfield,"
" is_client_validity_states_updated "
"FROM autofill_profiles " "FROM autofill_profiles "
"WHERE guid=?")); "WHERE guid=?"));
s.BindString(0, guid); s.BindString(0, guid);
std::unique_ptr<AutofillProfile> p;
if (!s.Step()) if (!s.Step())
return p; return nullptr;
p = AutofillProfileFromStatement(s); std::unique_ptr<AutofillProfile> profile(new AutofillProfile);
profile->set_guid(s.ColumnString(0));
DCHECK(base::IsValidGUID(profile->guid()));
// Get associated name info. // Get associated name info using guid.
AddAutofillProfileNamesToProfile(db_, p.get()); AddAutofillProfileNamesToProfile(db_, profile.get());
// Get associated email info. // Get associated email info using guid.
AddAutofillProfileEmailsToProfile(db_, p.get()); AddAutofillProfileEmailsToProfile(db_, profile.get());
// Get associated phone info. // Get associated phone info using guid.
AddAutofillProfilePhonesToProfile(db_, p.get()); AddAutofillProfilePhonesToProfile(db_, profile.get());
return p; // The details should be added after the other info to make sure they don't
// change when we change the names/emails/phones.
AddAutofillProfileDetailsFromStatement(s, profile.get());
return profile;
} }
bool AutofillTable::GetAutofillProfiles( bool AutofillTable::GetAutofillProfiles(
...@@ -2458,6 +2465,15 @@ bool AutofillTable::MigrateToVersion78AddModelTypeColumns() { ...@@ -2458,6 +2465,15 @@ bool AutofillTable::MigrateToVersion78AddModelTypeColumns() {
transaction.Commit(); transaction.Commit();
} }
bool AutofillTable::MigrateToVersion80AddIsClientValidityStatesUpdatedColumn() {
// Add the client validity states updated flag column to the autofill_profiles
// table.
return db_->Execute(
"ALTER TABLE autofill_profiles ADD COLUMN "
"is_client_validity_states_updated BOOL NOT "
"NULL DEFAULT FALSE");
}
bool AutofillTable::AddFormFieldValuesTime( bool AutofillTable::AddFormFieldValuesTime(
const std::vector<FormFieldData>& elements, const std::vector<FormFieldData>& elements,
std::vector<AutofillChange>* changes, std::vector<AutofillChange>* changes,
...@@ -2740,7 +2756,9 @@ bool AutofillTable::InitProfilesTable() { ...@@ -2740,7 +2756,9 @@ bool AutofillTable::InitProfilesTable() {
"language_code VARCHAR, " "language_code VARCHAR, "
"use_count INTEGER NOT NULL DEFAULT 0, " "use_count INTEGER NOT NULL DEFAULT 0, "
"use_date INTEGER NOT NULL DEFAULT 0, " "use_date INTEGER NOT NULL DEFAULT 0, "
"validity_bitfield UNSIGNED NOT NULL DEFAULT 0) ")) { "validity_bitfield UNSIGNED NOT NULL DEFAULT 0, "
"is_client_validity_states_updated BOOL NOT NULL DEFAULT "
"FALSE) ")) {
NOTREACHED(); NOTREACHED();
return false; return false;
} }
......
...@@ -92,7 +92,10 @@ struct PaymentsCustomerData; ...@@ -92,7 +92,10 @@ struct PaymentsCustomerData;
// validity_bitfield A bitfield representing the validity state of different // validity_bitfield A bitfield representing the validity state of different
// fields in the profile. // fields in the profile.
// Added in version 75. // Added in version 75.
// // is_client_validity_states_updated
// A flag indicating whether the validity states of
// different fields according to the client validity api is
// updated or not. Added in version 80.
// autofill_profile_names // autofill_profile_names
// This table contains the multi-valued name fields // This table contains the multi-valued name fields
// associated with a profile. // associated with a profile.
...@@ -518,7 +521,7 @@ class AutofillTable : public WebDatabaseTable, ...@@ -518,7 +521,7 @@ class AutofillTable : public WebDatabaseTable,
bool MigrateToVersion74AddServerCardTypeColumn(); bool MigrateToVersion74AddServerCardTypeColumn();
bool MigrateToVersion75AddProfileValidityBitfieldColumn(); bool MigrateToVersion75AddProfileValidityBitfieldColumn();
bool MigrateToVersion78AddModelTypeColumns(); bool MigrateToVersion78AddModelTypeColumns();
bool MigrateToVersion80AddIsClientValidityStatesUpdatedColumn();
// Max data length saved in the table, AKA the maximum length allowed for // Max data length saved in the table, AKA the maximum length allowed for
// form data. // form data.
// Copied to components/autofill/ios/browser/resources/autofill_controller.js. // Copied to components/autofill/ios/browser/resources/autofill_controller.js.
......
...@@ -795,6 +795,7 @@ TEST_F(AutofillTableTest, AutofillProfile) { ...@@ -795,6 +795,7 @@ TEST_F(AutofillTableTest, AutofillProfile) {
home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567"));
home_profile.set_language_code("en"); home_profile.set_language_code("en");
home_profile.SetClientValidityFromBitfieldValue(6); home_profile.SetClientValidityFromBitfieldValue(6);
home_profile.set_is_client_validity_states_updated(true);
Time pre_creation_time = Time::Now(); Time pre_creation_time = Time::Now();
EXPECT_TRUE(table_->AddAutofillProfile(home_profile)); EXPECT_TRUE(table_->AddAutofillProfile(home_profile));
...@@ -879,6 +880,8 @@ TEST_F(AutofillTableTest, AutofillProfile) { ...@@ -879,6 +880,8 @@ TEST_F(AutofillTableTest, AutofillProfile) {
billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER,
ASCIIToUTF16("18181230000")); ASCIIToUTF16("18181230000"));
billing_profile.SetClientValidityFromBitfieldValue(54); billing_profile.SetClientValidityFromBitfieldValue(54);
billing_profile.set_is_client_validity_states_updated(true);
Time pre_modification_time_2 = Time::Now(); Time pre_modification_time_2 = Time::Now();
EXPECT_TRUE(table_->UpdateAutofillProfile(billing_profile)); EXPECT_TRUE(table_->UpdateAutofillProfile(billing_profile));
Time post_modification_time_2 = Time::Now(); Time post_modification_time_2 = Time::Now();
...@@ -1855,6 +1858,40 @@ TEST_F(AutofillTableTest, AutofillProfileValidityBitfield) { ...@@ -1855,6 +1858,40 @@ TEST_F(AutofillTableTest, AutofillProfileValidityBitfield) {
db_profile->GetClientValidityBitfieldValue()); db_profile->GetClientValidityBitfieldValue());
} }
TEST_F(AutofillTableTest, AutofillProfileIsClientValidityStatesUpdatedFlag) {
AutofillProfile profile;
profile.set_origin(std::string());
profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith"));
profile.set_is_client_validity_states_updated(true);
// Add the profile to the table.
EXPECT_TRUE(table_->AddAutofillProfile(profile));
// Get the profile from the table and make sure the validity was set.
std::unique_ptr<AutofillProfile> db_profile =
table_->GetAutofillProfile(profile.guid());
ASSERT_TRUE(db_profile);
EXPECT_TRUE(db_profile->is_client_validity_states_updated());
// Test if turning off the validity updated flag works.
profile.set_is_client_validity_states_updated(false);
// Update the profile in the table.
EXPECT_TRUE(table_->UpdateAutofillProfile(profile));
// Get the profile from the table and make sure the validity was updated.
db_profile = table_->GetAutofillProfile(profile.guid());
ASSERT_TRUE(db_profile);
EXPECT_FALSE(db_profile->is_client_validity_states_updated());
// Test if turning on the validity updated flag works.
profile.set_is_client_validity_states_updated(true);
// Update the profile in the table.
EXPECT_TRUE(table_->UpdateAutofillProfile(profile));
// Get the profile from the table and make sure the validity was updated.
db_profile = table_->GetAutofillProfile(profile.guid());
ASSERT_TRUE(db_profile);
EXPECT_TRUE(db_profile->is_client_validity_states_updated());
}
TEST_F(AutofillTableTest, SetGetServerCards) { TEST_F(AutofillTableTest, SetGetServerCards) {
std::vector<CreditCard> inputs; std::vector<CreditCard> inputs;
inputs.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "a123")); inputs.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "a123"));
......
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR);
INSERT INTO "meta" VALUES('mmap_status','-1');
INSERT INTO "meta" VALUES('version','78');
INSERT INTO "meta" VALUES('last_compatible_version','78');
CREATE TABLE token_service (service VARCHAR PRIMARY KEY NOT NULL,encrypted_token BLOB);
CREATE TABLE keywords (id INTEGER PRIMARY KEY,short_name VARCHAR NOT NULL,keyword VARCHAR NOT NULL,favicon_url VARCHAR NOT NULL,url VARCHAR NOT NULL,safe_for_autoreplace INTEGER,originating_url VARCHAR,date_created INTEGER DEFAULT 0,usage_count INTEGER DEFAULT 0,input_encodings VARCHAR,suggest_url VARCHAR,prepopulate_id INTEGER DEFAULT 0,created_by_policy INTEGER DEFAULT 0,last_modified INTEGER DEFAULT 0,sync_guid VARCHAR,alternate_urls VARCHAR,image_url VARCHAR,search_url_post_params VARCHAR,suggest_url_post_params VARCHAR,image_url_post_params VARCHAR,new_tab_url VARCHAR,last_visited INTEGER DEFAULT 0);
CREATE TABLE autofill (name VARCHAR, value VARCHAR, value_lower VARCHAR, date_created INTEGER DEFAULT 0, date_last_used INTEGER DEFAULT 0, count INTEGER DEFAULT 1, PRIMARY KEY (name, value));
CREATE TABLE credit_cards ( guid VARCHAR PRIMARY KEY, name_on_card VARCHAR, expiration_month INTEGER, expiration_year INTEGER, card_number_encrypted BLOB, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '', use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, billing_address_id VARCHAR);
CREATE TABLE autofill_profiles ( guid VARCHAR PRIMARY KEY, company_name VARCHAR, street_address VARCHAR, dependent_locality VARCHAR, city VARCHAR, state VARCHAR, zipcode VARCHAR, sorting_code VARCHAR, country_code VARCHAR, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '', language_code VARCHAR, use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, validity_bitfield UNSIGNED NOT NULL DEFAULT 0);
INSERT INTO "autofill_profiles" VALUES('00000000-0000-0000-0000-000000000001','Google Inc','340 Main St','','Los Angeles','CA','90291','','US',1395948829,'Chrome settings','en',12,12,1365);
CREATE TABLE autofill_profile_names ( guid VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, full_name VARCHAR);
CREATE TABLE autofill_profile_emails ( guid VARCHAR, email VARCHAR);
CREATE TABLE autofill_profile_phones ( guid VARCHAR, number VARCHAR);
CREATE TABLE autofill_profiles_trash ( guid VARCHAR);
CREATE TABLE masked_credit_cards (id VARCHAR,status VARCHAR,name_on_card VARCHAR,network VARCHAR,last_four VARCHAR,exp_month INTEGER DEFAULT 0,exp_year INTEGER DEFAULT 0, bank_name VARCHAR, type INTEGER DEFAULT 0);
CREATE TABLE unmasked_credit_cards (id VARCHAR,card_number_encrypted VARCHAR, use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, unmask_date INTEGER NOT NULL DEFAULT 0);
CREATE TABLE server_card_metadata (id VARCHAR NOT NULL,use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, billing_address_id VARCHAR);
CREATE TABLE server_addresses (id VARCHAR,company_name VARCHAR,street_address VARCHAR,address_1 VARCHAR,address_2 VARCHAR,address_3 VARCHAR,address_4 VARCHAR,postal_code VARCHAR,sorting_code VARCHAR,country_code VARCHAR,language_code VARCHAR, recipient_name VARCHAR, phone_number VARCHAR);
CREATE TABLE server_address_metadata (id VARCHAR NOT NULL,use_count INTEGER NOT NULL DEFAULT 0, use_date INTEGER NOT NULL DEFAULT 0, has_converted BOOL NOT NULL DEFAULT FALSE);
CREATE TABLE autofill_sync_metadata (model_type INTEGER NOT NULL, storage_key VARCHAR NOT NULL, value BLOB, PRIMARY KEY (model_type, storage_key));
INSERT INTO autofill_sync_metadata VALUES (0, 'storage_key1', 'blob1'), (0, 'storage_key2', 'blob2');
CREATE TABLE autofill_model_type_state (model_type INTEGER NOT NULL PRIMARY KEY, value BLOB);
INSERT INTO autofill_model_type_state VALUES (1, 'state');
CREATE INDEX autofill_name ON autofill (name);
CREATE INDEX autofill_name_value_lower ON autofill (name, value_lower);
CREATE TABLE ie7_logins (url_hash VARCHAR NOT NULL, UNIQUE(url_hash));
CREATE INDEX ie7_logins_hash ON ie7_logins (url_hash);
CREATE TABLE logins (url_hash VARCHAR NOT NULL, UNIQUE(url_hash));
COMMIT;
...@@ -66,6 +66,7 @@ bundle_data("unit_tests_bundle_data") { ...@@ -66,6 +66,7 @@ bundle_data("unit_tests_bundle_data") {
"//components/test/data/web_database/version_76.sql", "//components/test/data/web_database/version_76.sql",
"//components/test/data/web_database/version_77.sql", "//components/test/data/web_database/version_77.sql",
"//components/test/data/web_database/version_78.sql", "//components/test/data/web_database/version_78.sql",
"//components/test/data/web_database/version_79.sql",
] ]
outputs = [ outputs = [
"{{bundle_resources_dir}}/" + "{{bundle_resources_dir}}/" +
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// corresponding changes must happen in the unit tests, and new migration test // corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
// static // static
const int WebDatabase::kCurrentVersionNumber = 79; const int WebDatabase::kCurrentVersionNumber = 80;
const int WebDatabase::kDeprecatedVersionNumber = 51; const int WebDatabase::kDeprecatedVersionNumber = 51;
......
...@@ -126,7 +126,7 @@ class WebDatabaseMigrationTest : public testing::Test { ...@@ -126,7 +126,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
}; };
const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 79; const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 80;
void WebDatabaseMigrationTest::LoadDatabase( void WebDatabaseMigrationTest::LoadDatabase(
const base::FilePath::StringType& file) { const base::FilePath::StringType& file) {
...@@ -1629,3 +1629,61 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion78ToCurrent) { ...@@ -1629,3 +1629,61 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion78ToCurrent) {
ASSERT_FALSE(connection.DoesTableExist("logins")); ASSERT_FALSE(connection.DoesTableExist("logins"));
} }
} }
// Tests adding "is_client_validity_states_updated" column for the
// "autofill_profiles" table.
TEST_F(WebDatabaseMigrationTest, MigrateVersion79ToCurrent) {
ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_79.sql")));
// Verify pre-conditions.
{
sql::Database connection;
ASSERT_TRUE(connection.Open(GetDatabasePath()));
ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
sql::MetaTable meta_table;
ASSERT_TRUE(meta_table.Init(&connection, 79, 79));
EXPECT_FALSE(connection.DoesColumnExist(
"autofill_profiles", "is_client_validity_states_updated"));
}
DoMigration();
// Verify post-conditions.
{
sql::Database connection;
ASSERT_TRUE(connection.Open(GetDatabasePath()));
ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
// Check version.
EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
EXPECT_TRUE(connection.DoesColumnExist(
"autofill_profiles", "is_client_validity_states_updated"));
// Data should have been preserved. Validity
// is_client_validity_states_updated should have been set to false.
sql::Statement s_profiles(connection.GetUniqueStatement(
"SELECT guid, company_name, street_address, dependent_locality,"
" city, state, zipcode, sorting_code, country_code, date_modified,"
" origin, language_code, validity_bitfield, "
" is_client_validity_states_updated "
" FROM autofill_profiles"));
ASSERT_TRUE(s_profiles.Step());
EXPECT_EQ("00000000-0000-0000-0000-000000000001",
s_profiles.ColumnString(0));
EXPECT_EQ(ASCIIToUTF16("Google Inc"), s_profiles.ColumnString16(1));
EXPECT_EQ(ASCIIToUTF16("340 Main St"), s_profiles.ColumnString16(2));
EXPECT_EQ(base::string16(), s_profiles.ColumnString16(3));
EXPECT_EQ(ASCIIToUTF16("Los Angeles"), s_profiles.ColumnString16(4));
EXPECT_EQ(ASCIIToUTF16("CA"), s_profiles.ColumnString16(5));
EXPECT_EQ(ASCIIToUTF16("90291"), s_profiles.ColumnString16(6));
EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
EXPECT_EQ(ASCIIToUTF16("US"), s_profiles.ColumnString16(8));
EXPECT_EQ(1395948829, s_profiles.ColumnInt(9));
EXPECT_EQ(ASCIIToUTF16(autofill::kSettingsOrigin),
s_profiles.ColumnString16(10));
EXPECT_EQ("en", s_profiles.ColumnString(11));
EXPECT_EQ(1365, s_profiles.ColumnInt(12));
// The new is_client_validity_states_updated should have the default value
// of FALSE.
EXPECT_FALSE(s_profiles.ColumnBool(13));
// No more entries expected.
ASSERT_FALSE(s_profiles.Step());
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment