diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-14 01:35:27 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-14 01:35:27 +0000 |
commit | a16ed65e3c9cd0a920692d6695b5be70ccea9c93 (patch) | |
tree | 96dd6a0224e92b76c9b0a662835ae4d08bb50985 /chrome/common/ipc_test_sink.h | |
parent | 5a82010ab774e803a0a69328fdf56a37dee91e86 (diff) | |
download | chromium_src-a16ed65e3c9cd0a920692d6695b5be70ccea9c93.zip chromium_src-a16ed65e3c9cd0a920692d6695b5be70ccea9c93.tar.gz chromium_src-a16ed65e3c9cd0a920692d6695b5be70ccea9c93.tar.bz2 |
NO CODE CHANGE.
Fix EOL-style on a few files.
Review URL: http://codereview.chromium.org/21373
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_test_sink.h')
-rw-r--r-- | chrome/common/ipc_test_sink.h | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/chrome/common/ipc_test_sink.h b/chrome/common/ipc_test_sink.h index 9403deb..fd9faee 100644 --- a/chrome/common/ipc_test_sink.h +++ b/chrome/common/ipc_test_sink.h @@ -1,84 +1,84 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_IPC_TEST_SINK_H_
-#define CHROME_COMMON_IPC_TEST_SINK_H_
-
-#include <utility>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "chrome/common/ipc_message.h"
-
-namespace IPC {
-
-// This test sink provides a "sink" for IPC messages that are sent. It allows
-// the caller to query messages received in various different ways. It is
-// designed for tests for objects that use the IPC system.
-//
-// Typical usage:
-//
-// test_sink.ClearMessages();
-// do_something();
-//
-// // We should have gotten exactly one update state message.
-// EXPECT_TRUE(test_sink.GetUniqeMessageMatching(ViewHostMsg_Update::ID));
-// // ...and no start load messages.
-// EXPECT_FALSE(test_sink.GetFirstMessageMatching(ViewHostMsg_Start::ID));
-//
-// // Now inspect a message. This assumes a message that was declared like
-// // this: IPC_MESSAGE_ROUTED2(ViewMsg_Foo, bool, int)
-// IPC::Message* msg = test_sink.GetFirstMessageMatching(ViewMsg_Foo::ID));
-// ASSERT_TRUE(msg);
-// bool first_param;
-// int second_param;
-// ViewMsg_Foo::Read(msg, &first_param, &second_param);
-//
-// // Go on to the next phase of the test.
-// test_sink.ClearMessages();
-//
-// To hook up the sink, all you need to do is call OnMessageReceived when a
-// message is recieved.
-class TestSink {
- public:
- TestSink();
- ~TestSink();
-
- // Used by the source of the messages to send the message to the sink. This
- // will make a copy of the message and store it in the list.
- void OnMessageReceived(const Message& msg);
-
- // Returns the number of messages in the queue.
- size_t message_count() const { return messages_.size(); }
-
- // Clears the message queue of saved messages.
- void ClearMessages();
-
- // Returns the message at the given index in the queue. The index may be out
- // of range, in which case the return value is NULL. The returned pointer will
- // only be valid until another message is received or the list is cleared.
- const Message* GetMessageAt(size_t index) const;
-
- // Returns the first message with the given ID in the queue. If there is no
- // message with the given ID, returns NULL. The returned pointer will only be
- // valid until another message is received or the list is cleared.
- const Message* GetFirstMessageMatching(uint16 id) const;
-
- // Returns the message with the given ID in the queue. If there is no such
- // message or there is more than one of that message, this will return NULL
- // (with the expectation that you'll do an ASSERT_TRUE() on the result).
- // The returned pointer will only be valid until another message is received
- // or the list is cleared.
- const Message* GetUniqueMessageMatching(uint16 id) const;
-
- private:
- // The actual list of received messages.
- std::vector<Message> messages_;
-
- DISALLOW_COPY_AND_ASSIGN(TestSink);
-};
-
-} // namespace IPC
-
-#endif // CHROME_COMMON_IPC_TEST_SINK_H_
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_IPC_TEST_SINK_H_ +#define CHROME_COMMON_IPC_TEST_SINK_H_ + +#include <utility> +#include <vector> + +#include "base/basictypes.h" +#include "chrome/common/ipc_message.h" + +namespace IPC { + +// This test sink provides a "sink" for IPC messages that are sent. It allows +// the caller to query messages received in various different ways. It is +// designed for tests for objects that use the IPC system. +// +// Typical usage: +// +// test_sink.ClearMessages(); +// do_something(); +// +// // We should have gotten exactly one update state message. +// EXPECT_TRUE(test_sink.GetUniqeMessageMatching(ViewHostMsg_Update::ID)); +// // ...and no start load messages. +// EXPECT_FALSE(test_sink.GetFirstMessageMatching(ViewHostMsg_Start::ID)); +// +// // Now inspect a message. This assumes a message that was declared like +// // this: IPC_MESSAGE_ROUTED2(ViewMsg_Foo, bool, int) +// IPC::Message* msg = test_sink.GetFirstMessageMatching(ViewMsg_Foo::ID)); +// ASSERT_TRUE(msg); +// bool first_param; +// int second_param; +// ViewMsg_Foo::Read(msg, &first_param, &second_param); +// +// // Go on to the next phase of the test. +// test_sink.ClearMessages(); +// +// To hook up the sink, all you need to do is call OnMessageReceived when a +// message is recieved. +class TestSink { + public: + TestSink(); + ~TestSink(); + + // Used by the source of the messages to send the message to the sink. This + // will make a copy of the message and store it in the list. + void OnMessageReceived(const Message& msg); + + // Returns the number of messages in the queue. + size_t message_count() const { return messages_.size(); } + + // Clears the message queue of saved messages. + void ClearMessages(); + + // Returns the message at the given index in the queue. The index may be out + // of range, in which case the return value is NULL. The returned pointer will + // only be valid until another message is received or the list is cleared. + const Message* GetMessageAt(size_t index) const; + + // Returns the first message with the given ID in the queue. If there is no + // message with the given ID, returns NULL. The returned pointer will only be + // valid until another message is received or the list is cleared. + const Message* GetFirstMessageMatching(uint16 id) const; + + // Returns the message with the given ID in the queue. If there is no such + // message or there is more than one of that message, this will return NULL + // (with the expectation that you'll do an ASSERT_TRUE() on the result). + // The returned pointer will only be valid until another message is received + // or the list is cleared. + const Message* GetUniqueMessageMatching(uint16 id) const; + + private: + // The actual list of received messages. + std::vector<Message> messages_; + + DISALLOW_COPY_AND_ASSIGN(TestSink); +}; + +} // namespace IPC + +#endif // CHROME_COMMON_IPC_TEST_SINK_H_ |