Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 #include "sync/test/engine/fake_model_worker.h" | 68 #include "sync/test/engine/fake_model_worker.h" |
| 69 #include "sync/test/engine/fake_sync_scheduler.h" | 69 #include "sync/test/engine/fake_sync_scheduler.h" |
| 70 #include "sync/test/engine/test_id_factory.h" | 70 #include "sync/test/engine/test_id_factory.h" |
| 71 #include "sync/test/fake_encryptor.h" | 71 #include "sync/test/fake_encryptor.h" |
| 72 #include "sync/util/cryptographer.h" | 72 #include "sync/util/cryptographer.h" |
| 73 #include "sync/util/extensions_activity.h" | 73 #include "sync/util/extensions_activity.h" |
| 74 #include "sync/util/mock_unrecoverable_error_handler.h" | 74 #include "sync/util/mock_unrecoverable_error_handler.h" |
| 75 #include "sync/util/time.h" | 75 #include "sync/util/time.h" |
| 76 #include "testing/gmock/include/gmock/gmock.h" | 76 #include "testing/gmock/include/gmock/gmock.h" |
| 77 #include "testing/gtest/include/gtest/gtest.h" | 77 #include "testing/gtest/include/gtest/gtest.h" |
| 78 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h" | |
| 79 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite .h" | |
| 78 #include "url/gurl.h" | 80 #include "url/gurl.h" |
| 79 | 81 |
| 80 using base::ExpectDictStringValue; | 82 using base::ExpectDictStringValue; |
| 81 using testing::_; | 83 using testing::_; |
| 82 using testing::DoAll; | 84 using testing::DoAll; |
| 83 using testing::InSequence; | 85 using testing::InSequence; |
| 84 using testing::Return; | 86 using testing::Return; |
| 85 using testing::SaveArg; | 87 using testing::SaveArg; |
| 86 using testing::StrictMock; | 88 using testing::StrictMock; |
| 87 | 89 |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 | 625 |
| 624 TEST_F(SyncApiTest, BaseNodeSetSpecificsPreservesUnknownFields) { | 626 TEST_F(SyncApiTest, BaseNodeSetSpecificsPreservesUnknownFields) { |
| 625 int64_t child_id = MakeNodeWithRoot(user_share(), BOOKMARKS, "testtag"); | 627 int64_t child_id = MakeNodeWithRoot(user_share(), BOOKMARKS, "testtag"); |
| 626 WriteTransaction trans(FROM_HERE, user_share()); | 628 WriteTransaction trans(FROM_HERE, user_share()); |
| 627 WriteNode node(&trans); | 629 WriteNode node(&trans); |
| 628 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id)); | 630 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id)); |
| 629 EXPECT_TRUE(node.GetEntitySpecifics().unknown_fields().empty()); | 631 EXPECT_TRUE(node.GetEntitySpecifics().unknown_fields().empty()); |
| 630 | 632 |
| 631 sync_pb::EntitySpecifics entity_specifics; | 633 sync_pb::EntitySpecifics entity_specifics; |
| 632 entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); | 634 entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); |
| 633 entity_specifics.mutable_unknown_fields()->AddFixed32(5, 100); | 635 { |
| 636 ::google::protobuf::io::StringOutputStream unknown_fields_stram( | |
|
Nicolas Zea
2016/04/05 22:47:40
stram -> stream
xyzzyz
2016/04/06 17:22:52
Good catch!
| |
| 637 entity_specifics.mutable_unknown_fields()); | |
| 638 ::google::protobuf::io::CodedOutputStream output(&unknown_fields_stram); | |
| 639 const int tag = 5; | |
| 640 const int value = 100; | |
| 641 output.WriteTag(tag); | |
| 642 output.WriteLittleEndian32(value); | |
| 643 } | |
| 634 node.SetEntitySpecifics(entity_specifics); | 644 node.SetEntitySpecifics(entity_specifics); |
| 635 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); | 645 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); |
| 636 | 646 |
| 637 entity_specifics.mutable_unknown_fields()->Clear(); | 647 entity_specifics.mutable_unknown_fields()->clear(); |
| 638 node.SetEntitySpecifics(entity_specifics); | 648 node.SetEntitySpecifics(entity_specifics); |
| 639 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); | 649 EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); |
|
Nicolas Zea
2016/04/05 22:47:40
What do you think about verifying the values in th
xyzzyz
2016/04/06 17:22:52
I added some verification, please take a look.
| |
| 640 } | 650 } |
| 641 | 651 |
| 642 TEST_F(SyncApiTest, EmptyTags) { | 652 TEST_F(SyncApiTest, EmptyTags) { |
| 643 WriteTransaction trans(FROM_HERE, user_share()); | 653 WriteTransaction trans(FROM_HERE, user_share()); |
| 644 ReadNode root_node(&trans); | 654 ReadNode root_node(&trans); |
| 645 root_node.InitByRootLookup(); | 655 root_node.InitByRootLookup(); |
| 646 WriteNode node(&trans); | 656 WriteNode node(&trans); |
| 647 std::string empty_tag; | 657 std::string empty_tag; |
| 648 WriteNode::InitUniqueByCreationResult result = | 658 WriteNode::InitUniqueByCreationResult result = |
| 649 node.InitUniqueByCreation(TYPED_URLS, root_node, empty_tag); | 659 node.InitUniqueByCreation(TYPED_URLS, root_node, empty_tag); |
| (...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3359 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3369 // SyncManagerInitInvalidStorageTest::GetFactory will return |
| 3360 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3370 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
| 3361 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3371 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
| 3362 // task is to ensure that SyncManagerImpl reported initialization failure in | 3372 // task is to ensure that SyncManagerImpl reported initialization failure in |
| 3363 // OnInitializationComplete callback. | 3373 // OnInitializationComplete callback. |
| 3364 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3374 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
| 3365 EXPECT_FALSE(initialization_succeeded_); | 3375 EXPECT_FALSE(initialization_succeeded_); |
| 3366 } | 3376 } |
| 3367 | 3377 |
| 3368 } // namespace syncer | 3378 } // namespace syncer |
| OLD | NEW |