Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sync/engine/traffic_recorder.h" | |
| 6 | |
| 7 #include "sync/protocol/sync.pb.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace browser_sync { | |
| 11 | |
| 12 extern const unsigned int kMaxMessages; | |
|
akalin
2012/03/27 23:53:44
eh, this is pretty gross. :/ Make TrafficRecorder'
lipalani1
2012/03/29 00:23:13
Done.
| |
| 13 extern const unsigned int kMaxMessageSize; | |
| 14 | |
| 15 // Ensure the number of records don't exceed |kMaxMessages|. | |
| 16 TEST(TrafficRecorderTest, MaxRecordsTest) { | |
| 17 TrafficRecorder recorder; | |
| 18 TrafficRecorder::TrafficRecord record; | |
| 19 | |
| 20 for (unsigned int i = 0; i<2*kMaxMessages; ++i) | |
|
akalin
2012/03/27 23:53:44
prefer calling the public interface
lipalani1
2012/03/29 00:23:13
Done.
| |
| 21 recorder.AddTrafficToQueue(record); | |
| 22 | |
| 23 EXPECT_EQ(recorder.records_.size(), kMaxMessages); | |
| 24 } | |
| 25 | |
| 26 // Ensure records with size greater than |kMaxMessageSize| are truncated. | |
| 27 TEST(TrafficRecorderTest, MaxMessageSizeTest) { | |
| 28 sync_pb::ClientToServerResponse response; | |
| 29 | |
| 30 int id = 0; | |
| 31 while ((unsigned int)response.ByteSize() < kMaxMessageSize) { | |
|
akalin
2012/03/27 23:53:44
you can just assign to error_message some large st
lipalani1
2012/03/29 00:23:13
hmm... I dont want to type in a large error messag
akalin
2012/03/29 08:13:14
You don't have to literally type in the large erro
| |
| 32 response.add_migrated_data_type_id(id); | |
| 33 ++id; | |
| 34 } | |
| 35 | |
| 36 TrafficRecorder recorder; | |
| 37 recorder.RecordClientToServerResponse(response); | |
| 38 | |
| 39 TrafficRecorder::TrafficRecord record = recorder.records_.front(); | |
| 40 EXPECT_TRUE(record.truncated); | |
| 41 EXPECT_TRUE(record.message.empty()); | |
| 42 } | |
| 43 | |
| 44 } //namespace browser_sync | |
| OLD | NEW |