OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_number_conversions.h" |
8 #include "chrome/browser/debugger/devtools_remote.h" | 8 #include "chrome/browser/debugger/devtools_remote.h" |
9 #include "chrome/browser/debugger/devtools_remote_message.h" | 9 #include "chrome/browser/debugger/devtools_remote_message.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 class DevToolsRemoteMessageTest : public testing::Test { | 12 class DevToolsRemoteMessageTest : public testing::Test { |
13 public: | 13 public: |
14 DevToolsRemoteMessageTest() : testing::Test() { | 14 DevToolsRemoteMessageTest() : testing::Test() { |
15 } | 15 } |
16 | 16 |
17 protected: | 17 protected: |
18 virtual void SetUp() { | 18 virtual void SetUp() { |
19 testing::Test::SetUp(); | 19 testing::Test::SetUp(); |
20 } | 20 } |
21 }; | 21 }; |
22 | 22 |
23 TEST_F(DevToolsRemoteMessageTest, ConstructInstanceManually) { | 23 TEST_F(DevToolsRemoteMessageTest, ConstructInstanceManually) { |
24 DevToolsRemoteMessage::HeaderMap headers; | 24 DevToolsRemoteMessage::HeaderMap headers; |
25 std::string content = "{\"command\":\"ping\"}"; | 25 std::string content = "{\"command\":\"ping\"}"; |
26 headers[DevToolsRemoteMessageHeaders::kTool] = "DevToolsService"; | 26 headers[DevToolsRemoteMessageHeaders::kTool] = "DevToolsService"; |
27 headers[DevToolsRemoteMessageHeaders::kContentLength] = | 27 headers[DevToolsRemoteMessageHeaders::kContentLength] = |
28 IntToString(content.size()); | 28 base::IntToString(content.size()); |
29 | 29 |
30 DevToolsRemoteMessage message(headers, content); | 30 DevToolsRemoteMessage message(headers, content); |
31 ASSERT_STREQ("DevToolsService", | 31 ASSERT_STREQ("DevToolsService", |
32 message.GetHeaderWithEmptyDefault( | 32 message.GetHeaderWithEmptyDefault( |
33 DevToolsRemoteMessageHeaders::kTool).c_str()); | 33 DevToolsRemoteMessageHeaders::kTool).c_str()); |
34 ASSERT_STREQ("DevToolsService", message.tool().c_str()); | 34 ASSERT_STREQ("DevToolsService", message.tool().c_str()); |
35 ASSERT_STREQ(content.c_str(), message.content().c_str()); | 35 ASSERT_STREQ(content.c_str(), message.content().c_str()); |
36 ASSERT_EQ(content.size(), | 36 ASSERT_EQ(content.size(), |
37 static_cast<std::string::size_type>(message.content_length())); | 37 static_cast<std::string::size_type>(message.content_length())); |
38 ASSERT_EQ(static_cast<DevToolsRemoteMessage::HeaderMap::size_type>(2), | 38 ASSERT_EQ(static_cast<DevToolsRemoteMessage::HeaderMap::size_type>(2), |
(...skipping 22 matching lines...) Expand all Loading... |
61 message->GetHeaderWithEmptyDefault( | 61 message->GetHeaderWithEmptyDefault( |
62 DevToolsRemoteMessageHeaders::kDestination).c_str()); | 62 DevToolsRemoteMessageHeaders::kDestination).c_str()); |
63 ASSERT_STREQ( | 63 ASSERT_STREQ( |
64 "2", | 64 "2", |
65 message->destination().c_str()); | 65 message->destination().c_str()); |
66 ASSERT_EQ(content.size(), | 66 ASSERT_EQ(content.size(), |
67 static_cast<DevToolsRemoteMessage::HeaderMap::size_type>( | 67 static_cast<DevToolsRemoteMessage::HeaderMap::size_type>( |
68 message->content_length())); | 68 message->content_length())); |
69 ASSERT_STREQ(content.c_str(), message->content().c_str()); | 69 ASSERT_STREQ(content.c_str(), message->content().c_str()); |
70 } | 70 } |
OLD | NEW |