OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 ASSERT_TRUE(value->GetAsDictionary(&dict)); | 31 ASSERT_TRUE(value->GetAsDictionary(&dict)); |
32 int status; | 32 int status; |
33 ASSERT_TRUE(dict->GetInteger("status", &status)); | 33 ASSERT_TRUE(dict->GetInteger("status", &status)); |
34 EXPECT_EQ(kUnknownError, status); | 34 EXPECT_EQ(kUnknownError, status); |
35 } | 35 } |
36 | 36 |
37 class DummyExecutor : public CommandExecutor { | 37 class DummyExecutor : public CommandExecutor { |
38 public: | 38 public: |
39 virtual ~DummyExecutor() {} | 39 virtual ~DummyExecutor() {} |
40 | 40 |
| 41 virtual void Init() OVERRIDE {} |
41 virtual void ExecuteCommand(const std::string& name, | 42 virtual void ExecuteCommand(const std::string& name, |
42 const base::DictionaryValue& params, | 43 const base::DictionaryValue& params, |
43 const std::string& session_id, | 44 const std::string& session_id, |
44 StatusCode* status, | 45 StatusCode* status, |
45 scoped_ptr<base::Value>* value, | 46 scoped_ptr<base::Value>* value, |
46 std::string* out_session_id) OVERRIDE { | 47 std::string* out_session_id) OVERRIDE {} |
47 } | |
48 }; | 48 }; |
49 | 49 |
50 | 50 |
51 struct ExpectedCommand { | 51 struct ExpectedCommand { |
52 ExpectedCommand( | 52 ExpectedCommand( |
53 const std::string& name, | 53 const std::string& name, |
54 const base::DictionaryValue& in_params, | 54 const base::DictionaryValue& in_params, |
55 const std::string& session_id, | 55 const std::string& session_id, |
56 StatusCode return_status, | 56 StatusCode return_status, |
57 scoped_ptr<base::Value> return_value, | 57 scoped_ptr<base::Value> return_value, |
(...skipping 15 matching lines...) Expand all Loading... |
73 scoped_ptr<base::Value> return_value; | 73 scoped_ptr<base::Value> return_value; |
74 std::string return_session_id; | 74 std::string return_session_id; |
75 }; | 75 }; |
76 | 76 |
77 class ExecutorMock : public CommandExecutor { | 77 class ExecutorMock : public CommandExecutor { |
78 public: | 78 public: |
79 virtual ~ExecutorMock() { | 79 virtual ~ExecutorMock() { |
80 EXPECT_TRUE(DidSatisfyExpectations()); | 80 EXPECT_TRUE(DidSatisfyExpectations()); |
81 } | 81 } |
82 | 82 |
| 83 virtual void Init() OVERRIDE {} |
| 84 |
83 virtual void ExecuteCommand(const std::string& name, | 85 virtual void ExecuteCommand(const std::string& name, |
84 const base::DictionaryValue& params, | 86 const base::DictionaryValue& params, |
85 const std::string& session_id, | 87 const std::string& session_id, |
86 StatusCode* status, | 88 StatusCode* status, |
87 scoped_ptr<base::Value>* value, | 89 scoped_ptr<base::Value>* value, |
88 std::string* out_session_id) OVERRIDE { | 90 std::string* out_session_id) OVERRIDE { |
89 ASSERT_TRUE(expectations_.size()); | 91 ASSERT_TRUE(expectations_.size()); |
90 ASSERT_STREQ(expectations_[0]->name.c_str(), name.c_str()); | 92 ASSERT_STREQ(expectations_[0]->name.c_str(), name.c_str()); |
91 ASSERT_TRUE(expectations_[0]->params.Equals(¶ms)); | 93 ASSERT_TRUE(expectations_[0]->params.Equals(¶ms)); |
92 ASSERT_STREQ(expectations_[0]->session_id.c_str(), session_id.c_str()); | 94 ASSERT_STREQ(expectations_[0]->session_id.c_str(), session_id.c_str()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_EQ(kOk, status); | 161 EXPECT_EQ(kOk, status); |
160 } | 162 } |
161 { | 163 { |
162 base::DictionaryValue params; | 164 base::DictionaryValue params; |
163 scoped_ptr<base::Value> value(base::Value::CreateNullValue()); | 165 scoped_ptr<base::Value> value(base::Value::CreateNullValue()); |
164 mock->Expect(scoped_ptr<ExpectedCommand>(new ExpectedCommand( | 166 mock->Expect(scoped_ptr<ExpectedCommand>(new ExpectedCommand( |
165 "quitAll", params, "", kOk, value.Pass(), ""))); | 167 "quitAll", params, "", kOk, value.Pass(), ""))); |
166 } | 168 } |
167 Shutdown(); | 169 Shutdown(); |
168 } | 170 } |
OLD | NEW |