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

Side by Side Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 7190001: [Sync] Split DirectoryChangeListener for thread-safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/task.h" 17 #include "base/task.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "base/tracked.h"
19 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/autofill/autofill_common_test.h" 21 #include "chrome/browser/autofill/autofill_common_test.h"
21 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 22 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
22 #include "chrome/browser/sync/engine/model_changing_syncer_command.h" 23 #include "chrome/browser/sync/engine/model_changing_syncer_command.h"
23 #include "chrome/browser/sync/engine/syncapi.h" 24 #include "chrome/browser/sync/engine/syncapi.h"
24 #include "chrome/browser/sync/glue/autofill_change_processor.h" 25 #include "chrome/browser/sync/glue/autofill_change_processor.h"
25 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" 26 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
26 #include "chrome/browser/sync/glue/autofill_model_associator.h" 27 #include "chrome/browser/sync/glue/autofill_model_associator.h"
27 #include "chrome/browser/sync/glue/autofill_profile_change_processor.h" 28 #include "chrome/browser/sync/glue/autofill_profile_change_processor.h"
28 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" 29 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 ProfileSyncServiceAutofillTest* test_; 485 ProfileSyncServiceAutofillTest* test_;
485 const std::vector<T>& entries_; 486 const std::vector<T>& entries_;
486 bool success_; 487 bool success_;
487 }; 488 };
488 489
489 // Overload write transaction to use custom NotifyTransactionComplete 490 // Overload write transaction to use custom NotifyTransactionComplete
490 static const bool kLoggingInfo = true; 491 static const bool kLoggingInfo = true;
491 class WriteTransactionTest: public WriteTransaction { 492 class WriteTransactionTest: public WriteTransaction {
492 public: 493 public:
493 WriteTransactionTest(const syncable::ScopedDirLookup& directory, 494 WriteTransactionTest(const syncable::ScopedDirLookup& directory,
494 WriterTag writer, const char* source_file, 495 WriterTag writer,
495 int line, 496 const tracked_objects::Location& from_here,
496 scoped_ptr<WaitableEvent> *wait_for_syncapi) 497 scoped_ptr<WaitableEvent> *wait_for_syncapi)
497 : WriteTransaction(directory, writer, source_file, line), 498 : WriteTransaction(directory, writer, from_here),
498 wait_for_syncapi_(wait_for_syncapi) { } 499 wait_for_syncapi_(wait_for_syncapi) { }
499 500
500 virtual void NotifyTransactionComplete(syncable::ModelTypeBitSet types) { 501 virtual void NotifyTransactionComplete(syncable::ModelTypeBitSet types) {
501 // This is where we differ. Force a thread change here, giving another 502 // This is where we differ. Force a thread change here, giving another
502 // thread a chance to create a WriteTransaction 503 // thread a chance to create a WriteTransaction
503 (*wait_for_syncapi_)->Wait(); 504 (*wait_for_syncapi_)->Wait();
504 505
505 WriteTransaction::NotifyTransactionComplete(types); 506 WriteTransaction::NotifyTransactionComplete(types);
506 } 507 }
507 508
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 546
546 sync_pb::EntitySpecifics entity_specifics; 547 sync_pb::EntitySpecifics entity_specifics;
547 entity_specifics.MutableExtension(sync_pb::autofill)-> 548 entity_specifics.MutableExtension(sync_pb::autofill)->
548 CopyFrom(new_autofill); 549 CopyFrom(new_autofill);
549 550
550 { 551 {
551 // Tell main thread we've started 552 // Tell main thread we've started
552 (*wait_for_start_)->Signal(); 553 (*wait_for_start_)->Signal();
553 554
554 // Create write transaction. 555 // Create write transaction.
555 WriteTransactionTest trans(dir, UNITTEST, __FILE__, __LINE__, 556 WriteTransactionTest trans(dir, UNITTEST, FROM_HERE,
556 wait_for_syncapi_); 557 wait_for_syncapi_);
557 558
558 // Create actual entry based on autofill protobuf information. 559 // Create actual entry based on autofill protobuf information.
559 // Simulates effects of SyncerUtil::UpdateLocalDataFromServerData 560 // Simulates effects of SyncerUtil::UpdateLocalDataFromServerData
560 MutableEntry parent(&trans, GET_BY_SERVER_TAG, kAutofillTag); 561 MutableEntry parent(&trans, GET_BY_SERVER_TAG, kAutofillTag);
561 MutableEntry item(&trans, CREATE, parent.Get(syncable::ID), tag); 562 MutableEntry item(&trans, CREATE, parent.Get(syncable::ID), tag);
562 ASSERT_TRUE(item.good()); 563 ASSERT_TRUE(item.good());
563 item.Put(SPECIFICS, entity_specifics); 564 item.Put(SPECIFICS, entity_specifics);
564 item.Put(SERVER_SPECIFICS, entity_specifics); 565 item.Put(SERVER_SPECIFICS, entity_specifics);
565 item.Put(BASE_VERSION, 1); 566 item.Put(BASE_VERSION, 1);
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 std::vector<AutofillEntry> sync_entries; 1081 std::vector<AutofillEntry> sync_entries;
1081 std::vector<AutofillProfile> sync_profiles; 1082 std::vector<AutofillProfile> sync_profiles;
1082 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1083 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1083 EXPECT_EQ(3U, sync_entries.size()); 1084 EXPECT_EQ(3U, sync_entries.size());
1084 EXPECT_EQ(0U, sync_profiles.size()); 1085 EXPECT_EQ(0U, sync_profiles.size());
1085 for (size_t i = 0; i < sync_entries.size(); i++) { 1086 for (size_t i = 0; i < sync_entries.size(); i++) {
1086 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1087 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1087 << ", " << sync_entries[i].key().value(); 1088 << ", " << sync_entries[i].key().value();
1088 } 1089 }
1089 } 1090 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/js_transaction_observer.cc ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698