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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 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
« no previous file with comments | « sync/internal_api/DEPS ('k') | sync/internal_api/write_node.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include "sync/internal_api/sync_manager_impl.h" 9 #include "sync/internal_api/sync_manager_impl.h"
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "sync/test/engine/fake_model_worker.h" 69 #include "sync/test/engine/fake_model_worker.h"
70 #include "sync/test/engine/fake_sync_scheduler.h" 70 #include "sync/test/engine/fake_sync_scheduler.h"
71 #include "sync/test/engine/test_id_factory.h" 71 #include "sync/test/engine/test_id_factory.h"
72 #include "sync/test/fake_encryptor.h" 72 #include "sync/test/fake_encryptor.h"
73 #include "sync/util/cryptographer.h" 73 #include "sync/util/cryptographer.h"
74 #include "sync/util/extensions_activity.h" 74 #include "sync/util/extensions_activity.h"
75 #include "sync/util/mock_unrecoverable_error_handler.h" 75 #include "sync/util/mock_unrecoverable_error_handler.h"
76 #include "sync/util/time.h" 76 #include "sync/util/time.h"
77 #include "testing/gmock/include/gmock/gmock.h" 77 #include "testing/gmock/include/gmock/gmock.h"
78 #include "testing/gtest/include/gtest/gtest.h" 78 #include "testing/gtest/include/gtest/gtest.h"
79 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h"
80 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite .h"
79 #include "url/gurl.h" 81 #include "url/gurl.h"
80 82
81 using base::ExpectDictStringValue; 83 using base::ExpectDictStringValue;
82 using testing::_; 84 using testing::_;
83 using testing::DoAll; 85 using testing::DoAll;
84 using testing::InSequence; 86 using testing::InSequence;
85 using testing::Return; 87 using testing::Return;
86 using testing::SaveArg; 88 using testing::SaveArg;
87 using testing::StrictMock; 89 using testing::StrictMock;
88 90
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 626
625 TEST_F(SyncApiTest, BaseNodeSetSpecificsPreservesUnknownFields) { 627 TEST_F(SyncApiTest, BaseNodeSetSpecificsPreservesUnknownFields) {
626 int64_t child_id = MakeNodeWithRoot(user_share(), BOOKMARKS, "testtag"); 628 int64_t child_id = MakeNodeWithRoot(user_share(), BOOKMARKS, "testtag");
627 WriteTransaction trans(FROM_HERE, user_share()); 629 WriteTransaction trans(FROM_HERE, user_share());
628 WriteNode node(&trans); 630 WriteNode node(&trans);
629 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id)); 631 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id));
630 EXPECT_TRUE(node.GetEntitySpecifics().unknown_fields().empty()); 632 EXPECT_TRUE(node.GetEntitySpecifics().unknown_fields().empty());
631 633
632 sync_pb::EntitySpecifics entity_specifics; 634 sync_pb::EntitySpecifics entity_specifics;
633 entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); 635 entity_specifics.mutable_bookmark()->set_url("http://www.google.com");
634 entity_specifics.mutable_unknown_fields()->AddFixed32(5, 100); 636 std::string unknown_fields;
637 {
638 ::google::protobuf::io::StringOutputStream unknown_fields_stream(
639 &unknown_fields);
640 ::google::protobuf::io::CodedOutputStream output(&unknown_fields_stream);
641 const int tag = 5;
642 const int value = 100;
643 output.WriteTag(tag);
644 output.WriteLittleEndian32(value);
645 }
646 *entity_specifics.mutable_unknown_fields() = unknown_fields;
635 node.SetEntitySpecifics(entity_specifics); 647 node.SetEntitySpecifics(entity_specifics);
636 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); 648 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty());
649 EXPECT_EQ(unknown_fields, node.GetEntitySpecifics().unknown_fields());
637 650
638 entity_specifics.mutable_unknown_fields()->Clear(); 651 entity_specifics.mutable_unknown_fields()->clear();
639 node.SetEntitySpecifics(entity_specifics); 652 node.SetEntitySpecifics(entity_specifics);
640 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); 653 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty());
654 EXPECT_EQ(unknown_fields, node.GetEntitySpecifics().unknown_fields());
641 } 655 }
642 656
643 TEST_F(SyncApiTest, EmptyTags) { 657 TEST_F(SyncApiTest, EmptyTags) {
644 WriteTransaction trans(FROM_HERE, user_share()); 658 WriteTransaction trans(FROM_HERE, user_share());
645 ReadNode root_node(&trans); 659 ReadNode root_node(&trans);
646 root_node.InitByRootLookup(); 660 root_node.InitByRootLookup();
647 WriteNode node(&trans); 661 WriteNode node(&trans);
648 std::string empty_tag; 662 std::string empty_tag;
649 WriteNode::InitUniqueByCreationResult result = 663 WriteNode::InitUniqueByCreationResult result =
650 node.InitUniqueByCreation(TYPED_URLS, root_node, empty_tag); 664 node.InitUniqueByCreation(TYPED_URLS, root_node, empty_tag);
(...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 // SyncManagerInitInvalidStorageTest::GetFactory will return 3385 // SyncManagerInitInvalidStorageTest::GetFactory will return
3372 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3386 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3373 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3387 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3374 // task is to ensure that SyncManagerImpl reported initialization failure in 3388 // task is to ensure that SyncManagerImpl reported initialization failure in
3375 // OnInitializationComplete callback. 3389 // OnInitializationComplete callback.
3376 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3390 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3377 EXPECT_FALSE(initialization_succeeded_); 3391 EXPECT_FALSE(initialization_succeeded_);
3378 } 3392 }
3379 3393
3380 } // namespace syncer 3394 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/DEPS ('k') | sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698