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

Unified Diff: google_apis/gcm/engine/connection_factory_impl_unittest.cc

Issue 206873006: [GCM] Add port 443 fallback logic and histograms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/engine/connection_factory_impl.cc ('k') | google_apis/gcm/gcm_client_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/engine/connection_factory_impl_unittest.cc
diff --git a/google_apis/gcm/engine/connection_factory_impl_unittest.cc b/google_apis/gcm/engine/connection_factory_impl_unittest.cc
index 82c3f18d9877c875b7622135ecd261f639945f9e..eebe14a9b0ad444e44f67975ec13a57293606f84 100644
--- a/google_apis/gcm/engine/connection_factory_impl_unittest.cc
+++ b/google_apis/gcm/engine/connection_factory_impl_unittest.cc
@@ -19,6 +19,7 @@ namespace gcm {
namespace {
const char kMCSEndpoint[] = "http://my.server";
+const char kMCSEndpoint2[] = "http://my.alt.server";
const int kBackoffDelayMs = 1;
const int kBackoffMultiplier = 2;
@@ -50,6 +51,13 @@ const net::BackoffEntry::Policy kTestBackoffPolicy = {
false,
};
+std::vector<GURL> BuildEndpoints() {
+ std::vector<GURL> endpoints;
+ endpoints.push_back(GURL(kMCSEndpoint));
+ endpoints.push_back(GURL(kMCSEndpoint2));
+ return endpoints;
+}
+
// Helper for calculating total expected exponential backoff delay given an
// arbitrary number of failed attempts. See BackoffEntry::CalculateReleaseTime.
double CalculateBackoff(int num_attempts) {
@@ -132,7 +140,7 @@ class TestConnectionFactoryImpl : public ConnectionFactoryImpl {
TestConnectionFactoryImpl::TestConnectionFactoryImpl(
const base::Closure& finished_callback)
- : ConnectionFactoryImpl(GURL(kMCSEndpoint),
+ : ConnectionFactoryImpl(BuildEndpoints(),
net::BackoffEntry::Policy(),
NULL,
NULL),
@@ -254,9 +262,11 @@ TEST_F(ConnectionFactoryImplTest, ConnectSuccess) {
factory()->SetConnectResult(net::OK);
factory()->Connect();
EXPECT_TRUE(factory()->NextRetryAttempt().is_null());
+ EXPECT_EQ(factory()->GetCurrentEndpoint(), BuildEndpoints()[0]);
}
-// A connection failure should result in backoff.
+// A connection failure should result in backoff, and attempting the fallback
+// endpoint next.
TEST_F(ConnectionFactoryImplTest, ConnectFail) {
factory()->Initialize(
ConnectionFactory::BuildLoginRequestCallback(),
@@ -265,6 +275,7 @@ TEST_F(ConnectionFactoryImplTest, ConnectFail) {
factory()->SetConnectResult(net::ERR_CONNECTION_FAILED);
factory()->Connect();
EXPECT_FALSE(factory()->NextRetryAttempt().is_null());
+ EXPECT_EQ(factory()->GetCurrentEndpoint(), BuildEndpoints()[1]);
}
// A connection success after a failure should reset backoff.
« no previous file with comments | « google_apis/gcm/engine/connection_factory_impl.cc ('k') | google_apis/gcm/gcm_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698