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

Side by Side Diff: sync/syncable/syncable_unittest.cc

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 years, 5 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
« no previous file with comments | « sync/syncable/syncable_mock.cc ('k') | sync/syncable/write_transaction_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 18 matching lines...) Expand all
29 #include "sync/syncable/syncable_util.h" 29 #include "sync/syncable/syncable_util.h"
30 #include "sync/syncable/write_transaction.h" 30 #include "sync/syncable/write_transaction.h"
31 #include "sync/test/engine/test_id_factory.h" 31 #include "sync/test/engine/test_id_factory.h"
32 #include "sync/test/engine/test_syncable_utils.h" 32 #include "sync/test/engine/test_syncable_utils.h"
33 #include "sync/test/fake_encryptor.h" 33 #include "sync/test/fake_encryptor.h"
34 #include "sync/test/null_directory_change_delegate.h" 34 #include "sync/test/null_directory_change_delegate.h"
35 #include "sync/test/null_transaction_observer.h" 35 #include "sync/test/null_transaction_observer.h"
36 #include "sync/util/test_unrecoverable_error_handler.h" 36 #include "sync/util/test_unrecoverable_error_handler.h"
37 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
38 38
39 using base::ExpectDictBooleanValue;
40 using base::ExpectDictStringValue;
41 using syncer::FakeEncryptor;
42 using syncer::TestIdFactory;
43 using syncer::TestUnrecoverableErrorHandler;
44
45 namespace syncer { 39 namespace syncer {
46 namespace syncable { 40 namespace syncable {
47 41
42 using base::ExpectDictBooleanValue;
43 using base::ExpectDictStringValue;
44
48 class SyncableKernelTest : public testing::Test {}; 45 class SyncableKernelTest : public testing::Test {};
49 46
50 // TODO(akalin): Add unit tests for EntryKernel::ContainsString(). 47 // TODO(akalin): Add unit tests for EntryKernel::ContainsString().
51 48
52 TEST_F(SyncableKernelTest, ToValue) { 49 TEST_F(SyncableKernelTest, ToValue) {
53 EntryKernel kernel; 50 EntryKernel kernel;
54 scoped_ptr<DictionaryValue> value(kernel.ToValue()); 51 scoped_ptr<DictionaryValue> value(kernel.ToValue());
55 if (value.get()) { 52 if (value.get()) {
56 // Not much to check without repeating the ToValue() code. 53 // Not much to check without repeating the ToValue() code.
57 EXPECT_TRUE(value->HasKey("isDirty")); 54 EXPECT_TRUE(value->HasKey("isDirty"));
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 all_handles.insert(e.Get(META_HANDLE)); 538 all_handles.insert(e.Get(META_HANDLE));
542 } else { 539 } else {
543 AddDefaultFieldValue(PREFERENCES, &specs); 540 AddDefaultFieldValue(PREFERENCES, &specs);
544 all_handles.insert(e.Get(META_HANDLE)); 541 all_handles.insert(e.Get(META_HANDLE));
545 } 542 }
546 e.Put(SPECIFICS, specs); 543 e.Put(SPECIFICS, specs);
547 e.Put(SERVER_SPECIFICS, specs); 544 e.Put(SERVER_SPECIFICS, specs);
548 } 545 }
549 } 546 }
550 547
551 syncer::ModelTypeSet to_purge(BOOKMARKS); 548 ModelTypeSet to_purge(BOOKMARKS);
552 dir_->PurgeEntriesWithTypeIn(to_purge); 549 dir_->PurgeEntriesWithTypeIn(to_purge);
553 550
554 Directory::SaveChangesSnapshot snapshot1; 551 Directory::SaveChangesSnapshot snapshot1;
555 base::AutoLock scoped_lock(dir_->kernel_->save_changes_mutex); 552 base::AutoLock scoped_lock(dir_->kernel_->save_changes_mutex);
556 dir_->TakeSnapshotForSaveChanges(&snapshot1); 553 dir_->TakeSnapshotForSaveChanges(&snapshot1);
557 EXPECT_TRUE(expected_purges == snapshot1.metahandles_to_purge); 554 EXPECT_TRUE(expected_purges == snapshot1.metahandles_to_purge);
558 555
559 to_purge.Clear(); 556 to_purge.Clear();
560 to_purge.Put(PREFERENCES); 557 to_purge.Put(PREFERENCES);
561 dir_->PurgeEntriesWithTypeIn(to_purge); 558 dir_->PurgeEntriesWithTypeIn(to_purge);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); 819 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
823 dir_->GetUnsyncedMetaHandles(&trans, &handles); 820 dir_->GetUnsyncedMetaHandles(&trans, &handles);
824 ASSERT_TRUE(1 == handles.size()); 821 ASSERT_TRUE(1 == handles.size());
825 ASSERT_TRUE(handle2 == handles[0]); 822 ASSERT_TRUE(handle2 == handles[0]);
826 } 823 }
827 } 824 }
828 825
829 TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { 826 TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) {
830 std::vector<int64> handles; 827 std::vector<int64> handles;
831 int64 handle1, handle2; 828 int64 handle1, handle2;
832 const syncer::FullModelTypeSet all_types = syncer::FullModelTypeSet::All(); 829 const FullModelTypeSet all_types = FullModelTypeSet::All();
833 { 830 {
834 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); 831 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
835 832
836 dir_->GetUnappliedUpdateMetaHandles(&trans, all_types, &handles); 833 dir_->GetUnappliedUpdateMetaHandles(&trans, all_types, &handles);
837 ASSERT_TRUE(0 == handles.size()); 834 ASSERT_TRUE(0 == handles.size());
838 835
839 MutableEntry e1(&trans, CREATE, trans.root_id(), "abba"); 836 MutableEntry e1(&trans, CREATE, trans.root_id(), "abba");
840 ASSERT_TRUE(e1.good()); 837 ASSERT_TRUE(e1.good());
841 handle1 = e1.Get(META_HANDLE); 838 handle1 = e1.Get(META_HANDLE);
842 e1.Put(IS_UNAPPLIED_UPDATE, false); 839 e1.Put(IS_UNAPPLIED_UPDATE, false);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 sync_pb::EntitySpecifics bookmark_specs; 1393 sync_pb::EntitySpecifics bookmark_specs;
1397 sync_pb::EntitySpecifics autofill_specs; 1394 sync_pb::EntitySpecifics autofill_specs;
1398 sync_pb::EntitySpecifics preference_specs; 1395 sync_pb::EntitySpecifics preference_specs;
1399 AddDefaultFieldValue(BOOKMARKS, &bookmark_specs); 1396 AddDefaultFieldValue(BOOKMARKS, &bookmark_specs);
1400 AddDefaultFieldValue(PREFERENCES, &preference_specs); 1397 AddDefaultFieldValue(PREFERENCES, &preference_specs);
1401 AddDefaultFieldValue(AUTOFILL, &autofill_specs); 1398 AddDefaultFieldValue(AUTOFILL, &autofill_specs);
1402 dir_->set_initial_sync_ended_for_type(BOOKMARKS, true); 1399 dir_->set_initial_sync_ended_for_type(BOOKMARKS, true);
1403 dir_->set_initial_sync_ended_for_type(PREFERENCES, true); 1400 dir_->set_initial_sync_ended_for_type(PREFERENCES, true);
1404 dir_->set_initial_sync_ended_for_type(AUTOFILL, true); 1401 dir_->set_initial_sync_ended_for_type(AUTOFILL, true);
1405 1402
1406 syncer::ModelTypeSet types_to_purge(PREFERENCES, AUTOFILL); 1403 ModelTypeSet types_to_purge(PREFERENCES, AUTOFILL);
1407 1404
1408 TestIdFactory id_factory; 1405 TestIdFactory id_factory;
1409 // Create some items for each type. 1406 // Create some items for each type.
1410 { 1407 {
1411 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); 1408 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
1412 MutableEntry item1(&trans, CREATE, trans.root_id(), "Item"); 1409 MutableEntry item1(&trans, CREATE, trans.root_id(), "Item");
1413 ASSERT_TRUE(item1.good()); 1410 ASSERT_TRUE(item1.good());
1414 item1.Put(SPECIFICS, bookmark_specs); 1411 item1.Put(SPECIFICS, bookmark_specs);
1415 item1.Put(SERVER_SPECIFICS, bookmark_specs); 1412 item1.Put(SERVER_SPECIFICS, bookmark_specs);
1416 item1.Put(IS_UNSYNCED, true); 1413 item1.Put(IS_UNSYNCED, true);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); 1685 EXPECT_TRUE(e1.GetKernelCopy().is_dirty());
1689 EXPECT_TRUE(IsInDirtyMetahandles(handle1)); 1686 EXPECT_TRUE(IsInDirtyMetahandles(handle1));
1690 } 1687 }
1691 ASSERT_TRUE(dir_->SaveChanges()); 1688 ASSERT_TRUE(dir_->SaveChanges());
1692 1689
1693 // Now do some operations using a directory for which SaveChanges will 1690 // Now do some operations using a directory for which SaveChanges will
1694 // always fail. 1691 // always fail.
1695 SwapInUnsaveableDirectory(); 1692 SwapInUnsaveableDirectory();
1696 ASSERT_TRUE(dir_->good()); 1693 ASSERT_TRUE(dir_->good());
1697 1694
1698 syncer::ModelTypeSet set(BOOKMARKS); 1695 ModelTypeSet set(BOOKMARKS);
1699 dir_->PurgeEntriesWithTypeIn(set); 1696 dir_->PurgeEntriesWithTypeIn(set);
1700 EXPECT_TRUE(IsInMetahandlesToPurge(handle1)); 1697 EXPECT_TRUE(IsInMetahandlesToPurge(handle1));
1701 ASSERT_FALSE(dir_->SaveChanges()); 1698 ASSERT_FALSE(dir_->SaveChanges());
1702 EXPECT_TRUE(IsInMetahandlesToPurge(handle1)); 1699 EXPECT_TRUE(IsInMetahandlesToPurge(handle1));
1703 } 1700 }
1704 1701
1705 } // namespace 1702 } // namespace
1706 1703
1707 void SyncableDirectoryTest::ValidateEntry(BaseTransaction* trans, 1704 void SyncableDirectoryTest::ValidateEntry(BaseTransaction* trans,
1708 int64 id, 1705 int64 id,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); 1940 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true));
1944 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); 1941 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true));
1945 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); 1942 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false));
1946 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); 1943 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false));
1947 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); 1944 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true));
1948 } 1945 }
1949 1946
1950 } // namespace 1947 } // namespace
1951 } // namespace syncable 1948 } // namespace syncable
1952 } // namespace syncer 1949 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/syncable_mock.cc ('k') | sync/syncable/write_transaction_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698