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

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 submitting. 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);
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 sync_pb::ClientToServerResponse::Error* error = response.mutable_error();
31 std::string error_description(kMaxMessageSize * 2, 'a');
32 error->set_error_description(error_description);
33
34 TrafficRecorder recorder(kMaxMessages, kMaxMessageSize);
35 recorder.RecordClientToServerResponse(response);
36
37 TrafficRecorder::TrafficRecord record = recorder.records().front();
38 EXPECT_TRUE(record.truncated);
39 EXPECT_TRUE(record.message.empty());
40 }
41
42 } //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