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 "chrome/browser/chromeos/contacts/contact_database.h" | 5 #include "chrome/browser/chromeos/contacts/contact_database.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 // Test that we create a new database when we encounter a corrupted one. | 314 // Test that we create a new database when we encounter a corrupted one. |
315 TEST_F(ContactDatabaseTest, DeleteWhenCorrupt) { | 315 TEST_F(ContactDatabaseTest, DeleteWhenCorrupt) { |
316 DestroyDatabase(); | 316 DestroyDatabase(); |
317 // Overwrite all of the files in the database with a space character. | 317 // Overwrite all of the files in the database with a space character. |
318 base::FileEnumerator enumerator( | 318 base::FileEnumerator enumerator( |
319 database_path(), false, base::FileEnumerator::FILES); | 319 database_path(), false, base::FileEnumerator::FILES); |
320 for (base::FilePath path = enumerator.Next(); !path.empty(); | 320 for (base::FilePath path = enumerator.Next(); !path.empty(); |
321 path = enumerator.Next()) { | 321 path = enumerator.Next()) { |
322 file_util::WriteFile(path, " ", 1); | 322 base::WriteFile(path, " ", 1); |
323 } | 323 } |
324 CreateDatabase(); | 324 CreateDatabase(); |
325 | 325 |
326 // Make sure that the resulting database is usable. | 326 // Make sure that the resulting database is usable. |
327 scoped_ptr<Contact> contact(new Contact); | 327 scoped_ptr<Contact> contact(new Contact); |
328 InitContact("1", "1", false, contact.get()); | 328 InitContact("1", "1", false, contact.get()); |
329 scoped_ptr<ContactPointers> contacts_to_save(new ContactPointers); | 329 scoped_ptr<ContactPointers> contacts_to_save(new ContactPointers); |
330 contacts_to_save->push_back(contact.get()); | 330 contacts_to_save->push_back(contact.get()); |
331 scoped_ptr<ContactDatabaseInterface::ContactIds> contact_ids_to_delete( | 331 scoped_ptr<ContactDatabaseInterface::ContactIds> contact_ids_to_delete( |
332 new ContactDatabaseInterface::ContactIds); | 332 new ContactDatabaseInterface::ContactIds); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 contact_ids_to_delete.Pass(), | 408 contact_ids_to_delete.Pass(), |
409 metadata_to_save.Pass(), | 409 metadata_to_save.Pass(), |
410 false); | 410 false); |
411 LoadContacts(&loaded_contacts, &loaded_metadata); | 411 LoadContacts(&loaded_contacts, &loaded_metadata); |
412 EXPECT_EQ(VarContactsToString(1, contact3.get()), | 412 EXPECT_EQ(VarContactsToString(1, contact3.get()), |
413 ContactsToString(*loaded_contacts)); | 413 ContactsToString(*loaded_contacts)); |
414 } | 414 } |
415 | 415 |
416 } // namespace test | 416 } // namespace test |
417 } // namespace contacts | 417 } // namespace contacts |
OLD | NEW |