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

Side by Side Diff: chrome/browser/net/network_stats_unittest.cc

Issue 7056031: Collect stats to investigate the viability of UDP (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/network_stats.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "base/message_loop.h"
7 #include "chrome/browser/net/network_stats.h"
8 #include "net/base/host_resolver.h"
9 #include "net/base/mock_host_resolver.h"
10 #include "net/base/test_completion_callback.h"
11 #include "net/test/test_server.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h"
14
15 namespace chrome_browser_net {
16
17 class NetworkStatsTest : public PlatformTest {
18 public:
19 NetworkStatsTest() {}
20 protected:
21 virtual void TearDown() {
22 // Flush the message loop to make Purify happy.
23 message_loop_.RunAllPending();
24 }
25 MessageLoopForIO message_loop_;
26 };
27
28 class NetworkStatsTestUDP : public NetworkStatsTest {
29 public:
30 NetworkStatsTestUDP()
31 : test_server_(net::TestServer::TYPE_UDP_ECHO,
32 FilePath(FILE_PATH_LITERAL("net/data"))) {
33 }
34
35 protected:
36 void RunUDPEchoTest(int bytes) {
37 TestCompletionCallback cb;
38
39 UDPStatsClient* udp_stats_client = new UDPStatsClient();
40 EXPECT_TRUE(udp_stats_client->Start(test_server_.host_port_pair().host(),
41 test_server_.host_port_pair().port(),
42 bytes,
43 &cb));
44 int rv = cb.WaitForResult();
45 // Check there were no errors during connect/write/read to echo UDP server.
46 EXPECT_EQ(0, rv);
47 }
48
49 net::TestServer test_server_;
50 };
51
52 class NetworkStatsTestTCP : public NetworkStatsTest {
53 public:
54 NetworkStatsTestTCP()
55 : test_server_(net::TestServer::TYPE_TCP_ECHO,
56 FilePath(FILE_PATH_LITERAL("net/data"))) {
57 }
58
59 protected:
60 void RunTCPEchoTest(int bytes) {
61 TestCompletionCallback cb;
62
63 scoped_ptr<net::MockHostResolver> host_resolver(
64 new net::MockHostResolver());
65
66 TCPStatsClient* tcp_stats_client = new TCPStatsClient();
67 EXPECT_TRUE(tcp_stats_client->Start(host_resolver.get(),
68 test_server_.host_port_pair(),
69 bytes,
70 &cb));
71 int rv = cb.WaitForResult();
72 // Check there were no errors during connect/write/read to echo TCP server.
73 EXPECT_EQ(0, rv);
74 }
75
76 net::TestServer test_server_;
77 };
78
79 TEST_F(NetworkStatsTestUDP, UDPEcho_50B_Of_Data) {
80 ASSERT_TRUE(test_server_.Start());
81 RunUDPEchoTest(50);
82 }
83
84 TEST_F(NetworkStatsTestUDP, UDPEcho_1K_Of_Data) {
85 ASSERT_TRUE(test_server_.Start());
86 RunUDPEchoTest(1024);
87 }
88
89 TEST_F(NetworkStatsTestTCP, TCPEcho_50B_Of_Data) {
90 ASSERT_TRUE(test_server_.Start());
91 RunTCPEchoTest(50);
92 }
93
94 TEST_F(NetworkStatsTestTCP, TCPEcho_1K_Of_Data) {
95 ASSERT_TRUE(test_server_.Start());
96 RunTCPEchoTest(1024);
97 }
98
99 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/network_stats.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698