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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, false, &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->IsDictionary()) |
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 |
147 int status = -1; | 147 int status = -1; |
148 EXPECT_TRUE(dict->GetInteger("status", &status)); | 148 EXPECT_TRUE(dict->GetInteger("status", &status)); |
149 EXPECT_EQ(kSuccess, static_cast<ErrorCode>(status)); | 149 EXPECT_EQ(kSuccess, static_cast<ErrorCode>(status)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 &path_segments, ¶meters, | 209 &path_segments, ¶meters, |
210 &response)); | 210 &response)); |
211 EXPECT_EQ("GET", method); | 211 EXPECT_EQ("GET", method); |
212 ASSERT_EQ(3u, path_segments.size()); | 212 ASSERT_EQ(3u, path_segments.size()); |
213 EXPECT_EQ("", path_segments[0]); | 213 EXPECT_EQ("", path_segments[0]); |
214 EXPECT_EQ("bar", path_segments[1]); | 214 EXPECT_EQ("bar", path_segments[1]); |
215 EXPECT_EQ("baz", path_segments[2]); | 215 EXPECT_EQ("baz", path_segments[2]); |
216 } | 216 } |
217 | 217 |
218 } // namespace webdriver | 218 } // namespace webdriver |
OLD | NEW |