OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/chrome/web_view_impl.h" | 5 #include "chrome/test/chromedriver/chrome/web_view_impl.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 bool got_object; | 199 bool got_object; |
200 std::string object_id; | 200 std::string object_id; |
201 ASSERT_TRUE(internal::EvaluateScriptAndGetObject( | 201 ASSERT_TRUE(internal::EvaluateScriptAndGetObject( |
202 &client, 0, std::string(), &got_object, &object_id).IsOk()); | 202 &client, 0, std::string(), &got_object, &object_id).IsOk()); |
203 ASSERT_TRUE(got_object); | 203 ASSERT_TRUE(got_object); |
204 ASSERT_STREQ("id", object_id.c_str()); | 204 ASSERT_STREQ("id", object_id.c_str()); |
205 } | 205 } |
206 | 206 |
207 TEST(ParseCallFunctionResult, NotDict) { | 207 TEST(ParseCallFunctionResult, NotDict) { |
208 std::unique_ptr<base::Value> result; | 208 std::unique_ptr<base::Value> result; |
209 base::FundamentalValue value(1); | 209 base::Value value(1); |
210 ASSERT_NE(kOk, internal::ParseCallFunctionResult(value, &result).code()); | 210 ASSERT_NE(kOk, internal::ParseCallFunctionResult(value, &result).code()); |
211 } | 211 } |
212 | 212 |
213 TEST(ParseCallFunctionResult, Ok) { | 213 TEST(ParseCallFunctionResult, Ok) { |
214 std::unique_ptr<base::Value> result; | 214 std::unique_ptr<base::Value> result; |
215 base::DictionaryValue dict; | 215 base::DictionaryValue dict; |
216 dict.SetInteger("status", 0); | 216 dict.SetInteger("status", 0); |
217 dict.SetInteger("value", 1); | 217 dict.SetInteger("value", 1); |
218 Status status = internal::ParseCallFunctionResult(dict, &result); | 218 Status status = internal::ParseCallFunctionResult(dict, &result); |
219 ASSERT_EQ(kOk, status.code()); | 219 ASSERT_EQ(kOk, status.code()); |
220 int value; | 220 int value; |
221 ASSERT_TRUE(result && result->GetAsInteger(&value)); | 221 ASSERT_TRUE(result && result->GetAsInteger(&value)); |
222 ASSERT_EQ(1, value); | 222 ASSERT_EQ(1, value); |
223 } | 223 } |
224 | 224 |
225 TEST(ParseCallFunctionResult, ScriptError) { | 225 TEST(ParseCallFunctionResult, ScriptError) { |
226 std::unique_ptr<base::Value> result; | 226 std::unique_ptr<base::Value> result; |
227 base::DictionaryValue dict; | 227 base::DictionaryValue dict; |
228 dict.SetInteger("status", 1); | 228 dict.SetInteger("status", 1); |
229 dict.SetInteger("value", 1); | 229 dict.SetInteger("value", 1); |
230 Status status = internal::ParseCallFunctionResult(dict, &result); | 230 Status status = internal::ParseCallFunctionResult(dict, &result); |
231 ASSERT_EQ(1, status.code()); | 231 ASSERT_EQ(1, status.code()); |
232 ASSERT_FALSE(result); | 232 ASSERT_FALSE(result); |
233 } | 233 } |
OLD | NEW |