| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 IPC_IPC_TEST_SINK_H_ | 5 #ifndef IPC_IPC_TEST_SINK_H_ |
| 6 #define IPC_IPC_TEST_SINK_H_ | 6 #define IPC_IPC_TEST_SINK_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // int second_param; | 38 // int second_param; |
| 39 // ViewMsg_Foo::Read(msg, &first_param, &second_param); | 39 // ViewMsg_Foo::Read(msg, &first_param, &second_param); |
| 40 // | 40 // |
| 41 // // Go on to the next phase of the test. | 41 // // Go on to the next phase of the test. |
| 42 // test_sink.ClearMessages(); | 42 // test_sink.ClearMessages(); |
| 43 // | 43 // |
| 44 // To read a sync reply, do this: | 44 // To read a sync reply, do this: |
| 45 // | 45 // |
| 46 // IPC::Message* msg = test_sink.GetUniqueMessageMatching(IPC_REPLY_ID); | 46 // IPC::Message* msg = test_sink.GetUniqueMessageMatching(IPC_REPLY_ID); |
| 47 // ASSERT_TRUE(msg); | 47 // ASSERT_TRUE(msg); |
| 48 // TupleTypes<ViewHostMsg_Foo::ReplyParam>::ValueTuple reply_data; | 48 // base::TupleTypes<ViewHostMsg_Foo::ReplyParam>::ValueTuple reply_data; |
| 49 // EXPECT_TRUE(ViewHostMsg_Foo::ReadReplyParam(msg, &reply_data)); | 49 // EXPECT_TRUE(ViewHostMsg_Foo::ReadReplyParam(msg, &reply_data)); |
| 50 // | 50 // |
| 51 // You can also register to be notified when messages are posted to the sink. | 51 // You can also register to be notified when messages are posted to the sink. |
| 52 // This can be useful if you need to wait for a particular message that will | 52 // This can be useful if you need to wait for a particular message that will |
| 53 // be posted asynchronously. Example usage: | 53 // be posted asynchronously. Example usage: |
| 54 // | 54 // |
| 55 // class MyListener : public IPC::Listener { | 55 // class MyListener : public IPC::Listener { |
| 56 // public: | 56 // public: |
| 57 // virtual bool OnMessageReceived(const IPC::Message& msg) { | 57 // virtual bool OnMessageReceived(const IPC::Message& msg) { |
| 58 // <do something with the message> | 58 // <do something with the message> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // The actual list of received messages. | 129 // The actual list of received messages. |
| 130 std::vector<Message> messages_; | 130 std::vector<Message> messages_; |
| 131 ObserverList<Listener> filter_list_; | 131 ObserverList<Listener> filter_list_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(TestSink); | 133 DISALLOW_COPY_AND_ASSIGN(TestSink); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace IPC | 136 } // namespace IPC |
| 137 | 137 |
| 138 #endif // IPC_IPC_TEST_SINK_H_ | 138 #endif // IPC_IPC_TEST_SINK_H_ |
| OLD | NEW |