diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 01:06:15 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 01:06:15 +0000 |
commit | f6f1ba3cfd72905cd900e6266589ccb4a1650cb0 (patch) | |
tree | 957e236fd4f8b3e3578a7c7208e3ea6a79c65aee /net/base/telnet_server_unittest.cc | |
parent | 043c9a78957bf3f7de4b53e41ec91bf22be69949 (diff) | |
download | chromium_src-f6f1ba3cfd72905cd900e6266589ccb4a1650cb0.zip chromium_src-f6f1ba3cfd72905cd900e6266589ccb4a1650cb0.tar.gz chromium_src-f6f1ba3cfd72905cd900e6266589ccb4a1650cb0.tar.bz2 |
Change made by external contributor Ibrar Ahmed (ibrar.ahmad@gmail.com), reviewed by erikkay:
http://codereview.chromium.org/6577/show
ports listen_socket and telnet_server to POSIX
I had to make some changes to get this to work on Mac and to fix a few regressions it caused in Windows, so please take a fresh look at this diff Dan.
Ibrar, please take a look at the changes from your patch to mine (you may need to diff listen_socket_unittest.h with listen_socket_unittest.cc manually since I moved a bunch of code here). Some were bugs that I should have caught in review, some were bugs that only got tickled on the Mac, others were just cleanup. Comments welcome.
Review URL: http://codereview.chromium.org/9260
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/telnet_server_unittest.cc')
-rw-r--r-- | net/base/telnet_server_unittest.cc | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/net/base/telnet_server_unittest.cc b/net/base/telnet_server_unittest.cc index 5825c05..08a1607 100644 --- a/net/base/telnet_server_unittest.cc +++ b/net/base/telnet_server_unittest.cc @@ -4,35 +4,30 @@ // Tests TelnetServer. +#include "base/platform_test.h" #include "net/base/listen_socket_unittest.h" #include "net/base/telnet_server.h" -namespace { - -const std::string CRLF("\r\n"); +static const char* kCRLF = "\r\n"; class TelnetServerTester : public ListenSocketTester { public: virtual ListenSocket* DoListen() { - return TelnetServer::Listen("127.0.0.1", TEST_PORT, this); + return TelnetServer::Listen("127.0.0.1", kTestPort, this); } virtual void SetUp() { ListenSocketTester::SetUp(); // With TelnetServer, there's some control codes sent at connect time, // so we need to eat those to avoid affecting the subsequent tests. - // TODO(erikkay): Unfortunately, without the sleep, we don't seem to - // reliably get the 15 bytes without an EWOULDBLOCK. It would be nice if - // there were a more reliable mechanism here. - Sleep(10); - ASSERT_EQ(ClearTestSocket(), 15); + EXPECT_EQ(ClearTestSocket(), 15); } virtual bool Send(SOCKET sock, const std::string& str) { if (ListenSocketTester::Send(sock, str)) { // TelnetServer currently calls DidRead after a CRLF, so we need to // append one to the end of the data that we send. - if (ListenSocketTester::Send(sock, CRLF)) { + if (ListenSocketTester::Send(sock, kCRLF)) { return true; } } @@ -40,18 +35,20 @@ public: } }; -class TelnetServerTest: public testing::Test { +class TelnetServerTest: public PlatformTest { protected: TelnetServerTest() { tester_ = NULL; } virtual void SetUp() { + PlatformTest::SetUp(); tester_ = new TelnetServerTester(); tester_->SetUp(); } virtual void TearDown() { + PlatformTest::TearDown(); tester_->TearDown(); tester_ = NULL; } @@ -59,8 +56,6 @@ protected: scoped_refptr<TelnetServerTester> tester_; }; -} // namespace - TEST_F(TelnetServerTest, ServerClientSend) { tester_->TestClientSend(); } |