summaryrefslogtreecommitdiffstats
path: root/chrome/browser/android/net/external_estimate_provider_android_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/android/net/external_estimate_provider_android_unittest.cc')
-rw-r--r--chrome/browser/android/net/external_estimate_provider_android_unittest.cc39
1 files changed, 38 insertions, 1 deletions
diff --git a/chrome/browser/android/net/external_estimate_provider_android_unittest.cc b/chrome/browser/android/net/external_estimate_provider_android_unittest.cc
index 26d9d10..1c80b09 100644
--- a/chrome/browser/android/net/external_estimate_provider_android_unittest.cc
+++ b/chrome/browser/android/net/external_estimate_provider_android_unittest.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
+#include "base/test/histogram_tester.h"
#include "base/time/time.h"
#include "net/base/network_quality_estimator.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -41,7 +42,10 @@ class TestNetworkQualityEstimator : public net::NetworkQualityEstimator {
~TestNetworkQualityEstimator() override {}
- void OnUpdatedEstimateAvailable() override { notified_ = true; }
+ void OnUpdatedEstimateAvailable() override {
+ notified_ = true;
+ net::NetworkQualityEstimator::OnUpdatedEstimateAvailable();
+ }
bool IsNotified() const { return notified_; }
@@ -56,11 +60,18 @@ class TestExternalEstimateProviderAndroid
: chrome::android::ExternalEstimateProviderAndroid() {}
~TestExternalEstimateProviderAndroid() override {}
using ExternalEstimateProviderAndroid::NotifyUpdatedEstimateAvailable;
+
+ bool GetTimeSinceLastUpdate(
+ base::TimeDelta* time_since_last_update) const override {
+ *time_since_last_update = base::TimeDelta::FromMilliseconds(1);
+ return true;
+ }
};
// Tests if the |ExternalEstimateProviderAndroid| notifies
// |NetworkQualityEstimator|.
TEST(ExternalEstimateProviderAndroidTest, DelegateTest) {
+ base::HistogramTester histogram_tester;
scoped_ptr<TestExternalEstimateProviderAndroid> external_estimate_provider;
external_estimate_provider.reset(new TestExternalEstimateProviderAndroid());
@@ -70,6 +81,32 @@ TEST(ExternalEstimateProviderAndroidTest, DelegateTest) {
external_estimate_provider.Pass(), variation_params);
ptr->NotifyUpdatedEstimateAvailable();
DCHECK(network_quality_estimator.IsNotified());
+
+ // EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE
+ histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 0,
+ 0);
+
+ // EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE
+ histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 1,
+ 1);
+
+ // EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED
+ // Updated once during NetworkQualityEstimator constructor and again,
+ // when |OnUpdatedEstimateAvailable| is called.
+ histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 2,
+ 2);
+
+ // EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL
+ // Updated once during NetworkQualityEstimator constructor and again,
+ // when |OnUpdatedEstimateAvailable| is called.
+ histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 3,
+ 2);
+
+ // EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK
+ histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 4,
+ 1);
+
+ histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 6);
}
} // namespace