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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 "components/data_usage/android/traffic_stats_amortizer.h"
6
7 #include <stdint.h>
8
9 #include <vector>
10
11 #include "components/data_usage/core/data_use.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "url/gurl.h"
14
15 namespace data_usage {
16 namespace android {
17
18 namespace {
19
20 class TestTrafficStatsAmortizer : public TrafficStatsAmortizer {
21 public:
22 TestTrafficStatsAmortizer()
23 : next_is_tx_bytes_available_(false),
24 next_tx_bytes_(0),
25 next_is_rx_bytes_available_(false),
26 next_rx_bytes_(0) {}
27
28 ~TestTrafficStatsAmortizer() override {}
29
30 void SetNextTxBytesResult(bool available, int64_t tx_bytes) {
31 next_is_tx_bytes_available_ = available;
32 next_tx_bytes_ = tx_bytes;
33 }
34
35 void SetNextRxBytesResult(bool available, int64_t rx_bytes) {
36 next_is_rx_bytes_available_ = available;
37 next_rx_bytes_ = rx_bytes;
38 }
39
40 protected:
41 bool GetTrafficStatsTxBytes(int64_t* tx_bytes) const override {
42 *tx_bytes = next_tx_bytes_;
43 return next_is_tx_bytes_available_;
44 }
45
46 bool GetTrafficStatsRxBytes(int64_t* rx_bytes) const override {
47 *rx_bytes = next_rx_bytes_;
48 return next_is_rx_bytes_available_;
49 }
50
51 private:
52 bool next_is_tx_bytes_available_;
53 int64_t next_tx_bytes_;
54 bool next_is_rx_bytes_available_;
55 int64_t next_rx_bytes_;
56 };
57
58 TEST(TrafficStatsAmortizerTest, TrafficStatsUnavailable) {
59 // TODO in this CL: Write tests.
60 }
61
62 } // namespace
63
64 } // namespace android
65 } // namespace data_usage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698