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

Side by Side Diff: webkit/glue/devtools/devtools_rpc_unittest.cc

Issue 173480: DevTools: Remove base/values dependency from devtools. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « webkit/glue/devtools/devtools_rpc_js.h ('k') | webkit/glue/devtools/js/devtools.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 #include "PlatformString.h"
5 #undef LOG
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "webkit/glue/devtools/devtools_mock_rpc.h"
9 #include "webkit/glue/devtools/devtools_rpc.h"
10
11 namespace {
12
13 #define TEST_RPC_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4) \
14 METHOD0(Method0) \
15 METHOD1(Method1, int) \
16 METHOD2(Method2, int, String) \
17 METHOD3(Method3, int, String, Value)
18 DEFINE_RPC_CLASS(TestRpcClass, TEST_RPC_STRUCT)
19
20 #define ANOTHER_TEST_RPC_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4) \
21 METHOD0(Method0)
22 DEFINE_RPC_CLASS(AnotherTestRpcClass, ANOTHER_TEST_RPC_STRUCT)
23
24 class MockTestRpcClass : public TestRpcClassStub,
25 public DevToolsMockRpc {
26 public:
27 MockTestRpcClass() : TestRpcClassStub(NULL) {
28 set_delegate(this);
29 }
30 ~MockTestRpcClass() {}
31 };
32
33 class MockAnotherTestRpcClass : public AnotherTestRpcClassStub,
34 public DevToolsMockRpc {
35 public:
36 MockAnotherTestRpcClass() : AnotherTestRpcClassStub(NULL) {
37 set_delegate(this);
38 }
39 ~MockAnotherTestRpcClass() {}
40 };
41
42 class DevToolsRpcTests : public testing::Test {
43 public:
44 DevToolsRpcTests() {}
45
46 protected:
47 virtual void SetUp() {}
48 virtual void TearDown() {}
49 };
50
51 // Tests method call serialization.
52 TEST_F(DevToolsRpcTests, TestSerialize) {
53 MockTestRpcClass mock;
54 mock.Method0();
55 EXPECT_EQ("TestRpcClass", mock.last_class_name());
56 EXPECT_EQ("Method0", mock.last_method_name());
57 EXPECT_EQ("[]", mock.last_msg());
58 mock.Reset();
59
60 mock.Method1(10);
61 EXPECT_EQ("TestRpcClass", mock.last_class_name());
62 EXPECT_EQ("Method1", mock.last_method_name());
63 EXPECT_EQ("[10]", mock.last_msg());
64 mock.Reset();
65
66 mock.Method2(20, "foo");
67 EXPECT_EQ("TestRpcClass", mock.last_class_name());
68 EXPECT_EQ("Method2", mock.last_method_name());
69 EXPECT_EQ("[20,\"foo\"]", mock.last_msg());
70 mock.Reset();
71
72 StringValue value("bar");
73 mock.Method3(30, "foo", value);
74 EXPECT_EQ("TestRpcClass", mock.last_class_name());
75 EXPECT_EQ("Method3", mock.last_method_name());
76 EXPECT_EQ("[30,\"foo\",\"bar\"]", mock.last_msg());
77 mock.Reset();
78 }
79
80 // Tests method call dispatch.
81 TEST_F(DevToolsRpcTests, TestDispatch) {
82 MockTestRpcClass local;
83 MockTestRpcClass remote;
84
85 // Call 1.
86 local.Reset();
87 local.Method0();
88 remote.Reset();
89 remote.Method0();
90 remote.Replay();
91
92 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
93 local.last_method_name(), local.last_msg());
94 remote.Verify();
95
96 // Call 2.
97 local.Reset();
98 local.Method1(10);
99 remote.Reset();
100 remote.Method1(10);
101 remote.Replay();
102 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
103 local.last_method_name(), local.last_msg());
104 remote.Verify();
105
106 // Call 3.
107 local.Reset();
108 remote.Reset();
109 local.Method2(20, "foo");
110 remote.Method2(20, "foo");
111
112 remote.Replay();
113 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
114 local.last_method_name(), local.last_msg());
115 remote.Verify();
116
117 // Call 4.
118 local.Reset();
119 remote.Reset();
120 StringValue value("bar");
121 local.Method3(30, "foo", value);
122 remote.Method3(30, "foo", value);
123
124 remote.Replay();
125 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(),
126 local.last_method_name(), local.last_msg());
127 remote.Verify();
128 }
129
130 } // namespace
OLDNEW
« no previous file with comments | « webkit/glue/devtools/devtools_rpc_js.h ('k') | webkit/glue/devtools/js/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698