OLD | NEW |
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 #include "PlatformString.h" | 4 #include "PlatformString.h" |
5 #undef LOG | 5 #undef LOG |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "webkit/glue/devtools/devtools_mock_rpc.h" | 8 #include "webkit/glue/devtools/devtools_mock_rpc.h" |
9 #include "webkit/glue/devtools/devtools_rpc.h" | 9 #include "webkit/glue/devtools/devtools_rpc.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 protected: | 46 protected: |
47 virtual void SetUp() {} | 47 virtual void SetUp() {} |
48 virtual void TearDown() {} | 48 virtual void TearDown() {} |
49 }; | 49 }; |
50 | 50 |
51 // Tests method call serialization. | 51 // Tests method call serialization. |
52 TEST_F(DevToolsRpcTests, TestSerialize) { | 52 TEST_F(DevToolsRpcTests, TestSerialize) { |
53 MockTestRpcClass mock; | 53 MockTestRpcClass mock; |
54 mock.Method0(); | 54 mock.Method0(); |
55 EXPECT_EQ("[\"TestRpcClass\",\"Method0\"]", mock.get_log()); | 55 EXPECT_EQ("TestRpcClass", mock.last_class_name()); |
| 56 EXPECT_EQ("Method0", mock.last_method_name()); |
| 57 EXPECT_EQ("[]", mock.last_msg()); |
56 mock.Reset(); | 58 mock.Reset(); |
57 | 59 |
58 mock.Method1(10); | 60 mock.Method1(10); |
59 EXPECT_EQ("[\"TestRpcClass\",\"Method1\",10]", mock.get_log()); | 61 EXPECT_EQ("TestRpcClass", mock.last_class_name()); |
| 62 EXPECT_EQ("Method1", mock.last_method_name()); |
| 63 EXPECT_EQ("[10]", mock.last_msg()); |
60 mock.Reset(); | 64 mock.Reset(); |
61 | 65 |
62 mock.Method2(20, "foo"); | 66 mock.Method2(20, "foo"); |
63 EXPECT_EQ("[\"TestRpcClass\",\"Method2\",20,\"foo\"]", mock.get_log()); | 67 EXPECT_EQ("TestRpcClass", mock.last_class_name()); |
| 68 EXPECT_EQ("Method2", mock.last_method_name()); |
| 69 EXPECT_EQ("[20,\"foo\"]", mock.last_msg()); |
64 mock.Reset(); | 70 mock.Reset(); |
65 | 71 |
66 StringValue value("bar"); | 72 StringValue value("bar"); |
67 mock.Method3(30, "foo", value); | 73 mock.Method3(30, "foo", value); |
68 EXPECT_EQ("[\"TestRpcClass\",\"Method3\",30,\"foo\",\"bar\"]", | 74 EXPECT_EQ("TestRpcClass", mock.last_class_name()); |
69 mock.get_log()); | 75 EXPECT_EQ("Method3", mock.last_method_name()); |
| 76 EXPECT_EQ("[30,\"foo\",\"bar\"]", mock.last_msg()); |
70 mock.Reset(); | 77 mock.Reset(); |
71 } | 78 } |
72 | 79 |
73 // Tests method call dispatch. | 80 // Tests method call dispatch. |
74 TEST_F(DevToolsRpcTests, TestDispatch) { | 81 TEST_F(DevToolsRpcTests, TestDispatch) { |
75 MockTestRpcClass local; | 82 MockTestRpcClass local; |
76 MockTestRpcClass remote; | 83 MockTestRpcClass remote; |
77 | 84 |
78 // Call 1. | 85 // Call 1. |
79 local.Reset(); | 86 local.Reset(); |
80 local.Method0(); | 87 local.Method0(); |
81 remote.Reset(); | 88 remote.Reset(); |
82 remote.Method0(); | 89 remote.Method0(); |
83 remote.Replay(); | 90 remote.Replay(); |
84 | 91 |
85 TestRpcClassDispatch::Dispatch(&remote, local.get_log()); | 92 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(), |
| 93 local.last_method_name(), local.last_msg()); |
86 remote.Verify(); | 94 remote.Verify(); |
87 | 95 |
88 // Call 2. | 96 // Call 2. |
89 local.Reset(); | 97 local.Reset(); |
90 local.Method1(10); | 98 local.Method1(10); |
91 remote.Reset(); | 99 remote.Reset(); |
92 remote.Method1(10); | 100 remote.Method1(10); |
93 remote.Replay(); | 101 remote.Replay(); |
94 TestRpcClassDispatch::Dispatch(&remote, local.get_log()); | 102 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(), |
| 103 local.last_method_name(), local.last_msg()); |
95 remote.Verify(); | 104 remote.Verify(); |
96 | 105 |
97 // Call 3. | 106 // Call 3. |
98 local.Reset(); | 107 local.Reset(); |
99 remote.Reset(); | 108 remote.Reset(); |
100 local.Method2(20, "foo"); | 109 local.Method2(20, "foo"); |
101 remote.Method2(20, "foo"); | 110 remote.Method2(20, "foo"); |
102 | 111 |
103 remote.Replay(); | 112 remote.Replay(); |
104 TestRpcClassDispatch::Dispatch(&remote, local.get_log()); | 113 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(), |
| 114 local.last_method_name(), local.last_msg()); |
105 remote.Verify(); | 115 remote.Verify(); |
106 | 116 |
107 // Call 4. | 117 // Call 4. |
108 local.Reset(); | 118 local.Reset(); |
109 remote.Reset(); | 119 remote.Reset(); |
110 StringValue value("bar"); | 120 StringValue value("bar"); |
111 local.Method3(30, "foo", value); | 121 local.Method3(30, "foo", value); |
112 remote.Method3(30, "foo", value); | 122 remote.Method3(30, "foo", value); |
113 | 123 |
114 remote.Replay(); | 124 remote.Replay(); |
115 TestRpcClassDispatch::Dispatch(&remote, local.get_log()); | 125 TestRpcClassDispatch::Dispatch(&remote, local.last_class_name(), |
| 126 local.last_method_name(), local.last_msg()); |
116 remote.Verify(); | 127 remote.Verify(); |
117 } | 128 } |
118 | 129 |
119 } // namespace | 130 } // namespace |
OLD | NEW |