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

Side by Side Diff: chrome/browser/net/nqe/ui_network_quality_estimator_service_browsertest.cc

Issue 2742293004: Expose getters methods for NQE on UI thread (Closed)
Patch Set: ryansturm comments Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 UINetworkQualityEstimatorService* nqe_service = 250 UINetworkQualityEstimatorService* nqe_service =
251 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile); 251 UINetworkQualityEstimatorServiceFactory::GetForProfile(profile);
252 TestRTTAndThroughputEstimatesObserver nqe_observer; 252 TestRTTAndThroughputEstimatesObserver nqe_observer;
253 nqe_service->AddRTTAndThroughputEstimatesObserver(&nqe_observer); 253 nqe_service->AddRTTAndThroughputEstimatesObserver(&nqe_observer);
254 254
255 base::TimeDelta rtt_1 = base::TimeDelta::FromMilliseconds(100); 255 base::TimeDelta rtt_1 = base::TimeDelta::FromMilliseconds(100);
256 256
257 nqe_test_util::OverrideRTTsAndWait(rtt_1); 257 nqe_test_util::OverrideRTTsAndWait(rtt_1);
258 EXPECT_EQ(rtt_1, nqe_observer.http_rtt()); 258 EXPECT_EQ(rtt_1, nqe_observer.http_rtt());
259 259
260 EXPECT_EQ(rtt_1, nqe_service->GetHttpRTT());
261 EXPECT_EQ(rtt_1, nqe_service->GetTransportRTT());
262 EXPECT_FALSE(nqe_service->GetDownstreamThroughputKbps().has_value());
263
260 base::TimeDelta rtt_2 = base::TimeDelta::FromMilliseconds(200); 264 base::TimeDelta rtt_2 = base::TimeDelta::FromMilliseconds(200);
261 265
262 nqe_test_util::OverrideRTTsAndWait(rtt_2); 266 nqe_test_util::OverrideRTTsAndWait(rtt_2);
263 EXPECT_EQ(rtt_2, nqe_observer.http_rtt()); 267 EXPECT_EQ(rtt_2, nqe_observer.http_rtt());
264 268
269 EXPECT_EQ(rtt_2, nqe_service->GetHttpRTT());
270 EXPECT_EQ(rtt_2, nqe_service->GetTransportRTT());
271 EXPECT_FALSE(nqe_service->GetDownstreamThroughputKbps().has_value());
272
265 nqe_service->RemoveRTTAndThroughputEstimatesObserver(&nqe_observer); 273 nqe_service->RemoveRTTAndThroughputEstimatesObserver(&nqe_observer);
266 274
267 base::TimeDelta rtt_3 = base::TimeDelta::FromMilliseconds(300); 275 base::TimeDelta rtt_3 = base::TimeDelta::FromMilliseconds(300);
268 276
269 nqe_test_util::OverrideRTTsAndWait(rtt_3); 277 nqe_test_util::OverrideRTTsAndWait(rtt_3);
270 EXPECT_EQ(rtt_2, nqe_observer.http_rtt()); 278 EXPECT_EQ(rtt_2, nqe_observer.http_rtt());
271 279
280 EXPECT_EQ(rtt_3, nqe_service->GetHttpRTT());
281 EXPECT_EQ(rtt_3, nqe_service->GetTransportRTT());
282 EXPECT_FALSE(nqe_service->GetDownstreamThroughputKbps().has_value());
283
272 // Observer should be notified on addition. 284 // Observer should be notified on addition.
273 TestRTTAndThroughputEstimatesObserver nqe_observer_2; 285 TestRTTAndThroughputEstimatesObserver nqe_observer_2;
274 nqe_service->AddRTTAndThroughputEstimatesObserver(&nqe_observer_2); 286 nqe_service->AddRTTAndThroughputEstimatesObserver(&nqe_observer_2);
275 EXPECT_GT(0, nqe_observer_2.http_rtt().InMilliseconds()); 287 EXPECT_GT(0, nqe_observer_2.http_rtt().InMilliseconds());
276 base::RunLoop().RunUntilIdle(); 288 base::RunLoop().RunUntilIdle();
277 EXPECT_EQ(rtt_3, nqe_observer_2.http_rtt()); 289 EXPECT_EQ(rtt_3, nqe_observer_2.http_rtt());
278 290
279 // |nqe_observer_3| should be not notified since it unregisters before the 291 // |nqe_observer_3| should be not notified since it unregisters before the
280 // message loop is run. 292 // message loop is run.
281 TestRTTAndThroughputEstimatesObserver nqe_observer_3; 293 TestRTTAndThroughputEstimatesObserver nqe_observer_3;
282 nqe_service->AddRTTAndThroughputEstimatesObserver(&nqe_observer_3); 294 nqe_service->AddRTTAndThroughputEstimatesObserver(&nqe_observer_3);
283 EXPECT_GT(0, nqe_observer_3.http_rtt().InMilliseconds()); 295 EXPECT_GT(0, nqe_observer_3.http_rtt().InMilliseconds());
284 nqe_service->RemoveRTTAndThroughputEstimatesObserver(&nqe_observer_3); 296 nqe_service->RemoveRTTAndThroughputEstimatesObserver(&nqe_observer_3);
285 base::RunLoop().RunUntilIdle(); 297 base::RunLoop().RunUntilIdle();
286 EXPECT_GT(0, nqe_observer_3.http_rtt().InMilliseconds()); 298 EXPECT_GT(0, nqe_observer_3.http_rtt().InMilliseconds());
287 } 299 }
288 300
289 // Verify that prefs are writen and read correctly. 301 // Verify that prefs are writen and read correctly.
290 IN_PROC_BROWSER_TEST_F(UINetworkQualityEstimatorServiceBrowserTest, 302 IN_PROC_BROWSER_TEST_F(UINetworkQualityEstimatorServiceBrowserTest,
291 WritingReadingToPrefsEnabled) { 303 WritingReadingToPrefsEnabled) {
292 VerifyWritingReadingPrefs(); 304 VerifyWritingReadingPrefs();
293 } 305 }
OLDNEW
« no previous file with comments | « chrome/browser/net/nqe/ui_network_quality_estimator_service.cc ('k') | net/nqe/network_quality_estimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698