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

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

Issue 1084533002: Rename NetLogLogger and CapturingNetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename NetLogLogger and CapturingNetLog(removed compiler error for chromeOS) Created 5 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 unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_stream_unittest.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 "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 SETTINGS_FLAG_PLEASE_PERSIST, 1603 SETTINGS_FLAG_PLEASE_PERSIST,
1604 2); 1604 2);
1605 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 1605 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
1606 test_host_port_pair_).size()); 1606 test_host_port_pair_).size());
1607 spdy_session_pool_->OnIPAddressChanged(); 1607 spdy_session_pool_->OnIPAddressChanged();
1608 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 1608 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings(
1609 test_host_port_pair_).size()); 1609 test_host_port_pair_).size());
1610 } 1610 }
1611 1611
1612 TEST_P(SpdySessionTest, Initialize) { 1612 TEST_P(SpdySessionTest, Initialize) {
1613 CapturingBoundNetLog log; 1613 BoundTestNetLog log;
1614 session_deps_.net_log = log.bound().net_log(); 1614 session_deps_.net_log = log.bound().net_log();
1615 session_deps_.host_resolver->set_synchronous_mode(true); 1615 session_deps_.host_resolver->set_synchronous_mode(true);
1616 1616
1617 MockConnect connect_data(SYNCHRONOUS, OK); 1617 MockConnect connect_data(SYNCHRONOUS, OK);
1618 MockRead reads[] = { 1618 MockRead reads[] = {
1619 MockRead(ASYNC, 0, 0) // EOF 1619 MockRead(ASYNC, 0, 0) // EOF
1620 }; 1620 };
1621 1621
1622 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 1622 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
1623 data.set_connect_data(connect_data); 1623 data.set_connect_data(connect_data);
1624 session_deps_.socket_factory->AddSocketDataProvider(&data); 1624 session_deps_.socket_factory->AddSocketDataProvider(&data);
1625 1625
1626 CreateNetworkSession(); 1626 CreateNetworkSession();
1627 1627
1628 base::WeakPtr<SpdySession> session = 1628 base::WeakPtr<SpdySession> session =
1629 CreateInsecureSpdySession(http_session_, key_, log.bound()); 1629 CreateInsecureSpdySession(http_session_, key_, log.bound());
1630 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); 1630 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
1631 1631
1632 // Flush the read completion task. 1632 // Flush the read completion task.
1633 base::MessageLoop::current()->RunUntilIdle(); 1633 base::MessageLoop::current()->RunUntilIdle();
1634 1634
1635 net::CapturingNetLog::CapturedEntryList entries; 1635 net::TestNetLog::CapturedEntryList entries;
1636 log.GetEntries(&entries); 1636 log.GetEntries(&entries);
1637 EXPECT_LT(0u, entries.size()); 1637 EXPECT_LT(0u, entries.size());
1638 1638
1639 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly. 1639 // Check that we logged TYPE_HTTP2_SESSION_INITIALIZED correctly.
1640 int pos = net::ExpectLogContainsSomewhere( 1640 int pos = net::ExpectLogContainsSomewhere(
1641 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_INITIALIZED, 1641 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_INITIALIZED,
1642 net::NetLog::PHASE_NONE); 1642 net::NetLog::PHASE_NONE);
1643 EXPECT_LT(0, pos); 1643 EXPECT_LT(0, pos);
1644 1644
1645 CapturingNetLog::CapturedEntry entry = entries[pos]; 1645 TestNetLog::CapturedEntry entry = entries[pos];
1646 NetLog::Source socket_source; 1646 NetLog::Source socket_source;
1647 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), 1647 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(),
1648 &socket_source)); 1648 &socket_source));
1649 EXPECT_TRUE(socket_source.IsValid()); 1649 EXPECT_TRUE(socket_source.IsValid());
1650 EXPECT_NE(log.bound().source().id, socket_source.id); 1650 EXPECT_NE(log.bound().source().id, socket_source.id);
1651 } 1651 }
1652 1652
1653 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) { 1653 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) {
1654 session_deps_.host_resolver->set_synchronous_mode(true); 1654 session_deps_.host_resolver->set_synchronous_mode(true);
1655 1655
1656 MockConnect connect_data(SYNCHRONOUS, OK); 1656 MockConnect connect_data(SYNCHRONOUS, OK);
1657 scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway()); 1657 scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway());
1658 MockRead reads[] = { 1658 MockRead reads[] = {
1659 CreateMockRead(*goaway), 1659 CreateMockRead(*goaway),
1660 MockRead(SYNCHRONOUS, 0, 0) // EOF 1660 MockRead(SYNCHRONOUS, 0, 0) // EOF
1661 }; 1661 };
1662 1662
1663 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 1663 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
1664 data.set_connect_data(connect_data); 1664 data.set_connect_data(connect_data);
1665 session_deps_.socket_factory->AddSocketDataProvider(&data); 1665 session_deps_.socket_factory->AddSocketDataProvider(&data);
1666 1666
1667 CreateNetworkSession(); 1667 CreateNetworkSession();
1668 1668
1669 CapturingBoundNetLog log; 1669 BoundTestNetLog log;
1670 base::WeakPtr<SpdySession> session = 1670 base::WeakPtr<SpdySession> session =
1671 CreateInsecureSpdySession(http_session_, key_, log.bound()); 1671 CreateInsecureSpdySession(http_session_, key_, log.bound());
1672 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); 1672 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
1673 1673
1674 // Flush the read completion task. 1674 // Flush the read completion task.
1675 base::MessageLoop::current()->RunUntilIdle(); 1675 base::MessageLoop::current()->RunUntilIdle();
1676 1676
1677 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 1677 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
1678 EXPECT_TRUE(session == NULL); 1678 EXPECT_TRUE(session == NULL);
1679 1679
1680 // Check that the NetLog was filled reasonably. 1680 // Check that the NetLog was filled reasonably.
1681 net::CapturingNetLog::CapturedEntryList entries; 1681 net::TestNetLog::CapturedEntryList entries;
1682 log.GetEntries(&entries); 1682 log.GetEntries(&entries);
1683 EXPECT_LT(0u, entries.size()); 1683 EXPECT_LT(0u, entries.size());
1684 1684
1685 // Check that we logged SPDY_SESSION_CLOSE correctly. 1685 // Check that we logged SPDY_SESSION_CLOSE correctly.
1686 int pos = net::ExpectLogContainsSomewhere( 1686 int pos = net::ExpectLogContainsSomewhere(
1687 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE, 1687 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE,
1688 net::NetLog::PHASE_NONE); 1688 net::NetLog::PHASE_NONE);
1689 1689
1690 if (pos < static_cast<int>(entries.size())) { 1690 if (pos < static_cast<int>(entries.size())) {
1691 CapturingNetLog::CapturedEntry entry = entries[pos]; 1691 TestNetLog::CapturedEntry entry = entries[pos];
1692 int error_code = 0; 1692 int error_code = 0;
1693 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); 1693 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1694 EXPECT_EQ(OK, error_code); 1694 EXPECT_EQ(OK, error_code);
1695 } else { 1695 } else {
1696 ADD_FAILURE(); 1696 ADD_FAILURE();
1697 } 1697 }
1698 } 1698 }
1699 1699
1700 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { 1700 TEST_P(SpdySessionTest, NetLogOnSessionEOF) {
1701 session_deps_.host_resolver->set_synchronous_mode(true); 1701 session_deps_.host_resolver->set_synchronous_mode(true);
1702 1702
1703 MockConnect connect_data(SYNCHRONOUS, OK); 1703 MockConnect connect_data(SYNCHRONOUS, OK);
1704 MockRead reads[] = { 1704 MockRead reads[] = {
1705 MockRead(SYNCHRONOUS, 0, 0) // EOF 1705 MockRead(SYNCHRONOUS, 0, 0) // EOF
1706 }; 1706 };
1707 1707
1708 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 1708 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
1709 data.set_connect_data(connect_data); 1709 data.set_connect_data(connect_data);
1710 session_deps_.socket_factory->AddSocketDataProvider(&data); 1710 session_deps_.socket_factory->AddSocketDataProvider(&data);
1711 1711
1712 CreateNetworkSession(); 1712 CreateNetworkSession();
1713 1713
1714 CapturingBoundNetLog log; 1714 BoundTestNetLog log;
1715 base::WeakPtr<SpdySession> session = 1715 base::WeakPtr<SpdySession> session =
1716 CreateInsecureSpdySession(http_session_, key_, log.bound()); 1716 CreateInsecureSpdySession(http_session_, key_, log.bound());
1717 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); 1717 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
1718 1718
1719 // Flush the read completion task. 1719 // Flush the read completion task.
1720 base::MessageLoop::current()->RunUntilIdle(); 1720 base::MessageLoop::current()->RunUntilIdle();
1721 1721
1722 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 1722 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
1723 EXPECT_TRUE(session == NULL); 1723 EXPECT_TRUE(session == NULL);
1724 1724
1725 // Check that the NetLog was filled reasonably. 1725 // Check that the NetLog was filled reasonably.
1726 net::CapturingNetLog::CapturedEntryList entries; 1726 net::TestNetLog::CapturedEntryList entries;
1727 log.GetEntries(&entries); 1727 log.GetEntries(&entries);
1728 EXPECT_LT(0u, entries.size()); 1728 EXPECT_LT(0u, entries.size());
1729 1729
1730 // Check that we logged SPDY_SESSION_CLOSE correctly. 1730 // Check that we logged SPDY_SESSION_CLOSE correctly.
1731 int pos = net::ExpectLogContainsSomewhere( 1731 int pos = net::ExpectLogContainsSomewhere(
1732 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE, 1732 entries, 0, net::NetLog::TYPE_HTTP2_SESSION_CLOSE,
1733 net::NetLog::PHASE_NONE); 1733 net::NetLog::PHASE_NONE);
1734 1734
1735 if (pos < static_cast<int>(entries.size())) { 1735 if (pos < static_cast<int>(entries.size())) {
1736 CapturingNetLog::CapturedEntry entry = entries[pos]; 1736 TestNetLog::CapturedEntry entry = entries[pos];
1737 int error_code = 0; 1737 int error_code = 0;
1738 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); 1738 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1739 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code); 1739 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code);
1740 } else { 1740 } else {
1741 ADD_FAILURE(); 1741 ADD_FAILURE();
1742 } 1742 }
1743 } 1743 }
1744 1744
1745 TEST_P(SpdySessionTest, SynCompressionHistograms) { 1745 TEST_P(SpdySessionTest, SynCompressionHistograms) {
1746 session_deps_.enable_compression = true; 1746 session_deps_.enable_compression = true;
(...skipping 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after
5148 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5148 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5149 "spdy_pooling.pem"); 5149 "spdy_pooling.pem");
5150 ssl_info.is_issued_by_known_root = true; 5150 ssl_info.is_issued_by_known_root = true;
5151 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5151 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5152 5152
5153 EXPECT_TRUE(SpdySession::CanPool( 5153 EXPECT_TRUE(SpdySession::CanPool(
5154 &tss, ssl_info, "www.example.org", "mail.example.org")); 5154 &tss, ssl_info, "www.example.org", "mail.example.org"));
5155 } 5155 }
5156 5156
5157 } // namespace net 5157 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698