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 | 4 |
5 #ifndef CHROME_COMMON_IPC_TEST_SINK_H_ | 5 #ifndef CHROME_COMMON_IPC_TEST_SINK_H_ |
6 #define CHROME_COMMON_IPC_TEST_SINK_H_ | 6 #define CHROME_COMMON_IPC_TEST_SINK_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // IPC::Message* msg = test_sink.GetFirstMessageMatching(ViewMsg_Foo::ID)); | 32 // IPC::Message* msg = test_sink.GetFirstMessageMatching(ViewMsg_Foo::ID)); |
33 // ASSERT_TRUE(msg); | 33 // ASSERT_TRUE(msg); |
34 // bool first_param; | 34 // bool first_param; |
35 // int second_param; | 35 // int second_param; |
36 // ViewMsg_Foo::Read(msg, &first_param, &second_param); | 36 // ViewMsg_Foo::Read(msg, &first_param, &second_param); |
37 // | 37 // |
38 // // Go on to the next phase of the test. | 38 // // Go on to the next phase of the test. |
39 // test_sink.ClearMessages(); | 39 // test_sink.ClearMessages(); |
40 // | 40 // |
41 // To hook up the sink, all you need to do is call OnMessageReceived when a | 41 // To hook up the sink, all you need to do is call OnMessageReceived when a |
42 // message is recieved. | 42 // message is received. |
43 class TestSink { | 43 class TestSink { |
44 public: | 44 public: |
45 TestSink(); | 45 TestSink(); |
46 ~TestSink(); | 46 ~TestSink(); |
47 | 47 |
48 // Used by the source of the messages to send the message to the sink. This | 48 // Used by the source of the messages to send the message to the sink. This |
49 // will make a copy of the message and store it in the list. | 49 // will make a copy of the message and store it in the list. |
50 void OnMessageReceived(const Message& msg); | 50 void OnMessageReceived(const Message& msg); |
51 | 51 |
52 // Returns the number of messages in the queue. | 52 // Returns the number of messages in the queue. |
(...skipping 22 matching lines...) Expand all Loading... |
75 private: | 75 private: |
76 // The actual list of received messages. | 76 // The actual list of received messages. |
77 std::vector<Message> messages_; | 77 std::vector<Message> messages_; |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(TestSink); | 79 DISALLOW_COPY_AND_ASSIGN(TestSink); |
80 }; | 80 }; |
81 | 81 |
82 } // namespace IPC | 82 } // namespace IPC |
83 | 83 |
84 #endif // CHROME_COMMON_IPC_TEST_SINK_H_ | 84 #endif // CHROME_COMMON_IPC_TEST_SINK_H_ |
OLD | NEW |