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

Unified Diff: chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged to ToT Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
index 7d8a0c5bef849235485c35afe2ee09a4f975b01b..f82ef6be55b3898b125ad6d845d88348d2ca8304 100644
--- a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
+++ b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
@@ -5,7 +5,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
+#include "base/run_loop.h"
#include "chrome/browser/captive_portal/captive_portal_detector.h"
#include "chrome/browser/captive_portal/testing_utils.h"
#include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
@@ -15,6 +15,7 @@
#include "chromeos/dbus/shill_service_client.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "dbus/object_path.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -40,10 +41,7 @@ const char* kStubCellular = "stub_cellular";
class NetworkPortalDetectorImplTest
: public testing::Test,
public captive_portal::CaptivePortalDetectorTestBase {
- public:
- NetworkPortalDetectorImplTest() {}
- virtual ~NetworkPortalDetectorImplTest() {}
-
+ protected:
virtual void SetUp() {
DBusThreadManager::InitializeWithStub();
SetupNetworkHandler();
@@ -166,13 +164,13 @@ class NetworkPortalDetectorImplTest
dbus::ObjectPath(service_path),
flimflam::kStateProperty, base::StringValue(flimflam::kStatePortal),
base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
void SetNetworkDeviceEnabled(const std::string& type, bool enabled) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
type, enabled, network_handler::ErrorCallback());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
void SetConnected(const std::string& service_path) {
@@ -180,12 +178,12 @@ class NetworkPortalDetectorImplTest
dbus::ObjectPath(service_path),
flimflam::kStateProperty, base::StringValue(flimflam::kStateOnline),
base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
private:
void SetupDefaultShillState() {
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
ShillServiceClient::TestInterface* service_test =
DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
service_test->ClearServices();
@@ -214,7 +212,7 @@ class NetworkPortalDetectorImplTest
NetworkHandler::Initialize();
}
- base::MessageLoop message_loop_;
+ content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<TestingProfile> profile_;
scoped_ptr<NetworkPortalDetectorImpl> network_portal_detector_;
};
@@ -377,7 +375,7 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectionTimeout) {
ASSERT_EQ(0, attempt_count());
SetConnected(kStubWireless1);
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// First portal detection timeouts, next portal detection is
// scheduled.
@@ -440,7 +438,7 @@ TEST_F(NetworkPortalDetectorImplTest, FirstAttemptFailed) {
ASSERT_EQ(base::TimeDelta::FromSeconds(0), next_attempt_delay());
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 204, NULL);
ASSERT_TRUE(is_state_idle());
@@ -466,7 +464,7 @@ TEST_F(NetworkPortalDetectorImplTest, AllAttemptsFailed) {
ASSERT_EQ(base::TimeDelta::FromSeconds(0), next_attempt_delay());
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 503, retry_after);
ASSERT_TRUE(is_state_portal_detection_pending());
@@ -474,7 +472,7 @@ TEST_F(NetworkPortalDetectorImplTest, AllAttemptsFailed) {
ASSERT_EQ(base::TimeDelta::FromSeconds(0), next_attempt_delay());
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 503, retry_after);
ASSERT_TRUE(is_state_idle());
@@ -495,7 +493,7 @@ TEST_F(NetworkPortalDetectorImplTest, ProxyAuthRequired) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 407, NULL);
ASSERT_EQ(2, attempt_count());
@@ -504,7 +502,7 @@ TEST_F(NetworkPortalDetectorImplTest, ProxyAuthRequired) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 407, NULL);
ASSERT_EQ(3, attempt_count());
@@ -528,7 +526,7 @@ TEST_F(NetworkPortalDetectorImplTest, NoResponseButBehindPortal) {
ASSERT_TRUE(is_state_portal_detection_pending());
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID,
@@ -537,7 +535,7 @@ TEST_F(NetworkPortalDetectorImplTest, NoResponseButBehindPortal) {
ASSERT_TRUE(is_state_portal_detection_pending());
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID,
@@ -566,7 +564,7 @@ TEST_F(NetworkPortalDetectorImplTest, LazyDetectionForOnlineNetwork) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 204, NULL);
@@ -577,7 +575,7 @@ TEST_F(NetworkPortalDetectorImplTest, LazyDetectionForOnlineNetwork) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
disable_lazy_detection();
@@ -608,7 +606,7 @@ TEST_F(NetworkPortalDetectorImplTest, LazyDetectionForPortalNetwork) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID,
@@ -619,7 +617,7 @@ TEST_F(NetworkPortalDetectorImplTest, LazyDetectionForPortalNetwork) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 200, NULL);
ASSERT_EQ(3, attempt_count());
@@ -628,7 +626,7 @@ TEST_F(NetworkPortalDetectorImplTest, LazyDetectionForPortalNetwork) {
kStubWireless1);
// To run CaptivePortalDetector::DetectCaptivePortal().
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
disable_lazy_detection();
@@ -678,7 +676,7 @@ TEST_F(NetworkPortalDetectorImplTest, TestDetectionRestart) {
ASSERT_TRUE(is_state_portal_detection_pending());
ASSERT_FALSE(start_detection_if_idle());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
ASSERT_TRUE(is_state_checking_for_portal());
CompleteURLFetch(net::OK, 200, NULL);
@@ -701,13 +699,13 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) {
// Second portal detection attempt for cellular1 uses 10sec timeout.
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CheckRequestTimeoutAndCompleteAttempt(2, 10, net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID);
// Third portal detection attempt for cellular1 uses 15sec timeout.
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CheckRequestTimeoutAndCompleteAttempt(3, 15, net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID);
@@ -716,7 +714,7 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) {
// Check that in lazy detection for cellular1 15sec timeout is used.
enable_lazy_detection();
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
disable_lazy_detection();
CheckRequestTimeoutAndCompleteAttempt(3, 15, net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID);
@@ -731,14 +729,14 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) {
// Second portal detection attempt for wifi1 also uses 5sec timeout.
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CheckRequestTimeoutAndCompleteAttempt(2, 10, net::OK, 204);
ASSERT_TRUE(is_state_idle());
// Check that in lazy detection for wifi1 5sec timeout is used.
enable_lazy_detection();
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
disable_lazy_detection();
CheckRequestTimeoutAndCompleteAttempt(3, 15, net::OK, 204);
ASSERT_TRUE(is_state_idle());
@@ -753,13 +751,13 @@ TEST_F(NetworkPortalDetectorImplTest, StartDetectionIfIdle) {
CheckRequestTimeoutAndCompleteAttempt(1, 5, net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID);
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// Second portal detection attempt for wifi1 uses 10sec timeout.
CheckRequestTimeoutAndCompleteAttempt(2, 10, net::ERR_CONNECTION_CLOSED,
net::URLFetcher::RESPONSE_CODE_INVALID);
ASSERT_TRUE(is_state_portal_detection_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// Second portal detection attempt for wifi1 uses 15sec timeout.
CheckRequestTimeoutAndCompleteAttempt(3, 15, net::ERR_CONNECTION_CLOSED,
@@ -770,7 +768,7 @@ TEST_F(NetworkPortalDetectorImplTest, StartDetectionIfIdle) {
ASSERT_TRUE(is_state_portal_detection_pending());
// First portal detection attempt for wifi1 uses 5sec timeout.
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
CheckRequestTimeoutAndCompleteAttempt(1, 5, net::OK, 204);
ASSERT_TRUE(is_state_idle());
}

Powered by Google App Engine
This is Rietveld 408576698