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 // Mock ServerConnectionManager class for use in client regression tests. | 5 // Mock ServerConnectionManager class for use in client regression tests. |
6 | 6 |
7 #include "sync/test/engine/mock_connection_manager.h" | 7 #include "sync/test/engine/mock_connection_manager.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 | 76 |
77 bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, | 77 bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, |
78 const string& path, | 78 const string& path, |
79 const string& auth_token, | 79 const string& auth_token, |
80 ScopedServerStatusWatcher* watcher) { | 80 ScopedServerStatusWatcher* watcher) { |
81 ClientToServerMessage post; | 81 ClientToServerMessage post; |
82 CHECK(post.ParseFromString(params->buffer_in)); | 82 CHECK(post.ParseFromString(params->buffer_in)); |
83 CHECK(post.has_protocol_version()); | 83 CHECK(post.has_protocol_version()); |
84 CHECK(post.has_api_key()); | 84 CHECK(post.has_api_key()); |
85 CHECK(post.has_bag_of_chips()); | 85 CHECK(post.has_bag_of_chips()); |
86 last_request_.CopyFrom(post); | 86 |
87 requests_.push_back(sync_pb::ClientToServerMessage::default_instance()); | |
Nicolas Zea
2013/11/19 23:43:04
push_back(post)?
maniscalco
2013/11/20 01:03:32
Good catch. Done.
| |
88 requests_.back().CopyFrom(post); | |
87 client_stuck_ = post.sync_problem_detected(); | 89 client_stuck_ = post.sync_problem_detected(); |
88 sync_pb::ClientToServerResponse response; | 90 sync_pb::ClientToServerResponse response; |
89 response.Clear(); | 91 response.Clear(); |
90 | 92 |
91 if (directory_) { | 93 if (directory_) { |
92 // If the Directory's locked when we do this, it's a problem as in normal | 94 // If the Directory's locked when we do this, it's a problem as in normal |
93 // use this function could take a while to return because it accesses the | 95 // use this function could take a while to return because it accesses the |
94 // network. As we can't test this we do the next best thing and hang here | 96 // network. As we can't test this we do the next best thing and hang here |
95 // when there's an issue. | 97 // when there's an issue. |
96 CHECK(directory_->good()); | 98 CHECK(directory_->good()); |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 const CommitMessage& MockConnectionManager::last_sent_commit() const { | 681 const CommitMessage& MockConnectionManager::last_sent_commit() const { |
680 EXPECT_TRUE(!commit_messages_.empty()); | 682 EXPECT_TRUE(!commit_messages_.empty()); |
681 return *commit_messages_.back(); | 683 return *commit_messages_.back(); |
682 } | 684 } |
683 | 685 |
684 const CommitResponse& MockConnectionManager::last_commit_response() const { | 686 const CommitResponse& MockConnectionManager::last_commit_response() const { |
685 EXPECT_TRUE(!commit_responses_.empty()); | 687 EXPECT_TRUE(!commit_responses_.empty()); |
686 return *commit_responses_.back(); | 688 return *commit_responses_.back(); |
687 } | 689 } |
688 | 690 |
691 const sync_pb::ClientToServerMessage& | |
692 MockConnectionManager::last_request() const { | |
693 EXPECT_TRUE(!requests_.empty()); | |
694 return requests_.back(); | |
695 } | |
696 | |
697 const std::vector<sync_pb::ClientToServerMessage>& | |
698 MockConnectionManager::requests() const { | |
699 return requests_; | |
700 } | |
701 | |
689 bool MockConnectionManager::IsModelTypePresentInSpecifics( | 702 bool MockConnectionManager::IsModelTypePresentInSpecifics( |
690 const google::protobuf::RepeatedPtrField< | 703 const google::protobuf::RepeatedPtrField< |
691 sync_pb::DataTypeProgressMarker>& filter, | 704 sync_pb::DataTypeProgressMarker>& filter, |
692 ModelType value) { | 705 ModelType value) { |
693 int data_type_id = GetSpecificsFieldNumberFromModelType(value); | 706 int data_type_id = GetSpecificsFieldNumberFromModelType(value); |
694 for (int i = 0; i < filter.size(); ++i) { | 707 for (int i = 0; i < filter.size(); ++i) { |
695 if (filter.Get(i).data_type_id() == data_type_id) { | 708 if (filter.Get(i).data_type_id() == data_type_id) { |
696 return true; | 709 return true; |
697 } | 710 } |
698 } | 711 } |
(...skipping 29 matching lines...) Expand all Loading... | |
728 server_status_ = HttpResponse::SERVER_CONNECTION_OK; | 741 server_status_ = HttpResponse::SERVER_CONNECTION_OK; |
729 } | 742 } |
730 } | 743 } |
731 | 744 |
732 void MockConnectionManager::SetServerStatus( | 745 void MockConnectionManager::SetServerStatus( |
733 HttpResponse::ServerConnectionCode server_status) { | 746 HttpResponse::ServerConnectionCode server_status) { |
734 server_status_ = server_status; | 747 server_status_ = server_status; |
735 } | 748 } |
736 | 749 |
737 } // namespace syncer | 750 } // namespace syncer |
OLD | NEW |