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

Unified Diff: components/data_usage/android/traffic_stats_amortizer_unittest.cc

Issue 1390993005: Amortize data usage using TrafficStats on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_buffering
Patch Set: Created 5 years, 2 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: components/data_usage/android/traffic_stats_amortizer_unittest.cc
diff --git a/components/data_usage/android/traffic_stats_amortizer_unittest.cc b/components/data_usage/android/traffic_stats_amortizer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..250106be0c579bc63fbfdc98143925c64373cbbd
--- /dev/null
+++ b/components/data_usage/android/traffic_stats_amortizer_unittest.cc
@@ -0,0 +1,65 @@
+// Copyright 2015 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 "components/data_usage/android/traffic_stats_amortizer.h"
+
+#include <stdint.h>
+
+#include <vector>
+
+#include "components/data_usage/core/data_use.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+namespace data_usage {
+namespace android {
+
+namespace {
+
+class TestTrafficStatsAmortizer : public TrafficStatsAmortizer {
+ public:
+ TestTrafficStatsAmortizer()
+ : next_is_tx_bytes_available_(false),
+ next_tx_bytes_(0),
+ next_is_rx_bytes_available_(false),
+ next_rx_bytes_(0) {}
+
+ ~TestTrafficStatsAmortizer() override {}
+
+ void SetNextTxBytesResult(bool available, int64_t tx_bytes) {
+ next_is_tx_bytes_available_ = available;
+ next_tx_bytes_ = tx_bytes;
+ }
+
+ void SetNextRxBytesResult(bool available, int64_t rx_bytes) {
+ next_is_rx_bytes_available_ = available;
+ next_rx_bytes_ = rx_bytes;
+ }
+
+ protected:
+ bool GetTrafficStatsTxBytes(int64_t* tx_bytes) const override {
+ *tx_bytes = next_tx_bytes_;
+ return next_is_tx_bytes_available_;
+ }
+
+ bool GetTrafficStatsRxBytes(int64_t* rx_bytes) const override {
+ *rx_bytes = next_rx_bytes_;
+ return next_is_rx_bytes_available_;
+ }
+
+ private:
+ bool next_is_tx_bytes_available_;
+ int64_t next_tx_bytes_;
+ bool next_is_rx_bytes_available_;
+ int64_t next_rx_bytes_;
+};
+
+TEST(TrafficStatsAmortizerTest, TrafficStatsUnavailable) {
+ // TODO in this CL: Write tests.
+}
+
+} // namespace
+
+} // namespace android
+} // namespace data_usage

Powered by Google App Engine
This is Rietveld 408576698