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

Side by Side Diff: components/translate/core/browser/translate_manager_unittest.cc

Issue 2053913002: Remove MessageLoop::current()->RunUntilIdle() in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 "components/translate/core/browser/translate_manager.h" 5 #include "components/translate/core/browser/translate_manager.h"
6 6
7 #include "base/run_loop.h"
7 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
8 #include "build/build_config.h" 9 #include "build/build_config.h"
9 #include "components/infobars/core/infobar.h" 10 #include "components/infobars/core/infobar.h"
10 #include "components/pref_registry/pref_registry_syncable.h" 11 #include "components/pref_registry/pref_registry_syncable.h"
11 #include "components/pref_registry/testing_pref_service_syncable.h" 12 #include "components/pref_registry/testing_pref_service_syncable.h"
12 #include "components/translate/core/browser/mock_translate_driver.h" 13 #include "components/translate/core/browser/mock_translate_driver.h"
13 #include "components/translate/core/browser/translate_browser_metrics.h" 14 #include "components/translate/core/browser/translate_browser_metrics.h"
14 #include "components/translate/core/browser/translate_client.h" 15 #include "components/translate/core/browser/translate_client.h"
15 #include "components/translate/core/browser/translate_download_manager.h" 16 #include "components/translate/core/browser/translate_download_manager.h"
16 #include "components/translate/core/browser/translate_prefs.h" 17 #include "components/translate/core/browser/translate_prefs.h"
(...skipping 23 matching lines...) Expand all
40 connection_type_to_return_( 41 connection_type_to_return_(
41 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) {} 42 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) {}
42 43
43 // Simulates a change of the connection type to |type|. This will notify any 44 // Simulates a change of the connection type to |type|. This will notify any
44 // objects that are NetworkChangeNotifiers. 45 // objects that are NetworkChangeNotifiers.
45 void SimulateNetworkConnectionChange( 46 void SimulateNetworkConnectionChange(
46 net::NetworkChangeNotifier::ConnectionType type) { 47 net::NetworkChangeNotifier::ConnectionType type) {
47 connection_type_to_return_ = type; 48 connection_type_to_return_ = type;
48 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests( 49 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests(
49 connection_type_to_return_); 50 connection_type_to_return_);
50 base::MessageLoop::current()->RunUntilIdle(); 51 base::RunLoop().RunUntilIdle();
51 } 52 }
52 53
53 void SimulateOffline() { 54 void SimulateOffline() {
54 connection_type_to_return_ =net::NetworkChangeNotifier::CONNECTION_NONE; 55 connection_type_to_return_ =net::NetworkChangeNotifier::CONNECTION_NONE;
55 } 56 }
56 57
57 void SimulateOnline() { 58 void SimulateOnline() {
58 connection_type_to_return_ = net::NetworkChangeNotifier::CONNECTION_UNKNOWN; 59 connection_type_to_return_ = net::NetworkChangeNotifier::CONNECTION_UNKNOWN;
59 } 60 }
60 61
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // In the online case, InitiateTranslation will proceed past early out tests. 219 // In the online case, InitiateTranslation will proceed past early out tests.
219 network_notifier_.SimulateOnline(); 220 network_notifier_.SimulateOnline();
220 translate_manager_->InitiateTranslation("de"); 221 translate_manager_->InitiateTranslation("de");
221 histogram_tester.ExpectUniqueSample( 222 histogram_tester.ExpectUniqueSample(
222 kMetricName, 223 kMetricName,
223 translate::TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_PREFS, 224 translate::TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_PREFS,
224 1); 225 1);
225 } 226 }
226 227
227 } // namespace translate 228 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698