Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: sync/engine/traffic_recorder_unittest.cc

Issue 9732008: [Sync] Store the past 10 traffic records in memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/traffic_recorder.cc ('k') | sync/sessions/sync_session_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 const unsigned int kMaxMessages = 10;
13 const unsigned int kMaxMessageSize = 5 * 1024;
14
15 // Ensure the number of records don't exceed |kMaxMessages|.
16 TEST(TrafficRecorderTest, MaxRecordsTest) {
17 TrafficRecorder recorder(kMaxMessages,kMaxMessageSize);
akalin 2012/03/29 18:54:06 space after comma
lipalani1 2012/03/29 19:28:28 Done.
18 sync_pb::ClientToServerResponse response;
19
20 for (unsigned int i = 0; i<2*kMaxMessages; ++i)
21 recorder.RecordClientToServerResponse(response);
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/29 18:54:06 I still prefer the one-liner to add a large string
lipalani1 2012/03/29 19:28:28 Done.
32 response.add_migrated_data_type_id(id);
33 ++id;
34 }
35
36 TrafficRecorder recorder(kMaxMessages,kMaxMessageSize);
akalin 2012/03/29 18:54:06 space after comma
lipalani1 2012/03/29 19:28:28 Done.
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
OLDNEW
« no previous file with comments | « sync/engine/traffic_recorder.cc ('k') | sync/sessions/sync_session_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698