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

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

Issue 1348523003: Revert "Populate EEP estimate in NQE" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 8
9 #include "base/test/histogram_tester.h"
10 #include "base/time/time.h" 9 #include "base/time/time.h"
11 #include "net/base/network_quality_estimator.h" 10 #include "net/base/network_quality_estimator.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 12
14 namespace { 13 namespace {
15 14
16 // Tests if the |ExternalEstimateProviderAndroid| APIs return false without the 15 // Tests if the |ExternalEstimateProviderAndroid| APIs return false without the
17 // downstream implementation. 16 // downstream implementation.
18 TEST(ExternalEstimateProviderAndroidTest, BasicsTest) { 17 TEST(ExternalEstimateProviderAndroidTest, BasicsTest) {
19 chrome::android::ExternalEstimateProviderAndroid external_estimate_provider; 18 chrome::android::ExternalEstimateProviderAndroid external_estimate_provider;
(...skipping 15 matching lines...) Expand all
35 TestNetworkQualityEstimator( 34 TestNetworkQualityEstimator(
36 scoped_ptr<chrome::android::ExternalEstimateProviderAndroid> 35 scoped_ptr<chrome::android::ExternalEstimateProviderAndroid>
37 external_estimate_provider, 36 external_estimate_provider,
38 const std::map<std::string, std::string>& variation_params) 37 const std::map<std::string, std::string>& variation_params)
39 : NetworkQualityEstimator(external_estimate_provider.Pass(), 38 : NetworkQualityEstimator(external_estimate_provider.Pass(),
40 variation_params), 39 variation_params),
41 notified_(false) {} 40 notified_(false) {}
42 41
43 ~TestNetworkQualityEstimator() override {} 42 ~TestNetworkQualityEstimator() override {}
44 43
45 void OnUpdatedEstimateAvailable() override { 44 void OnUpdatedEstimateAvailable() override { notified_ = true; }
46 notified_ = true;
47 net::NetworkQualityEstimator::OnUpdatedEstimateAvailable();
48 }
49 45
50 bool IsNotified() const { return notified_; } 46 bool IsNotified() const { return notified_; }
51 47
52 private: 48 private:
53 bool notified_; 49 bool notified_;
54 }; 50 };
55 51
56 class TestExternalEstimateProviderAndroid 52 class TestExternalEstimateProviderAndroid
57 : public chrome::android::ExternalEstimateProviderAndroid { 53 : public chrome::android::ExternalEstimateProviderAndroid {
58 public: 54 public:
59 TestExternalEstimateProviderAndroid() 55 TestExternalEstimateProviderAndroid()
60 : chrome::android::ExternalEstimateProviderAndroid() {} 56 : chrome::android::ExternalEstimateProviderAndroid() {}
61 ~TestExternalEstimateProviderAndroid() override {} 57 ~TestExternalEstimateProviderAndroid() override {}
62 using ExternalEstimateProviderAndroid::NotifyUpdatedEstimateAvailable; 58 using ExternalEstimateProviderAndroid::NotifyUpdatedEstimateAvailable;
63
64 bool GetTimeSinceLastUpdate(
65 base::TimeDelta* time_since_last_update) const override {
66 *time_since_last_update = base::TimeDelta::FromMilliseconds(1);
67 return true;
68 }
69 }; 59 };
70 60
71 // Tests if the |ExternalEstimateProviderAndroid| notifies 61 // Tests if the |ExternalEstimateProviderAndroid| notifies
72 // |NetworkQualityEstimator|. 62 // |NetworkQualityEstimator|.
73 TEST(ExternalEstimateProviderAndroidTest, DelegateTest) { 63 TEST(ExternalEstimateProviderAndroidTest, DelegateTest) {
74 base::HistogramTester histogram_tester;
75 scoped_ptr<TestExternalEstimateProviderAndroid> external_estimate_provider; 64 scoped_ptr<TestExternalEstimateProviderAndroid> external_estimate_provider;
76 external_estimate_provider.reset(new TestExternalEstimateProviderAndroid()); 65 external_estimate_provider.reset(new TestExternalEstimateProviderAndroid());
77 66
78 TestExternalEstimateProviderAndroid* ptr = external_estimate_provider.get(); 67 TestExternalEstimateProviderAndroid* ptr = external_estimate_provider.get();
79 std::map<std::string, std::string> variation_params; 68 std::map<std::string, std::string> variation_params;
80 TestNetworkQualityEstimator network_quality_estimator( 69 TestNetworkQualityEstimator network_quality_estimator(
81 external_estimate_provider.Pass(), variation_params); 70 external_estimate_provider.Pass(), variation_params);
82 ptr->NotifyUpdatedEstimateAvailable(); 71 ptr->NotifyUpdatedEstimateAvailable();
83 DCHECK(network_quality_estimator.IsNotified()); 72 DCHECK(network_quality_estimator.IsNotified());
84
85 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE
86 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 0,
87 0);
88
89 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE
90 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 1,
91 1);
92
93 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED
94 // Updated once during NetworkQualityEstimator constructor and again,
95 // when |OnUpdatedEstimateAvailable| is called.
96 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 2,
97 2);
98
99 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL
100 // Updated once during NetworkQualityEstimator constructor and again,
101 // when |OnUpdatedEstimateAvailable| is called.
102 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 3,
103 2);
104
105 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK
106 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 4,
107 1);
108
109 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 6);
110 } 73 }
111 74
112 } // namespace 75 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/android/net/external_estimate_provider_android.cc ('k') | net/base/external_estimate_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698