| OLD | NEW |
| 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 // Mock ServerConnectionManager class for use in client regression tests. | 5 // Mock ServerConnectionManager class for use in client regression tests. |
| 6 | 6 |
| 7 #include "chrome/test/sync/engine/mock_connection_manager.h" | 7 #include "chrome/test/sync/engine/mock_connection_manager.h" |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/stringprintf.h" |
| 11 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 12 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 12 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 13 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
| 13 #include "chrome/test/sync/engine/test_id_factory.h" | 14 #include "chrome/test/sync/engine/test_id_factory.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 using browser_sync::HttpResponse; | 17 using browser_sync::HttpResponse; |
| 17 using browser_sync::ServerConnectionManager; | 18 using browser_sync::ServerConnectionManager; |
| 18 using browser_sync::ServerConnectionEventListener; | 19 using browser_sync::ServerConnectionEventListener; |
| 19 using browser_sync::ServerConnectionEvent; | 20 using browser_sync::ServerConnectionEvent; |
| 20 using browser_sync::SyncerProtoUtil; | 21 using browser_sync::SyncerProtoUtil; |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 502 } |
| 502 string parent_id = entry.parent_id_string(); | 503 string parent_id = entry.parent_id_string(); |
| 503 // Remap id's we've already assigned. | 504 // Remap id's we've already assigned. |
| 504 if (changed_ids.end() != changed_ids.find(parent_id)) { | 505 if (changed_ids.end() != changed_ids.find(parent_id)) { |
| 505 parent_id = changed_ids[parent_id]; | 506 parent_id = changed_ids[parent_id]; |
| 506 er->set_parent_id_string(parent_id); | 507 er->set_parent_id_string(parent_id); |
| 507 } | 508 } |
| 508 if (entry.has_version() && 0 != entry.version()) { | 509 if (entry.has_version() && 0 != entry.version()) { |
| 509 er->set_id_string(id); // Allows verification. | 510 er->set_id_string(id); // Allows verification. |
| 510 } else { | 511 } else { |
| 511 string new_id = StringPrintf("mock_server:%d", next_new_id_++); | 512 string new_id = base::StringPrintf("mock_server:%d", next_new_id_++); |
| 512 changed_ids[id] = new_id; | 513 changed_ids[id] = new_id; |
| 513 er->set_id_string(new_id); | 514 er->set_id_string(new_id); |
| 514 } | 515 } |
| 515 } | 516 } |
| 516 commit_responses_->push_back(new CommitResponse(*commit_response)); | 517 commit_responses_->push_back(new CommitResponse(*commit_response)); |
| 517 } | 518 } |
| 518 | 519 |
| 519 SyncEntity* MockConnectionManager::AddUpdateDirectory( | 520 SyncEntity* MockConnectionManager::AddUpdateDirectory( |
| 520 syncable::Id id, syncable::Id parent_id, string name, int64 version, | 521 syncable::Id id, syncable::Id parent_id, string name, int64 version, |
| 521 int64 sync_ts) { | 522 int64 sync_ts) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 ServerConnectionEvent(server_status_, server_reachable_)); | 612 ServerConnectionEvent(server_status_, server_reachable_)); |
| 612 } | 613 } |
| 613 | 614 |
| 614 void MockConnectionManager::SetServerNotReachable() { | 615 void MockConnectionManager::SetServerNotReachable() { |
| 615 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; | 616 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; |
| 616 server_reachable_ = false; | 617 server_reachable_ = false; |
| 617 | 618 |
| 618 listeners_->Notify(&ServerConnectionEventListener::OnServerConnectionEvent, | 619 listeners_->Notify(&ServerConnectionEventListener::OnServerConnectionEvent, |
| 619 ServerConnectionEvent(server_status_, server_reachable_)); | 620 ServerConnectionEvent(server_status_, server_reachable_)); |
| 620 } | 621 } |
| OLD | NEW |