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

Side by Side Diff: chrome/browser/metrics/variations/resource_request_allowed_notifier_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/metrics/variations/resource_request_allowed_notifier_te st_util.h" 5 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier_te st_util.h"
6 #include "chrome/common/chrome_notification_types.h" 6 #include "chrome/common/chrome_notification_types.h"
7 #include "chrome/test/base/testing_browser_process.h" 7 #include "chrome/test/base/testing_browser_process.h"
8 #include "chrome/test/base/testing_pref_service.h" 8 #include "chrome/test/base/testing_pref_service.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 // Override NetworkChangeNotifier to simulate connection type changes for tests. 13 // Override NetworkChangeNotifier to simulate connection type changes for tests.
14 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier { 14 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier {
15 public: 15 public:
16 TestNetworkChangeNotifier() 16 TestNetworkChangeNotifier()
17 : net::NetworkChangeNotifier(), 17 : net::NetworkChangeNotifier(),
18 connection_type_to_return_( 18 connection_type_to_return_(
19 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) { 19 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) {
20 } 20 }
21 21
22 // Simulates a change of the connection type to |type|. This will notify any 22 // Simulates a change of the connection type to |type|. This will notify any
23 // objects that are NetworkChangeNotifiers. 23 // objects that are NetworkChangeNotifiers.
24 void SimulateNetworkConnectionChange( 24 void SimulateNetworkConnectionChange(
25 net::NetworkChangeNotifier::ConnectionType type) { 25 net::NetworkChangeNotifier::ConnectionType type) {
26 connection_type_to_return_ = type; 26 connection_type_to_return_ = type;
27 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); 27 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange();
28 MessageLoop::current()->RunAllPending(); 28 MessageLoop::current()->RunUntilIdle();
29 } 29 }
30 30
31 private: 31 private:
32 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE { 32 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE {
33 return connection_type_to_return_; 33 return connection_type_to_return_;
34 } 34 }
35 35
36 // The currently simulated network connection type. If this is set to 36 // The currently simulated network connection type. If this is set to
37 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true. 37 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true.
38 net::NetworkChangeNotifier::ConnectionType connection_type_to_return_; 38 net::NetworkChangeNotifier::ConnectionType connection_type_to_return_;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 DisableEulaAndNetwork(); 235 DisableEulaAndNetwork();
236 236
237 SimulateNetworkConnectionChange( 237 SimulateNetworkConnectionChange(
238 net::NetworkChangeNotifier::CONNECTION_WIFI); 238 net::NetworkChangeNotifier::CONNECTION_WIFI);
239 EXPECT_FALSE(was_notified()); 239 EXPECT_FALSE(was_notified());
240 240
241 SimulateEulaAccepted(); 241 SimulateEulaAccepted();
242 EXPECT_FALSE(was_notified()); 242 EXPECT_FALSE(was_notified());
243 } 243 }
244 #endif // OS_CHROMEOS 244 #endif // OS_CHROMEOS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698