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

Unified Diff: net/http/http_server_properties_impl_unittest.cc

Issue 1860343002: SHP 1: Change SupportsSpdy dict to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync Created 4 years, 8 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 | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_server_properties_impl_unittest.cc
diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc
index a4c1a59a050128d40d67a1ccfcdce65a0b148791..50368af0bff22e88542b6b4613d2d035900ca77a 100644
--- a/net/http/http_server_properties_impl_unittest.cc
+++ b/net/http/http_server_properties_impl_unittest.cc
@@ -14,6 +14,7 @@
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
namespace base {
class ListValue;
@@ -102,18 +103,44 @@ class HttpServerPropertiesImplTest : public testing::Test {
typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
+TEST_F(SpdyServerPropertiesTest, InitializeWithSchemeHostPort) {
+ // Check spdy servers are correctly set with SchemeHostPort key.
+ url::SchemeHostPort https_www_server("https", "www.google.com", 443);
+ url::SchemeHostPort http_photo_server("http", "photos.google.com", 80);
+ // Servers with port equal to default port in scheme will drop port components
+ // when calling Serialize().
+ std::string spdy_server_g = https_www_server.Serialize();
+ std::string spdy_server_p = http_photo_server.Serialize();
+
+ url::SchemeHostPort http_google_server("http", "www.google.com", 443);
+ url::SchemeHostPort https_photos_server("https", "photos.google.com", 443);
+ url::SchemeHostPort valid_google_server((GURL("https://www.google.com")));
+
+ // Initializing https://www.google.com:443 and https://photos.google.com:443
+ // as spdy servers.
+ std::vector<std::string> spdy_servers1;
+ spdy_servers1.push_back(spdy_server_g); // Will be 0th index.
+ spdy_servers1.push_back(spdy_server_p); // Will be 1st index.
+ impl_.InitializeSpdyServers(&spdy_servers1, true);
+ EXPECT_TRUE(impl_.SupportsRequestPriority(http_photo_server));
+ EXPECT_TRUE(impl_.SupportsRequestPriority(https_www_server));
+ EXPECT_FALSE(impl_.SupportsRequestPriority(http_google_server));
+ EXPECT_FALSE(impl_.SupportsRequestPriority(https_photos_server));
+ EXPECT_TRUE(impl_.SupportsRequestPriority(valid_google_server));
+}
+
TEST_F(SpdyServerPropertiesTest, Initialize) {
- HostPortPair spdy_server_google("www.google.com", 443);
- std::string spdy_server_g = spdy_server_google.ToString();
+ url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
+ std::string spdy_server_g = spdy_server_google.Serialize();
- HostPortPair spdy_server_photos("photos.google.com", 443);
- std::string spdy_server_p = spdy_server_photos.ToString();
+ url::SchemeHostPort spdy_server_photos("https", "photos.google.com", 443);
+ std::string spdy_server_p = spdy_server_photos.Serialize();
- HostPortPair spdy_server_docs("docs.google.com", 443);
- std::string spdy_server_d = spdy_server_docs.ToString();
+ url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
+ std::string spdy_server_d = spdy_server_docs.Serialize();
- HostPortPair spdy_server_mail("mail.google.com", 443);
- std::string spdy_server_m = spdy_server_mail.ToString();
+ url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
+ std::string spdy_server_m = spdy_server_mail.Serialize();
// Check by initializing NULL spdy servers.
impl_.InitializeSpdyServers(NULL, true);
@@ -201,49 +228,51 @@ TEST_F(SpdyServerPropertiesTest, Initialize) {
}
TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) {
- HostPortPair spdy_server_empty(std::string(), 443);
+ url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty));
// Add www.google.com:443 as supporting SPDY.
- HostPortPair spdy_server_google("www.google.com", 443);
+ url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
impl_.SetSupportsSpdy(spdy_server_google, true);
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
// Add mail.google.com:443 as not supporting SPDY.
- HostPortPair spdy_server_mail("mail.google.com", 443);
+ url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
// Add docs.google.com:443 as supporting SPDY.
- HostPortPair spdy_server_docs("docs.google.com", 443);
+ url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
impl_.SetSupportsSpdy(spdy_server_docs, true);
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
// Add www.youtube.com:443 as supporting QUIC.
HostPortPair quic_server_youtube("www.youtube.com", 443);
+ url::SchemeHostPort youtube_server("https", "www.youtube.com", 443);
const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443);
SetAlternativeService(quic_server_youtube, alternative_service1);
- EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube));
+ EXPECT_TRUE(impl_.SupportsRequestPriority(youtube_server));
// Add www.example.com:443 with two alternative services, one supporting QUIC.
HostPortPair quic_server_example("www.example.com", 443);
+ url::SchemeHostPort example_server("https", "www.example.com", 443);
const AlternativeService alternative_service2(NPN_HTTP_2, "", 443);
SetAlternativeService(quic_server_example, alternative_service2);
SetAlternativeService(quic_server_example, alternative_service1);
- EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example));
+ EXPECT_TRUE(impl_.SupportsRequestPriority(example_server));
// Verify all the entries are the same after additions.
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
- EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube));
- EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example));
+ EXPECT_TRUE(impl_.SupportsRequestPriority(youtube_server));
+ EXPECT_TRUE(impl_.SupportsRequestPriority(example_server));
}
TEST_F(SpdyServerPropertiesTest, Clear) {
// Add www.google.com:443 and mail.google.com:443 as supporting SPDY.
- HostPortPair spdy_server_google("www.google.com", 443);
+ url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
impl_.SetSupportsSpdy(spdy_server_google, true);
- HostPortPair spdy_server_mail("mail.google.com", 443);
+ url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
impl_.SetSupportsSpdy(spdy_server_mail, true);
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
@@ -262,17 +291,17 @@ TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
EXPECT_EQ(0U, spdy_server_list.GetSize());
// Check empty server is not added.
- HostPortPair spdy_server_empty(std::string(), 443);
+ url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
impl_.SetSupportsSpdy(spdy_server_empty, true);
impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
EXPECT_EQ(0U, spdy_server_list.GetSize());
std::string string_value_g;
std::string string_value_m;
- HostPortPair spdy_server_google("www.google.com", 443);
- std::string spdy_server_g = spdy_server_google.ToString();
- HostPortPair spdy_server_mail("mail.google.com", 443);
- std::string spdy_server_m = spdy_server_mail.ToString();
+ url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
+ std::string spdy_server_g = spdy_server_google.Serialize();
+ url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
+ std::string spdy_server_m = spdy_server_mail.Serialize();
// Add www.google.com:443 as not supporting SPDY.
impl_.SetSupportsSpdy(spdy_server_google, false);
@@ -316,10 +345,10 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
std::string string_value_g;
std::string string_value_m;
- HostPortPair spdy_server_google("www.google.com", 443);
- std::string spdy_server_g = spdy_server_google.ToString();
- HostPortPair spdy_server_mail("mail.google.com", 443);
- std::string spdy_server_m = spdy_server_mail.ToString();
+ url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
+ std::string spdy_server_g = spdy_server_google.Serialize();
+ url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
+ std::string spdy_server_m = spdy_server_mail.Serialize();
// Add www.google.com:443 as supporting SPDY.
impl_.SetSupportsSpdy(spdy_server_google, true);
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698