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

Unified Diff: sync/engine/traffic_recorder_unittest.cc

Issue 12090113: Revert 180073 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/traffic_recorder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/traffic_recorder_unittest.cc
===================================================================
--- sync/engine/traffic_recorder_unittest.cc (revision 180080)
+++ sync/engine/traffic_recorder_unittest.cc (working copy)
@@ -4,10 +4,7 @@
#include "sync/engine/traffic_recorder.h"
-#include "base/time.h"
-#include "base/values.h"
#include "sync/protocol/sync.pb.h"
-#include "sync/util/time.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
@@ -42,79 +39,4 @@
EXPECT_TRUE(record.message.empty());
}
-// Test implementation of TrafficRecorder.
-class TestTrafficRecorder : public TrafficRecorder {
- public:
- TestTrafficRecorder(unsigned int max_messages, unsigned int max_message_size)
- : TrafficRecorder(max_messages, max_message_size) {
- set_time(0);
- }
- virtual ~TestTrafficRecorder() {}
-
- virtual base::Time GetTime() OVERRIDE {
- return time_;
- }
-
- void set_time(int64 time) {
- time_ = ProtoTimeToTime(time);
- }
-
- void set_time(base::Time time) {
- time_ = time;
- }
-
- private:
- base::Time time_;
-};
-
-// Ensure that timestamp is recorded correctly in traffic record.
-TEST(TrafficRecorderTest, TimestampTest) {
- sync_pb::ClientToServerResponse response;
-
- TestTrafficRecorder recorder(kMaxMessages, kMaxMessageSize);
- recorder.set_time(3);
- recorder.RecordClientToServerResponse(response);
-
- base::Time expect_time = ProtoTimeToTime(3);
- TrafficRecorder::TrafficRecord record = recorder.records().front();
- EXPECT_EQ(expect_time, record.timestamp);
-}
-
-// Ensure that timestamps are recorded correctly in traffic records.
-TEST(TrafficRecorderTest, MultipleTimestampTest) {
- sync_pb::ClientToServerResponse response;
- base::Time sample_time_1 = ProtoTimeToTime(1359484676659324);
- base::Time sample_time_2 = ProtoTimeToTime(1359484676659324 * 2);
-
- TestTrafficRecorder recorder(kMaxMessages, kMaxMessageSize);
- recorder.set_time(sample_time_1);
- recorder.RecordClientToServerResponse(response);
- recorder.set_time(sample_time_2);
- recorder.RecordClientToServerResponse(response);
-
- TrafficRecorder::TrafficRecord record_1 = recorder.records().front();
- TrafficRecorder::TrafficRecord record_2 = recorder.records().back();
- EXPECT_EQ(sample_time_1, record_1.timestamp);
- EXPECT_EQ(sample_time_2, record_2.timestamp);
-}
-
-// Ensure that timestamp is added to ListValue of DictionaryValues in ToValue().
-TEST(TrafficRecorderTest, ToValueTimestampTest) {
- sync_pb::ClientToServerResponse response;
- base::Time sample_time = ProtoTimeToTime(1359484676659324);
- std::string expect_time_str = GetTimeDebugString(sample_time);
-
- TestTrafficRecorder recorder(kMaxMessages, kMaxMessageSize);
- recorder.set_time(sample_time);
- recorder.RecordClientToServerResponse(response);
-
- ListValue* value = recorder.ToValue();
- DictionaryValue* record_value;
- std::string time_str;
-
- ASSERT_TRUE(value->GetDictionary(0, &record_value));
- EXPECT_TRUE(record_value->GetString("timestamp", &time_str));
- EXPECT_EQ(expect_time_str, time_str);
-}
-
} // namespace syncer
« no previous file with comments | « sync/engine/traffic_recorder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698