OLD | NEW |
---|---|
(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/test_completion_callback.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 #include "testing/platform_test.h" | |
11 | |
12 namespace chrome_browser_net { | |
13 | |
14 class NetworkStatsTest : public PlatformTest { | |
15 public: | |
16 NetworkStatsTest() {} | |
17 protected: | |
18 virtual void TearDown() { | |
19 // Flush the message loop to make Purify happy. | |
20 message_loop_.RunAllPending(); | |
21 } | |
22 MessageLoopForIO message_loop_; | |
23 }; | |
24 | |
25 void RunUDPEchoTest(int bytes) { | |
26 TestCompletionCallback cb; | |
27 | |
28 UDPStatsClient* udp_stats_client = new UDPStatsClient(); | |
29 EXPECT_TRUE(udp_stats_client->Start("127.0.0.1", 90, bytes, &cb)); | |
30 | |
31 int rv = cb.WaitForResult(); | |
32 EXPECT_EQ(0, rv); | |
33 EXPECT_EQ(0, udp_stats_client->error_count()); | |
34 } | |
35 | |
36 void RunTCPEchoTest(int bytes) { | |
37 TestCompletionCallback cb; | |
38 | |
39 TCPStatsClient* tcp_stats_client = new TCPStatsClient(); | |
40 net::HostPortPair server_address("127.0.0.1", 80); | |
41 EXPECT_TRUE(tcp_stats_client->Start(server_address, bytes, &cb)); | |
42 | |
43 int rv = cb.WaitForResult(); | |
44 EXPECT_EQ(0, rv); | |
45 EXPECT_EQ(0, tcp_stats_client->error_count()); | |
46 } | |
47 | |
48 TEST_F(NetworkStatsTest, UDPEcho_50B_Of_Data) { | |
49 // TODO(raman): Enable the test once UDP echo server is deployed. | |
50 // RunUDPEchoTest(5); | |
Mike Belshe
2011/05/27 21:27:00
Can't the test work now since you're using loopbac
ramant (doing other things)
2011/05/31 21:25:36
Done.
| |
51 } | |
52 | |
53 TEST_F(NetworkStatsTest, TCPEcho_50B_Of_Data) { | |
54 // TODO(raman): Enable the test once TCP echo server is deployed. | |
55 // RunTCPEchoTest(5); | |
Mike Belshe
2011/05/27 21:27:00
BTW - I'd like to see tests which send more than j
ramant (doing other things)
2011/05/31 21:25:36
Done.
| |
56 } | |
57 | |
58 } // namespace chrome_browser_net | |
OLD | NEW |