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 <list> | 5 #include <list> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 void set_status(const Status& status) { | 23 void set_status(const Status& status) { |
24 status_ = status; | 24 status_ = status; |
25 } | 25 } |
26 void set_result(const base::DictionaryValue& result) { | 26 void set_result(const base::DictionaryValue& result) { |
27 result_.Clear(); | 27 result_.Clear(); |
28 result_.MergeDictionary(&result); | 28 result_.MergeDictionary(&result); |
29 } | 29 } |
30 | 30 |
31 // Overridden from DevToolsClient: | 31 // Overridden from DevToolsClient: |
32 virtual const std::string& GetId() OVERRIDE { | 32 virtual const std::string& GetId() override { |
33 return id_; | 33 return id_; |
34 } | 34 } |
35 virtual bool WasCrashed() OVERRIDE { | 35 virtual bool WasCrashed() override { |
36 return false; | 36 return false; |
37 } | 37 } |
38 virtual Status ConnectIfNecessary() OVERRIDE { | 38 virtual Status ConnectIfNecessary() override { |
39 return Status(kOk); | 39 return Status(kOk); |
40 } | 40 } |
41 virtual Status SendCommand(const std::string& method, | 41 virtual Status SendCommand(const std::string& method, |
42 const base::DictionaryValue& params) OVERRIDE { | 42 const base::DictionaryValue& params) override { |
43 return SendCommandAndGetResult(method, params, NULL); | 43 return SendCommandAndGetResult(method, params, NULL); |
44 } | 44 } |
45 virtual Status SendCommandAndGetResult( | 45 virtual Status SendCommandAndGetResult( |
46 const std::string& method, | 46 const std::string& method, |
47 const base::DictionaryValue& params, | 47 const base::DictionaryValue& params, |
48 scoped_ptr<base::DictionaryValue>* result) OVERRIDE { | 48 scoped_ptr<base::DictionaryValue>* result) override { |
49 if (status_.IsError()) | 49 if (status_.IsError()) |
50 return status_; | 50 return status_; |
51 result->reset(result_.DeepCopy()); | 51 result->reset(result_.DeepCopy()); |
52 return Status(kOk); | 52 return Status(kOk); |
53 } | 53 } |
54 virtual void AddListener(DevToolsEventListener* listener) OVERRIDE {} | 54 virtual void AddListener(DevToolsEventListener* listener) override {} |
55 virtual Status HandleEventsUntil( | 55 virtual Status HandleEventsUntil( |
56 const ConditionalFunc& conditional_func, | 56 const ConditionalFunc& conditional_func, |
57 const base::TimeDelta& timeout) OVERRIDE { | 57 const base::TimeDelta& timeout) override { |
58 return Status(kOk); | 58 return Status(kOk); |
59 } | 59 } |
60 virtual Status HandleReceivedEvents() OVERRIDE { | 60 virtual Status HandleReceivedEvents() override { |
61 return Status(kOk); | 61 return Status(kOk); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 const std::string id_; | 65 const std::string id_; |
66 Status status_; | 66 Status status_; |
67 base::DictionaryValue result_; | 67 base::DictionaryValue result_; |
68 }; | 68 }; |
69 | 69 |
70 void AssertEvalFails(const base::DictionaryValue& command_result) { | 70 void AssertEvalFails(const base::DictionaryValue& command_result) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 TEST(ParseCallFunctionResult, ScriptError) { | 209 TEST(ParseCallFunctionResult, ScriptError) { |
210 scoped_ptr<base::Value> result; | 210 scoped_ptr<base::Value> result; |
211 base::DictionaryValue dict; | 211 base::DictionaryValue dict; |
212 dict.SetInteger("status", 1); | 212 dict.SetInteger("status", 1); |
213 dict.SetInteger("value", 1); | 213 dict.SetInteger("value", 1); |
214 Status status = internal::ParseCallFunctionResult(dict, &result); | 214 Status status = internal::ParseCallFunctionResult(dict, &result); |
215 ASSERT_EQ(1, status.code()); | 215 ASSERT_EQ(1, status.code()); |
216 ASSERT_FALSE(result); | 216 ASSERT_FALSE(result); |
217 } | 217 } |
OLD | NEW |