Chromium Code Reviews| Index: chrome/browser/net/network_stats_unittest.cc |
| =================================================================== |
| --- chrome/browser/net/network_stats_unittest.cc (revision 0) |
| +++ chrome/browser/net/network_stats_unittest.cc (revision 0) |
| @@ -0,0 +1,58 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/basictypes.h" |
| +#include "base/message_loop.h" |
| +#include "chrome/browser/net/network_stats.h" |
| +#include "net/base/test_completion_callback.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "testing/platform_test.h" |
| + |
| +namespace chrome_browser_net { |
| + |
| +class NetworkStatsTest : public PlatformTest { |
| + public: |
| + NetworkStatsTest() {} |
| + protected: |
| + virtual void TearDown() { |
| + // Flush the message loop to make Purify happy. |
| + message_loop_.RunAllPending(); |
| + } |
| + MessageLoopForIO message_loop_; |
| +}; |
| + |
| +void RunUDPEchoTest(int bytes) { |
| + TestCompletionCallback cb; |
| + |
| + UDPStatsClient* udp_stats_client = new UDPStatsClient(); |
| + EXPECT_TRUE(udp_stats_client->Start("127.0.0.1", 90, bytes, &cb)); |
| + |
| + int rv = cb.WaitForResult(); |
| + EXPECT_EQ(0, rv); |
| + EXPECT_EQ(0, udp_stats_client->error_count()); |
| +} |
| + |
| +void RunTCPEchoTest(int bytes) { |
| + TestCompletionCallback cb; |
| + |
| + TCPStatsClient* tcp_stats_client = new TCPStatsClient(); |
| + net::HostPortPair server_address("127.0.0.1", 80); |
| + EXPECT_TRUE(tcp_stats_client->Start(server_address, bytes, &cb)); |
| + |
| + int rv = cb.WaitForResult(); |
| + EXPECT_EQ(0, rv); |
| + EXPECT_EQ(0, tcp_stats_client->error_count()); |
| +} |
| + |
| +TEST_F(NetworkStatsTest, UDPEcho_50B_Of_Data) { |
| + // TODO(raman): Enable the test once UDP echo server is deployed. |
| + // 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.
|
| +} |
| + |
| +TEST_F(NetworkStatsTest, TCPEcho_50B_Of_Data) { |
| + // TODO(raman): Enable the test once TCP echo server is deployed. |
| + // 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.
|
| +} |
| + |
| +} // namespace chrome_browser_net |