OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/format_macros.h" | 5 #include "base/format_macros.h" |
6 #include "base/json/json_reader.h" | 6 #include "base/json/json_reader.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/test/webdriver/commands/response.h" | 10 #include "chrome/test/webdriver/commands/response.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // We do not know whether the response status or value will be | 127 // We do not know whether the response status or value will be |
128 // encoded first, so we have to parse the response body to | 128 // encoded first, so we have to parse the response body to |
129 // verify it is correct. | 129 // verify it is correct. |
130 std::string actual_data(http_response.data(), | 130 std::string actual_data(http_response.data(), |
131 http_response.length()); | 131 http_response.length()); |
132 | 132 |
133 int error_code; | 133 int error_code; |
134 std::string error_message; | 134 std::string error_message; |
135 scoped_ptr<Value> parsed_response(base::JSONReader::ReadAndReturnError( | 135 scoped_ptr<Value> parsed_response(base::JSONReader::ReadAndReturnError( |
136 actual_data, false, &error_code, &error_message)); | 136 actual_data, base::JSON_PARSE_RFC, &error_code, &error_message)); |
137 | 137 |
138 ASSERT_TRUE(parsed_response.get() != NULL) << error_message; | 138 ASSERT_TRUE(parsed_response.get() != NULL) << error_message; |
139 ASSERT_TRUE(parsed_response->IsType(Value::TYPE_DICTIONARY)) | 139 ASSERT_TRUE(parsed_response->IsType(Value::TYPE_DICTIONARY)) |
140 << "Response should be a dictionary: " << actual_data; | 140 << "Response should be a dictionary: " << actual_data; |
141 | 141 |
142 DictionaryValue* dict = static_cast<DictionaryValue*>(parsed_response.get()); | 142 DictionaryValue* dict = static_cast<DictionaryValue*>(parsed_response.get()); |
143 EXPECT_EQ(2u, dict->size()); | 143 EXPECT_EQ(2u, dict->size()); |
144 EXPECT_TRUE(dict->HasKey("status")); | 144 EXPECT_TRUE(dict->HasKey("status")); |
145 EXPECT_TRUE(dict->HasKey("value")); | 145 EXPECT_TRUE(dict->HasKey("value")); |
146 | 146 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ¶meters, | 217 ¶meters, |
218 &response)); | 218 &response)); |
219 EXPECT_EQ("GET", method); | 219 EXPECT_EQ("GET", method); |
220 ASSERT_EQ(3u, path_segments.size()); | 220 ASSERT_EQ(3u, path_segments.size()); |
221 EXPECT_EQ("", path_segments[0]); | 221 EXPECT_EQ("", path_segments[0]); |
222 EXPECT_EQ("bar", path_segments[1]); | 222 EXPECT_EQ("bar", path_segments[1]); |
223 EXPECT_EQ("baz", path_segments[2]); | 223 EXPECT_EQ("baz", path_segments[2]); |
224 } | 224 } |
225 | 225 |
226 } // namespace webdriver | 226 } // namespace webdriver |
OLD | NEW |