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

Side by Side Diff: chrome/browser/android/net/external_estimate_provider_android_unittest.cc

Issue 2593243003: Add network quality change events to net log (Closed)
Patch Set: ps Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/io_thread.cc » ('j') | net/nqe/event_creator.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/net/external_estimate_provider_android.h" 5 #include "chrome/browser/android/net/external_estimate_provider_android.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/memory/ptr_util.h"
RyanSturm 2017/01/10 16:22:37 Not seeing where ptr_util is used.
tbansal1 2017/01/10 18:27:52 Done.
11 #include "base/test/histogram_tester.h" 12 #include "base/test/histogram_tester.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "net/log/test_net_log.h"
14 #include "net/nqe/network_quality_estimator.h" 16 #include "net/nqe/network_quality_estimator.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 namespace { 19 namespace {
18 20
19 // Tests if the |ExternalEstimateProviderAndroid| APIs return false without the 21 // Tests if the |ExternalEstimateProviderAndroid| APIs return false without the
20 // downstream implementation. 22 // downstream implementation.
21 TEST(ExternalEstimateProviderAndroidTest, BasicsTest) { 23 TEST(ExternalEstimateProviderAndroidTest, BasicsTest) {
22 base::ShadowingAtExitManager at_exit_manager; 24 base::ShadowingAtExitManager at_exit_manager;
23 chrome::android::ExternalEstimateProviderAndroid external_estimate_provider; 25 chrome::android::ExternalEstimateProviderAndroid external_estimate_provider;
24 26
25 base::TimeDelta rtt; 27 base::TimeDelta rtt;
26 EXPECT_FALSE(external_estimate_provider.GetRTT(&rtt)); 28 EXPECT_FALSE(external_estimate_provider.GetRTT(&rtt));
27 29
28 int32_t kbps; 30 int32_t kbps;
29 EXPECT_FALSE(external_estimate_provider.GetDownstreamThroughputKbps(&kbps)); 31 EXPECT_FALSE(external_estimate_provider.GetDownstreamThroughputKbps(&kbps));
30 EXPECT_FALSE(external_estimate_provider.GetUpstreamThroughputKbps(&kbps)); 32 EXPECT_FALSE(external_estimate_provider.GetUpstreamThroughputKbps(&kbps));
31 33
32 base::TimeDelta time_since_last_update; 34 base::TimeDelta time_since_last_update;
33 EXPECT_FALSE(external_estimate_provider.GetTimeSinceLastUpdate( 35 EXPECT_FALSE(external_estimate_provider.GetTimeSinceLastUpdate(
34 &time_since_last_update)); 36 &time_since_last_update));
35 } 37 }
36 38
37 class TestNetworkQualityEstimator : public net::NetworkQualityEstimator { 39 class TestNetworkQualityEstimator : public net::NetworkQualityEstimator {
38 public: 40 public:
39 TestNetworkQualityEstimator( 41 TestNetworkQualityEstimator(
40 std::unique_ptr<chrome::android::ExternalEstimateProviderAndroid> 42 std::unique_ptr<chrome::android::ExternalEstimateProviderAndroid>
41 external_estimate_provider, 43 external_estimate_provider,
42 const std::map<std::string, std::string>& variation_params) 44 const std::map<std::string, std::string>& variation_params,
45 net::NetLog* net_log)
43 : NetworkQualityEstimator(std::move(external_estimate_provider), 46 : NetworkQualityEstimator(std::move(external_estimate_provider),
44 variation_params), 47 variation_params,
48 net_log),
45 notified_(false) {} 49 notified_(false) {}
46 50
47 ~TestNetworkQualityEstimator() override {} 51 ~TestNetworkQualityEstimator() override {}
48 52
49 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, 53 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt,
50 int32_t downstream_throughput_kbps, 54 int32_t downstream_throughput_kbps,
51 int32_t upstream_throughput_kbps) override { 55 int32_t upstream_throughput_kbps) override {
52 EXPECT_EQ(base::TimeDelta(), rtt); 56 EXPECT_EQ(base::TimeDelta(), rtt);
53 EXPECT_EQ(-1, downstream_throughput_kbps); 57 EXPECT_EQ(-1, downstream_throughput_kbps);
54 EXPECT_EQ(-1, upstream_throughput_kbps); 58 EXPECT_EQ(-1, upstream_throughput_kbps);
(...skipping 29 matching lines...) Expand all
84 content::TestBrowserThreadBundle thread_bundle( 88 content::TestBrowserThreadBundle thread_bundle(
85 content::TestBrowserThreadBundle::IO_MAINLOOP); 89 content::TestBrowserThreadBundle::IO_MAINLOOP);
86 90
87 base::ShadowingAtExitManager at_exit_manager; 91 base::ShadowingAtExitManager at_exit_manager;
88 base::HistogramTester histogram_tester; 92 base::HistogramTester histogram_tester;
89 std::unique_ptr<TestExternalEstimateProviderAndroid> 93 std::unique_ptr<TestExternalEstimateProviderAndroid>
90 external_estimate_provider; 94 external_estimate_provider;
91 external_estimate_provider.reset(new TestExternalEstimateProviderAndroid()); 95 external_estimate_provider.reset(new TestExternalEstimateProviderAndroid());
92 96
93 TestExternalEstimateProviderAndroid* ptr = external_estimate_provider.get(); 97 TestExternalEstimateProviderAndroid* ptr = external_estimate_provider.get();
98 net::TestNetLog net_log;
94 std::map<std::string, std::string> variation_params; 99 std::map<std::string, std::string> variation_params;
95 TestNetworkQualityEstimator network_quality_estimator( 100 TestNetworkQualityEstimator network_quality_estimator(
96 std::move(external_estimate_provider), variation_params); 101 std::move(external_estimate_provider), variation_params, &net_log);
97 ptr->NotifyUpdatedEstimateAvailable(); 102 ptr->NotifyUpdatedEstimateAvailable();
98 EXPECT_TRUE(network_quality_estimator.notified()); 103 EXPECT_TRUE(network_quality_estimator.notified());
99 104
100 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 2); 105 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 2);
101 106
102 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE 107 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE
103 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 1, 108 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 1,
104 1); 109 1);
105 110
106 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK 111 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK
107 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 4, 112 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 4,
108 1); 113 1);
109 } 114 }
110 115
111 } // namespace 116 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/io_thread.cc » ('j') | net/nqe/event_creator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698