Index: blimp/net/compressed_packet_unittest.cc |
diff --git a/blimp/net/compressed_packet_unittest.cc b/blimp/net/compressed_packet_unittest.cc |
index 0742fda8d74659fb6abb0ee72bb9efe1d4fc54e0..7223f44371e0578069e64a9e72da4c82ddab3247 100644 |
--- a/blimp/net/compressed_packet_unittest.cc |
+++ b/blimp/net/compressed_packet_unittest.cc |
@@ -4,7 +4,9 @@ |
#include "base/memory/ptr_util.h" |
#include "base/rand_util.h" |
+#include "base/run_loop.h" |
#include "base/sys_byteorder.h" |
+#include "blimp/net/blimp_connection_statistics.h" |
#include "blimp/net/common.h" |
#include "blimp/net/compressed_packet_reader.h" |
#include "blimp/net/compressed_packet_writer.h" |
@@ -47,12 +49,18 @@ ACTION_TEMPLATE(CopyBuffer, |
class CompressedPacketTest : public testing::Test { |
public: |
CompressedPacketTest() |
- : mock_reader_(new MockPacketReader), |
+ : blimp_connection_statistics_(new BlimpConnectionStatistics), |
+ mock_reader_(new MockPacketReader), |
mock_writer_(new MockPacketWriter), |
compressed_reader_( |
new CompressedPacketReader(base::WrapUnique(mock_reader_))), |
compressed_writer_( |
- new CompressedPacketWriter(base::WrapUnique(mock_writer_))) {} |
+ new CompressedPacketWriter(base::WrapUnique(mock_writer_))) { |
+ compressed_reader_->set_blimp_connection_statistics( |
+ blimp_connection_statistics_.get()); |
+ compressed_writer_->set_blimp_connection_statistics( |
+ blimp_connection_statistics_.get()); |
+ } |
~CompressedPacketTest() override {} |
protected: |
@@ -98,6 +106,7 @@ class CompressedPacketTest : public testing::Test { |
return Decompress(Compress(content)) == content; |
} |
+ std::unique_ptr<BlimpConnectionStatistics> blimp_connection_statistics_; |
Kevin M
2016/05/24 01:02:01
suggestion: make it a regular (non-unique_ptr) fie
shaktisahu
2016/05/24 21:02:45
Removed from this file
|
MockPacketReader* mock_reader_; |
MockPacketWriter* mock_writer_; |
std::unique_ptr<CompressedPacketReader> compressed_reader_; |
@@ -107,10 +116,22 @@ class CompressedPacketTest : public testing::Test { |
TEST_F(CompressedPacketTest, Empty) { |
EXPECT_TRUE(CheckRoundTrip("1234")); |
+ EXPECT_TRUE(CheckRoundTrip("1234")); |
Kevin M
2016/05/24 01:02:02
Why duplicate this line?
shaktisahu
2016/05/24 21:02:45
Done.
|
EXPECT_TRUE(CheckRoundTrip("")); |
EXPECT_TRUE(CheckRoundTrip("1234")); |
} |
+TEST_F(CompressedPacketTest, StatisticsCollection) { |
+ std::string source = "AAAAAAAAAAAAAAAAAAAAAAAAA"; |
+ std::string compressed = Compress(source); |
+ std::string decompressed = Decompress(compressed); |
+ EXPECT_EQ((int)compressed.size(), |
Kevin M
2016/05/24 01:02:01
nit: use static_cast<> instead of C-style cast.
shaktisahu
2016/05/24 21:02:45
Done.
|
+ blimp_connection_statistics_->Get( |
+ BlimpConnectionStatistics::BYTES_RECEIVED)); |
+ EXPECT_EQ((int)compressed.size(), blimp_connection_statistics_->Get( |
+ BlimpConnectionStatistics::BYTES_SENT)); |
Kevin M
2016/05/24 01:02:01
This formatting looks a little off, run git cl for
shaktisahu
2016/05/24 21:02:45
Done.
|
+} |
+ |
TEST_F(CompressedPacketTest, Simple) { |
std::string source = "AAAAAAAAAAAAAAAAAAAAAAAAA"; |
std::string compressed = Compress(source); |