| OLD | NEW |
| 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/test/histogram_tester.h" | 11 #include "base/test/histogram_tester.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "net/base/network_quality_estimator.h" | 14 #include "net/base/network_quality_estimator.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Tests if the |ExternalEstimateProviderAndroid| APIs return false without the | 19 // Tests if the |ExternalEstimateProviderAndroid| APIs return false without the |
| 19 // downstream implementation. | 20 // downstream implementation. |
| 20 TEST(ExternalEstimateProviderAndroidTest, BasicsTest) { | 21 TEST(ExternalEstimateProviderAndroidTest, BasicsTest) { |
| 21 base::ShadowingAtExitManager at_exit_manager; | 22 base::ShadowingAtExitManager at_exit_manager; |
| 22 chrome::android::ExternalEstimateProviderAndroid external_estimate_provider; | 23 chrome::android::ExternalEstimateProviderAndroid external_estimate_provider; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 bool GetTimeSinceLastUpdate( | 68 bool GetTimeSinceLastUpdate( |
| 68 base::TimeDelta* time_since_last_update) const override { | 69 base::TimeDelta* time_since_last_update) const override { |
| 69 *time_since_last_update = base::TimeDelta::FromMilliseconds(1); | 70 *time_since_last_update = base::TimeDelta::FromMilliseconds(1); |
| 70 return true; | 71 return true; |
| 71 } | 72 } |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 // Tests if the |ExternalEstimateProviderAndroid| notifies | 75 // Tests if the |ExternalEstimateProviderAndroid| notifies |
| 75 // |NetworkQualityEstimator|. | 76 // |NetworkQualityEstimator|. |
| 76 TEST(ExternalEstimateProviderAndroidTest, DelegateTest) { | 77 TEST(ExternalEstimateProviderAndroidTest, DelegateTest) { |
| 78 content::TestBrowserThreadBundle thread_bundle( |
| 79 content::TestBrowserThreadBundle::IO_MAINLOOP); |
| 80 |
| 77 base::ShadowingAtExitManager at_exit_manager; | 81 base::ShadowingAtExitManager at_exit_manager; |
| 78 base::HistogramTester histogram_tester; | 82 base::HistogramTester histogram_tester; |
| 79 scoped_ptr<TestExternalEstimateProviderAndroid> external_estimate_provider; | 83 scoped_ptr<TestExternalEstimateProviderAndroid> external_estimate_provider; |
| 80 external_estimate_provider.reset(new TestExternalEstimateProviderAndroid()); | 84 external_estimate_provider.reset(new TestExternalEstimateProviderAndroid()); |
| 81 | 85 |
| 82 TestExternalEstimateProviderAndroid* ptr = external_estimate_provider.get(); | 86 TestExternalEstimateProviderAndroid* ptr = external_estimate_provider.get(); |
| 83 std::map<std::string, std::string> variation_params; | 87 std::map<std::string, std::string> variation_params; |
| 84 TestNetworkQualityEstimator network_quality_estimator( | 88 TestNetworkQualityEstimator network_quality_estimator( |
| 85 std::move(external_estimate_provider), variation_params); | 89 std::move(external_estimate_provider), variation_params); |
| 86 ptr->NotifyUpdatedEstimateAvailable(); | 90 ptr->NotifyUpdatedEstimateAvailable(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 107 2); | 111 2); |
| 108 | 112 |
| 109 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK | 113 // EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK |
| 110 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 4, | 114 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProviderStatus", 4, |
| 111 1); | 115 1); |
| 112 | 116 |
| 113 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 6); | 117 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 6); |
| 114 } | 118 } |
| 115 | 119 |
| 116 } // namespace | 120 } // namespace |
| OLD | NEW |