| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/sync/engine/syncer_proto_util.h" | 5 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 8 #include "chrome/browser/sync/engine/syncproto.h" | 10 #include "chrome/browser/sync/engine/syncproto.h" |
| 9 #include "chrome/browser/sync/syncable/blob.h" | 11 #include "chrome/browser/sync/syncable/blob.h" |
| 10 #include "chrome/browser/sync/syncable/directory_manager.h" | 12 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 11 #include "chrome/browser/sync/syncable/syncable.h" | 13 #include "chrome/browser/sync/syncable/syncable.h" |
| 12 #include "chrome/test/sync/engine/mock_connection_manager.h" | 14 #include "chrome/test/sync/engine/mock_connection_manager.h" |
| 13 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 15 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
| 14 | 16 |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 18 |
| 17 using syncable::Blob; | 19 using syncable::Blob; |
| 18 using syncable::ScopedDirLookup; | 20 using syncable::ScopedDirLookup; |
| 19 using syncable::SyncName; | 21 using syncable::SyncName; |
| 20 | 22 |
| 21 namespace browser_sync { | 23 namespace browser_sync { |
| 22 | 24 |
| 23 TEST(SyncerProtoUtil, TestBlobToProtocolBufferBytesUtilityFunctions) { | 25 TEST(SyncerProtoUtil, TestBlobToProtocolBufferBytesUtilityFunctions) { |
| 24 unsigned char test_data1[] = {1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 4, 2, 9}; | 26 unsigned char test_data1[] = {1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 4, 2, 9}; |
| 25 unsigned char test_data2[] = {1, 99, 3, 4, 5, 6, 7, 8, 0, 1, 4, 2, 9}; | 27 unsigned char test_data2[] = {1, 99, 3, 4, 5, 6, 7, 8, 0, 1, 4, 2, 9}; |
| 26 unsigned char test_data3[] = {99, 2, 3, 4, 5, 6, 7, 8}; | 28 unsigned char test_data3[] = {99, 2, 3, 4, 5, 6, 7, 8}; |
| 27 | 29 |
| 28 syncable::Blob test_blob1, test_blob2, test_blob3; | 30 syncable::Blob test_blob1, test_blob2, test_blob3; |
| 29 for (size_t i = 0; i < arraysize(test_data1); ++i) | 31 for (size_t i = 0; i < arraysize(test_data1); ++i) |
| 30 test_blob1.push_back(test_data1[i]); | 32 test_blob1.push_back(test_data1[i]); |
| 31 for (size_t i = 0; i < arraysize(test_data2); ++i) | 33 for (size_t i = 0; i < arraysize(test_data2); ++i) |
| 32 test_blob2.push_back(test_data2[i]); | 34 test_blob2.push_back(test_data2[i]); |
| 33 for (size_t i = 0; i < arraysize(test_data3); ++i) | 35 for (size_t i = 0; i < arraysize(test_data3); ++i) |
| 34 test_blob3.push_back(test_data3[i]); | 36 test_blob3.push_back(test_data3[i]); |
| 35 | 37 |
| 36 string test_message1(reinterpret_cast<char*>(test_data1), | 38 std::string test_message1(reinterpret_cast<char*>(test_data1), |
| 37 arraysize(test_data1)); | 39 arraysize(test_data1)); |
| 38 string test_message2(reinterpret_cast<char*>(test_data2), | 40 std::string test_message2(reinterpret_cast<char*>(test_data2), |
| 39 arraysize(test_data2)); | 41 arraysize(test_data2)); |
| 40 string test_message3(reinterpret_cast<char*>(test_data3), | 42 std::string test_message3(reinterpret_cast<char*>(test_data3), |
| 41 arraysize(test_data3)); | 43 arraysize(test_data3)); |
| 42 | 44 |
| 43 EXPECT_TRUE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, | 45 EXPECT_TRUE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, |
| 44 test_blob1)); | 46 test_blob1)); |
| 45 EXPECT_FALSE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, | 47 EXPECT_FALSE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, |
| 46 test_blob2)); | 48 test_blob2)); |
| 47 EXPECT_FALSE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, | 49 EXPECT_FALSE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, |
| 48 test_blob3)); | 50 test_blob3)); |
| 49 EXPECT_FALSE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message2, | 51 EXPECT_FALSE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message2, |
| 50 test_blob1)); | 52 test_blob1)); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 dcm.set_send_error(false); | 231 dcm.set_send_error(false); |
| 230 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, | 232 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, |
| 231 msg, &response)); | 233 msg, &response)); |
| 232 | 234 |
| 233 dcm.set_access_denied(true); | 235 dcm.set_access_denied(true); |
| 234 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, | 236 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, |
| 235 msg, &response)); | 237 msg, &response)); |
| 236 } | 238 } |
| 237 | 239 |
| 238 } // namespace browser_sync | 240 } // namespace browser_sync |
| OLD | NEW |