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

Side by Side Diff: net/url_request/url_request_http_job_unittest.cc

Issue 2082603002: Introduce an 'ENABLE_WEBSOCKETS' define in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hsts
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
« net/BUILD.gn ('K') | « net/net_common.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <memory> 10 #include <memory>
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 641
642 struct TestCase { 642 struct TestCase {
643 const char* url; 643 const char* url;
644 bool upgrade_expected; 644 bool upgrade_expected;
645 const char* url_expected; 645 const char* url_expected;
646 } cases[] = { 646 } cases[] = {
647 {"http://upgrade.test/", true, "https://upgrade.test/"}, 647 {"http://upgrade.test/", true, "https://upgrade.test/"},
648 {"http://upgrade.test:123/", true, "https://upgrade.test:123/"}, 648 {"http://upgrade.test:123/", true, "https://upgrade.test:123/"},
649 {"http://no-upgrade.test/", false, "http://no-upgrade.test/"}, 649 {"http://no-upgrade.test/", false, "http://no-upgrade.test/"},
650 {"http://no-upgrade.test:123/", false, "http://no-upgrade.test:123/"}, 650 {"http://no-upgrade.test:123/", false, "http://no-upgrade.test:123/"},
651 // iOS doesn't support websockets; see the comments above 651 #if defined(ENABLE_WEBSOCKETS)
mmenke 2016/06/20 15:14:09 url_request_job_manager.cc also has an defined(OS_
Mike West 2016/06/21 10:31:15 Done.
652 // URLRequestHttpJobWebSocketTest for detail.
653 #if !defined(OS_IOS)
654 {"ws://upgrade.test/", true, "wss://upgrade.test/"}, 652 {"ws://upgrade.test/", true, "wss://upgrade.test/"},
655 {"ws://upgrade.test:123/", true, "wss://upgrade.test:123/"}, 653 {"ws://upgrade.test:123/", true, "wss://upgrade.test:123/"},
656 {"ws://no-upgrade.test/", false, "ws://no-upgrade.test/"}, 654 {"ws://no-upgrade.test/", false, "ws://no-upgrade.test/"},
657 {"ws://no-upgrade.test:123/", false, "ws://no-upgrade.test:123/"}, 655 {"ws://no-upgrade.test:123/", false, "ws://no-upgrade.test:123/"},
658 #endif // !defined(OS_IOS) 656 #endif // defined(ENABLE_WEBSOCKETS)
659 }; 657 };
660 658
661 for (const auto& test : cases) { 659 for (const auto& test : cases) {
662 SCOPED_TRACE(test.url); 660 SCOPED_TRACE(test.url);
663 TestDelegate d; 661 TestDelegate d;
664 TestNetworkDelegate network_delegate; 662 TestNetworkDelegate network_delegate;
665 std::unique_ptr<URLRequest> r( 663 std::unique_ptr<URLRequest> r(
666 context_.CreateRequest(GURL(test.url), DEFAULT_PRIORITY, &d)); 664 context_.CreateRequest(GURL(test.url), DEFAULT_PRIORITY, &d));
667 665
668 net_log_.Clear(); 666 net_log_.Clear();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 } 887 }
890 888
891 MOCK_METHOD0(CreateBasicStreamMock, 889 MOCK_METHOD0(CreateBasicStreamMock,
892 WebSocketHandshakeStreamBase*()); 890 WebSocketHandshakeStreamBase*());
893 891
894 MOCK_METHOD2(CreateSpdyStream, 892 MOCK_METHOD2(CreateSpdyStream,
895 WebSocketHandshakeStreamBase*(const base::WeakPtr<SpdySession>&, 893 WebSocketHandshakeStreamBase*(const base::WeakPtr<SpdySession>&,
896 bool)); 894 bool));
897 }; 895 };
898 896
899 // iOS doesn't support WebSockets, so these tests fail with ERR_UNKOWN_SCHEME on 897 #if defined(ENABLE_WEBSOCKETS)
900 // iOS.
901 // TODO(mmenke): Hard coding features based on OS is regression prone and ugly.
902 // Seems like this should use a build flag instead.
903 #if !defined(OS_IOS)
904 898
905 class FakeWebSocketHandshakeStream : public WebSocketHandshakeStreamBase { 899 class FakeWebSocketHandshakeStream : public WebSocketHandshakeStreamBase {
906 public: 900 public:
907 FakeWebSocketHandshakeStream() : initialize_stream_was_called_(false) {} 901 FakeWebSocketHandshakeStream() : initialize_stream_was_called_(false) {}
908 902
909 bool initialize_stream_was_called() const { 903 bool initialize_stream_was_called() const {
910 return initialize_stream_was_called_; 904 return initialize_stream_was_called_;
911 } 905 }
912 906
913 // Fake implementation of HttpStreamBase methods. 907 // Fake implementation of HttpStreamBase methods.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 .WillOnce(Return(fake_handshake_stream)); 996 .WillOnce(Return(fake_handshake_stream));
1003 req_->SetUserData(WebSocketHandshakeStreamBase::CreateHelper::DataKey(), 997 req_->SetUserData(WebSocketHandshakeStreamBase::CreateHelper::DataKey(),
1004 create_helper.release()); 998 create_helper.release());
1005 req_->SetLoadFlags(LOAD_DISABLE_CACHE); 999 req_->SetLoadFlags(LOAD_DISABLE_CACHE);
1006 req_->Start(); 1000 req_->Start();
1007 base::RunLoop().RunUntilIdle(); 1001 base::RunLoop().RunUntilIdle();
1008 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); 1002 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status());
1009 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); 1003 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called());
1010 } 1004 }
1011 1005
1012 #endif // !defined(OS_IOS) 1006 #endif // defined(ENABLE_WEBSOCKETS)
1013 1007
1014 } // namespace 1008 } // namespace
1015 1009
1016 } // namespace net 1010 } // namespace net
OLDNEW
« net/BUILD.gn ('K') | « net/net_common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698