Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/test/webdriver/webdriver_dispatch_unittest.cc

Issue 10827362: Fix ChromeDriver flakiness with the C# webdriver bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/webdriver_dispatch.cc ('k') | chrome/test/webdriver/webdriver_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 Response command_response; 115 Response command_response;
116 command_response.SetStatus(kSuccess); 116 command_response.SetStatus(kSuccess);
117 command_response.SetValue(Value::CreateStringValue("foobar")); 117 command_response.SetValue(Value::CreateStringValue("foobar"));
118 118
119 HttpResponse http_response; 119 HttpResponse http_response;
120 internal::PrepareHttpResponse(command_response, &http_response); 120 internal::PrepareHttpResponse(command_response, &http_response);
121 EXPECT_EQ(HttpResponse::kOk, http_response.status()); 121 EXPECT_EQ(HttpResponse::kOk, http_response.status());
122 ExpectHeaderValue(http_response, "content-type", 122 ExpectHeaderValue(http_response, "content-type",
123 "application/json; charset=utf-8"); 123 "application/json; charset=utf-8");
124 ExpectHeaderValue(http_response, "content-length",
125 base::StringPrintf("%"PRIuS, kExpectedData.length()));
126 124
127 // We do not know whether the response status or value will be 125 // We do not know whether the response status or value will be
128 // encoded first, so we have to parse the response body to 126 // encoded first, so we have to parse the response body to
129 // verify it is correct. 127 // verify it is correct.
130 std::string actual_data(http_response.data(),
131 http_response.length());
132
133 int error_code; 128 int error_code;
134 std::string error_message; 129 std::string error_message;
135 scoped_ptr<Value> parsed_response(base::JSONReader::ReadAndReturnError( 130 scoped_ptr<Value> parsed_response(base::JSONReader::ReadAndReturnError(
136 actual_data, base::JSON_PARSE_RFC, &error_code, &error_message)); 131 http_response.body(), base::JSON_PARSE_RFC, &error_code, &error_message));
137 132
138 ASSERT_TRUE(parsed_response.get() != NULL) << error_message; 133 ASSERT_TRUE(parsed_response.get() != NULL) << error_message;
139 ASSERT_TRUE(parsed_response->IsType(Value::TYPE_DICTIONARY)) 134 ASSERT_TRUE(parsed_response->IsType(Value::TYPE_DICTIONARY))
140 << "Response should be a dictionary: " << actual_data; 135 << "Response should be a dictionary: " << http_response.body();
141 136
142 DictionaryValue* dict = static_cast<DictionaryValue*>(parsed_response.get()); 137 DictionaryValue* dict = static_cast<DictionaryValue*>(parsed_response.get());
143 EXPECT_EQ(2u, dict->size()); 138 EXPECT_EQ(2u, dict->size());
144 EXPECT_TRUE(dict->HasKey("status")); 139 EXPECT_TRUE(dict->HasKey("status"));
145 EXPECT_TRUE(dict->HasKey("value")); 140 EXPECT_TRUE(dict->HasKey("value"));
146 141
147 int status = -1; 142 int status = -1;
148 EXPECT_TRUE(dict->GetInteger("status", &status)); 143 EXPECT_TRUE(dict->GetInteger("status", &status));
149 EXPECT_EQ(kSuccess, static_cast<ErrorCode>(status)); 144 EXPECT_EQ(kSuccess, static_cast<ErrorCode>(status));
150 145
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 &parameters, 212 &parameters,
218 &response)); 213 &response));
219 EXPECT_EQ("GET", method); 214 EXPECT_EQ("GET", method);
220 ASSERT_EQ(3u, path_segments.size()); 215 ASSERT_EQ(3u, path_segments.size());
221 EXPECT_EQ("", path_segments[0]); 216 EXPECT_EQ("", path_segments[0]);
222 EXPECT_EQ("bar", path_segments[1]); 217 EXPECT_EQ("bar", path_segments[1]);
223 EXPECT_EQ("baz", path_segments[2]); 218 EXPECT_EQ("baz", path_segments[2]);
224 } 219 }
225 220
226 } // namespace webdriver 221 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_dispatch.cc ('k') | chrome/test/webdriver/webdriver_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698