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

Side by Side Diff: webkit/glue/devtools/devtools_mock_rpc.h

Issue 115862: DevTools: pass class and method name as arguments to RPC messages (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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/renderer/devtools_client.cc ('k') | webkit/glue/devtools/devtools_rpc.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MOCK_RPC_H_ 5 #ifndef WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MOCK_RPC_H_
6 #define WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MOCK_RPC_H_ 6 #define WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MOCK_RPC_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webkit/glue/devtools/devtools_rpc.h" 12 #include "webkit/glue/devtools/devtools_rpc.h"
13 #include "webkit/glue/glue_util.h" 13 #include "webkit/glue/glue_util.h"
14 14
15 // Universal mock delegate for DevToolsRpc. Typical usage of the mock is: 15 // Universal mock delegate for DevToolsRpc. Typical usage of the mock is:
16 // mock->Method1(); // Set expectation. 16 // mock->Method1(); // Set expectation.
17 // mock->Replay(); 17 // mock->Replay();
18 // // Do Something here; 18 // // Do Something here;
19 // mock->Verify(); // Verify. 19 // mock->Verify(); // Verify.
20 class DevToolsMockRpc : public DevToolsRpc::Delegate { 20 class DevToolsMockRpc : public DevToolsRpc::Delegate {
21 public: 21 public:
22 DevToolsMockRpc() {} 22 DevToolsMockRpc() {}
23 ~DevToolsMockRpc() {} 23 ~DevToolsMockRpc() {}
24 24
25 virtual void SendRpcMessage(const std::string& msg) { 25 virtual void SendRpcMessage(const std::string& class_name,
26 const std::string& method_name,
27 const std::string& msg) {
28 last_class_name_ = class_name;
29 last_method_name_ = method_name;
30 last_msg_ = msg;
31
26 if (!log_.length()) { 32 if (!log_.length()) {
27 log_ = msg; 33 log_ = StringPrintf("%s %s %s", class_name.c_str(),
34 method_name.c_str(), msg.c_str());;
28 } else { 35 } else {
29 log_ = StringPrintf("%s\n%s", log_.c_str(), msg.c_str()); 36 log_ = StringPrintf("%s\n%s %s %s", log_.c_str(), class_name.c_str(),
37 method_name.c_str(), msg.c_str());
30 } 38 }
31 } 39 }
32 40
33 void Replay() { 41 void Replay() {
42 ref_last_class_name_ = last_class_name_;
43 last_class_name_ = "";
44 ref_last_method_name_ = last_method_name_;
45 last_method_name_ = "";
46 ref_last_msg_ = last_msg_;
47 last_msg_ = "";
48
34 ref_log_ = log_; 49 ref_log_ = log_;
35 log_ = ""; 50 log_ = "";
36 } 51 }
37 52
38 void Verify() { 53 void Verify() {
54 ASSERT_EQ(ref_last_class_name_, last_class_name_);
55 ASSERT_EQ(ref_last_method_name_, last_method_name_);
56 ASSERT_EQ(ref_last_msg_, last_msg_);
39 ASSERT_EQ(ref_log_, log_); 57 ASSERT_EQ(ref_log_, log_);
40 } 58 }
41 59
42 void Reset() { 60 void Reset() {
61 last_class_name_ = "";
62 last_method_name_ = "";
63 last_msg_ = "";
64
65 ref_last_class_name_ = "";
66 ref_last_method_name_ = "";
67 ref_last_msg_ = "";
68
43 ref_log_ = ""; 69 ref_log_ = "";
44 log_ = ""; 70 log_ = "";
45 } 71 }
46 72
47 const std::string &get_log() { return log_; } 73 const std::string& last_class_name() { return last_class_name_; }
74 const std::string& last_method_name() { return last_method_name_; }
75 const std::string& last_msg() { return last_msg_; }
48 76
49 private: 77 private:
78 std::string last_class_name_;
79 std::string last_method_name_;
80 std::string last_msg_;
81
82 std::string ref_last_class_name_;
83 std::string ref_last_method_name_;
84 std::string ref_last_msg_;
85
50 std::string log_; 86 std::string log_;
51 std::string ref_log_; 87 std::string ref_log_;
52 DISALLOW_COPY_AND_ASSIGN(DevToolsMockRpc); 88 DISALLOW_COPY_AND_ASSIGN(DevToolsMockRpc);
53 }; 89 };
54 90
55 #endif // WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MOCK_RPC_H_ 91 #endif // WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_MOCK_RPC_H_
OLDNEW
« no previous file with comments | « chrome/renderer/devtools_client.cc ('k') | webkit/glue/devtools/devtools_rpc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698