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

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

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
209 &path_segments, &parameters, 209 &path_segments, &parameters,
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
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_dispatch.cc ('k') | chrome/test/webdriver/webdriver_element_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698