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

Unified Diff: blimp/net/blimp_connection_statistics_unittest.cc

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Kevin's comments Created 4 years, 7 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
Index: blimp/net/blimp_connection_statistics_unittest.cc
diff --git a/blimp/net/blimp_connection_statistics_unittest.cc b/blimp/net/blimp_connection_statistics_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..46d896850644a95e53f852995877e283e65644e2
--- /dev/null
+++ b/blimp/net/blimp_connection_statistics_unittest.cc
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <blimp/net/blimp_connection_statistics.h>
Kevin M 2016/05/20 01:02:04 No angle brackets for non-standard headers
shaktisahu 2016/05/22 22:36:57 Done.
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/threading/thread.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::_;
+
+namespace blimp {
+
+class BlimpConnectionStatisticsTest : public testing::Test {
+ public:
+ BlimpConnectionStatisticsTest()
+ : stats_(new BlimpConnectionStatistics(message_loop_.task_runner())) {}
+
+ ~BlimpConnectionStatisticsTest() override {}
+
+ MOCK_METHOD1(UpdateDebugInfoCallback,
+ void(BlimpConnectionStatistics::StatisticsMap));
+
+ protected:
+ base::MessageLoop message_loop_;
+ std::unique_ptr<BlimpConnectionStatistics> stats_;
Kevin M 2016/05/20 01:02:04 DISALLOW_COPY_AND_ASSIGN()
shaktisahu 2016/05/22 22:36:57 Done.
+};
+
+TEST_F(BlimpConnectionStatisticsTest, AddStatsAndVerify) {
+ stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 10);
+ stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 20);
+ stats_->Add(BlimpConnectionStatistics::BYTES_RECEIVED, 5);
+ stats_->Increment(BlimpConnectionStatistics::COMMIT);
+ base::RunLoop().RunUntilIdle();
+
+ BlimpConnectionStatistics::StatisticsMap map;
+ map[BlimpConnectionStatistics::BYTES_SENT] = 30;
+ map[BlimpConnectionStatistics::BYTES_RECEIVED] = 5;
+ map[BlimpConnectionStatistics::COMMIT] = 1;
+
+ EXPECT_CALL(*this, UpdateDebugInfoCallback(map));
+ stats_->GetDebugInfo(
+ base::Bind(&BlimpConnectionStatisticsTest::UpdateDebugInfoCallback,
+ base::Unretained(this)));
+}
+
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698