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

Side by Side Diff: trunk/src/chrome/browser/chromeos/contacts/contact_database_unittest.cc

Issue 14824006: Revert 198820 "Move FileEnumerator to its own file, do some refa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 "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"
11 #include "base/files/file_enumerator.h"
12 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
14 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
16 #include "base/message_loop.h" 15 #include "base/message_loop.h"
17 #include "chrome/browser/chromeos/contacts/contact.pb.h" 16 #include "chrome/browser/chromeos/contacts/contact.pb.h"
18 #include "chrome/browser/chromeos/contacts/contact_test_util.h" 17 #include "chrome/browser/chromeos/contacts/contact_test_util.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 metadata_to_save.Pass(), 307 metadata_to_save.Pass(),
309 true); 308 true);
310 LoadContacts(&loaded_contacts, &loaded_metadata); 309 LoadContacts(&loaded_contacts, &loaded_metadata);
311 EXPECT_TRUE(loaded_contacts->empty()); 310 EXPECT_TRUE(loaded_contacts->empty());
312 } 311 }
313 312
314 // Test that we create a new database when we encounter a corrupted one. 313 // Test that we create a new database when we encounter a corrupted one.
315 TEST_F(ContactDatabaseTest, DeleteWhenCorrupt) { 314 TEST_F(ContactDatabaseTest, DeleteWhenCorrupt) {
316 DestroyDatabase(); 315 DestroyDatabase();
317 // Overwrite all of the files in the database with a space character. 316 // Overwrite all of the files in the database with a space character.
318 base::FileEnumerator enumerator( 317 file_util::FileEnumerator enumerator(
319 database_path(), false, base::FileEnumerator::FILES); 318 database_path(), false, file_util::FileEnumerator::FILES);
320 for (base::FilePath path = enumerator.Next(); !path.empty(); 319 for (base::FilePath path = enumerator.Next(); !path.empty();
321 path = enumerator.Next()) { 320 path = enumerator.Next()) {
322 file_util::WriteFile(path, " ", 1); 321 file_util::WriteFile(path, " ", 1);
323 } 322 }
324 CreateDatabase(); 323 CreateDatabase();
325 324
326 // Make sure that the resulting database is usable. 325 // Make sure that the resulting database is usable.
327 scoped_ptr<Contact> contact(new Contact); 326 scoped_ptr<Contact> contact(new Contact);
328 InitContact("1", "1", false, contact.get()); 327 InitContact("1", "1", false, contact.get());
329 scoped_ptr<ContactPointers> contacts_to_save(new ContactPointers); 328 scoped_ptr<ContactPointers> contacts_to_save(new ContactPointers);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 contact_ids_to_delete.Pass(), 407 contact_ids_to_delete.Pass(),
409 metadata_to_save.Pass(), 408 metadata_to_save.Pass(),
410 false); 409 false);
411 LoadContacts(&loaded_contacts, &loaded_metadata); 410 LoadContacts(&loaded_contacts, &loaded_metadata);
412 EXPECT_EQ(VarContactsToString(1, contact3.get()), 411 EXPECT_EQ(VarContactsToString(1, contact3.get()),
413 ContactsToString(*loaded_contacts)); 412 ContactsToString(*loaded_contacts));
414 } 413 }
415 414
416 } // namespace test 415 } // namespace test
417 } // namespace contacts 416 } // namespace contacts
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/chromeos/camera_detector.cc ('k') | trunk/src/chrome/browser/chromeos/drive/file_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698