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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 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
« no previous file with comments | « net/spdy/spdy_session_pool.cc ('k') | net/spdy/spdy_stream.cc » ('j') | 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) 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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
15 #include "net/base/host_port_pair.h" 15 #include "net/base/host_port_pair.h"
16 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
17 #include "net/base/ip_endpoint.h" 17 #include "net/base/ip_endpoint.h"
18 #include "net/base/proxy_delegate.h" 18 #include "net/base/proxy_delegate.h"
19 #include "net/base/request_priority.h" 19 #include "net/base/request_priority.h"
20 #include "net/base/test_data_stream.h" 20 #include "net/base/test_data_stream.h"
21 #include "net/base/test_proxy_delegate.h" 21 #include "net/base/test_proxy_delegate.h"
22 #include "net/cert/ct_policy_status.h" 22 #include "net/cert/ct_policy_status.h"
23 #include "net/log/net_log_event_type.h"
23 #include "net/log/test_net_log.h" 24 #include "net/log/test_net_log.h"
24 #include "net/log/test_net_log_entry.h" 25 #include "net/log/test_net_log_entry.h"
25 #include "net/log/test_net_log_util.h" 26 #include "net/log/test_net_log_util.h"
26 #include "net/proxy/proxy_server.h" 27 #include "net/proxy/proxy_server.h"
27 #include "net/socket/client_socket_pool_manager.h" 28 #include "net/socket/client_socket_pool_manager.h"
28 #include "net/socket/socket_test_util.h" 29 #include "net/socket/socket_test_util.h"
29 #include "net/spdy/spdy_http_utils.h" 30 #include "net/spdy/spdy_http_utils.h"
30 #include "net/spdy/spdy_session_pool.h" 31 #include "net/spdy/spdy_session_pool.h"
31 #include "net/spdy/spdy_session_test_util.h" 32 #include "net/spdy/spdy_session_test_util.h"
32 #include "net/spdy/spdy_stream.h" 33 #include "net/spdy/spdy_stream.h"
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 CreateInsecureSpdySession(); 1529 CreateInsecureSpdySession();
1529 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); 1530 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
1530 1531
1531 // Flush the read completion task. 1532 // Flush the read completion task.
1532 base::RunLoop().RunUntilIdle(); 1533 base::RunLoop().RunUntilIdle();
1533 1534
1534 TestNetLogEntry::List entries; 1535 TestNetLogEntry::List entries;
1535 log_.GetEntries(&entries); 1536 log_.GetEntries(&entries);
1536 EXPECT_LT(0u, entries.size()); 1537 EXPECT_LT(0u, entries.size());
1537 1538
1538 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly. 1539 // Check that we logged HTTP2_SESSION_INITIALIZED correctly.
1539 int pos = ExpectLogContainsSomewhere( 1540 int pos = ExpectLogContainsSomewhere(
1540 entries, 0, NetLog::TYPE_HTTP2_SESSION_INITIALIZED, NetLog::PHASE_NONE); 1541 entries, 0, NetLogEventType::HTTP2_SESSION_INITIALIZED,
1542 NetLogEventPhase::NONE);
1541 EXPECT_LT(0, pos); 1543 EXPECT_LT(0, pos);
1542 1544
1543 TestNetLogEntry entry = entries[pos]; 1545 TestNetLogEntry entry = entries[pos];
1544 NetLog::Source socket_source; 1546 NetLog::Source socket_source;
1545 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), 1547 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(),
1546 &socket_source)); 1548 &socket_source));
1547 EXPECT_TRUE(socket_source.IsValid()); 1549 EXPECT_TRUE(socket_source.IsValid());
1548 EXPECT_NE(log_.bound().source().id, socket_source.id); 1550 EXPECT_NE(log_.bound().source().id, socket_source.id);
1549 } 1551 }
1550 1552
(...skipping 17 matching lines...) Expand all
1568 base::RunLoop().RunUntilIdle(); 1570 base::RunLoop().RunUntilIdle();
1569 1571
1570 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 1572 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
1571 EXPECT_FALSE(session_); 1573 EXPECT_FALSE(session_);
1572 1574
1573 // Check that the NetLog was filled reasonably. 1575 // Check that the NetLog was filled reasonably.
1574 TestNetLogEntry::List entries; 1576 TestNetLogEntry::List entries;
1575 log_.GetEntries(&entries); 1577 log_.GetEntries(&entries);
1576 EXPECT_LT(0u, entries.size()); 1578 EXPECT_LT(0u, entries.size());
1577 1579
1578 int pos = ExpectLogContainsSomewhere( 1580 int pos = ExpectLogContainsSomewhere(entries, 0,
1579 entries, 0, NetLog::TYPE_HTTP2_SESSION_GOAWAY, NetLog::PHASE_NONE); 1581 NetLogEventType::HTTP2_SESSION_GOAWAY,
1582 NetLogEventPhase::NONE);
1580 TestNetLogEntry entry = entries[pos]; 1583 TestNetLogEntry entry = entries[pos];
1581 int last_accepted_stream_id; 1584 int last_accepted_stream_id;
1582 ASSERT_TRUE(entry.GetIntegerValue("last_accepted_stream_id", 1585 ASSERT_TRUE(entry.GetIntegerValue("last_accepted_stream_id",
1583 &last_accepted_stream_id)); 1586 &last_accepted_stream_id));
1584 EXPECT_EQ(42, last_accepted_stream_id); 1587 EXPECT_EQ(42, last_accepted_stream_id);
1585 int active_streams; 1588 int active_streams;
1586 ASSERT_TRUE(entry.GetIntegerValue("active_streams", &active_streams)); 1589 ASSERT_TRUE(entry.GetIntegerValue("active_streams", &active_streams));
1587 EXPECT_EQ(0, active_streams); 1590 EXPECT_EQ(0, active_streams);
1588 int unclaimed_streams; 1591 int unclaimed_streams;
1589 ASSERT_TRUE(entry.GetIntegerValue("unclaimed_streams", &unclaimed_streams)); 1592 ASSERT_TRUE(entry.GetIntegerValue("unclaimed_streams", &unclaimed_streams));
1590 EXPECT_EQ(0, unclaimed_streams); 1593 EXPECT_EQ(0, unclaimed_streams);
1591 int status; 1594 int status;
1592 ASSERT_TRUE(entry.GetIntegerValue("status", &status)); 1595 ASSERT_TRUE(entry.GetIntegerValue("status", &status));
1593 EXPECT_EQ(GOAWAY_ENHANCE_YOUR_CALM, status); 1596 EXPECT_EQ(GOAWAY_ENHANCE_YOUR_CALM, status);
1594 std::string debug_data; 1597 std::string debug_data;
1595 ASSERT_TRUE(entry.GetStringValue("debug_data", &debug_data)); 1598 ASSERT_TRUE(entry.GetStringValue("debug_data", &debug_data));
1596 EXPECT_EQ("foo", debug_data); 1599 EXPECT_EQ("foo", debug_data);
1597 1600
1598 // Check that we logged SPDY_SESSION_CLOSE correctly. 1601 // Check that we logged SPDY_SESSION_CLOSE correctly.
1599 pos = ExpectLogContainsSomewhere(entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, 1602 pos = ExpectLogContainsSomewhere(
1600 NetLog::PHASE_NONE); 1603 entries, 0, NetLogEventType::HTTP2_SESSION_CLOSE, NetLogEventPhase::NONE);
1601 entry = entries[pos]; 1604 entry = entries[pos];
1602 int error_code = 0; 1605 int error_code = 0;
1603 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); 1606 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1604 EXPECT_THAT(error_code, IsOk()); 1607 EXPECT_THAT(error_code, IsOk());
1605 } 1608 }
1606 1609
1607 TEST_F(SpdySessionTest, NetLogOnSessionEOF) { 1610 TEST_F(SpdySessionTest, NetLogOnSessionEOF) {
1608 session_deps_.host_resolver->set_synchronous_mode(true); 1611 session_deps_.host_resolver->set_synchronous_mode(true);
1609 1612
1610 MockRead reads[] = { 1613 MockRead reads[] = {
(...skipping 13 matching lines...) Expand all
1624 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 1627 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
1625 EXPECT_FALSE(session_); 1628 EXPECT_FALSE(session_);
1626 1629
1627 // Check that the NetLog was filled reasonably. 1630 // Check that the NetLog was filled reasonably.
1628 TestNetLogEntry::List entries; 1631 TestNetLogEntry::List entries;
1629 log_.GetEntries(&entries); 1632 log_.GetEntries(&entries);
1630 EXPECT_LT(0u, entries.size()); 1633 EXPECT_LT(0u, entries.size());
1631 1634
1632 // Check that we logged SPDY_SESSION_CLOSE correctly. 1635 // Check that we logged SPDY_SESSION_CLOSE correctly.
1633 int pos = ExpectLogContainsSomewhere( 1636 int pos = ExpectLogContainsSomewhere(
1634 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); 1637 entries, 0, NetLogEventType::HTTP2_SESSION_CLOSE, NetLogEventPhase::NONE);
1635 1638
1636 if (pos < static_cast<int>(entries.size())) { 1639 if (pos < static_cast<int>(entries.size())) {
1637 TestNetLogEntry entry = entries[pos]; 1640 TestNetLogEntry entry = entries[pos];
1638 int error_code = 0; 1641 int error_code = 0;
1639 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); 1642 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1640 EXPECT_THAT(error_code, IsError(ERR_CONNECTION_CLOSED)); 1643 EXPECT_THAT(error_code, IsError(ERR_CONNECTION_CLOSED));
1641 } else { 1644 } else {
1642 ADD_FAILURE(); 1645 ADD_FAILURE();
1643 } 1646 }
1644 } 1647 }
(...skipping 3756 matching lines...) Expand 10 before | Expand all | Expand 10 after
5401 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5404 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5402 "spdy_pooling.pem"); 5405 "spdy_pooling.pem");
5403 ssl_info.is_issued_by_known_root = true; 5406 ssl_info.is_issued_by_known_root = true;
5404 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5407 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5405 5408
5406 EXPECT_TRUE(SpdySession::CanPool( 5409 EXPECT_TRUE(SpdySession::CanPool(
5407 &tss, ssl_info, "www.example.org", "mail.example.org")); 5410 &tss, ssl_info, "www.example.org", "mail.example.org"));
5408 } 5411 }
5409 5412
5410 } // namespace net 5413 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_pool.cc ('k') | net/spdy/spdy_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698