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

Unified Diff: chrome/common/ipc_test_sink.cc

Issue 6290008: Move the TestSink for doing IPC tests from chrome/common into IPC and create ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/ipc_test_sink.h ('k') | chrome/renderer/mock_render_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/ipc_test_sink.cc
===================================================================
--- chrome/common/ipc_test_sink.cc (revision 71846)
+++ chrome/common/ipc_test_sink.cc (working copy)
@@ -1,59 +0,0 @@
-// Copyright (c) 2010 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.
-
-#include "chrome/common/ipc_test_sink.h"
-#include "ipc/ipc_message.h"
-
-namespace IPC {
-
-TestSink::TestSink() {
-}
-
-TestSink::~TestSink() {
-}
-
-bool TestSink::Send(IPC::Message* message) {
- OnMessageReceived(*message);
- delete message;
- return true;
-}
-
-bool TestSink::OnMessageReceived(const Message& msg) {
- messages_.push_back(Message(msg));
- return true;
-}
-
-void TestSink::ClearMessages() {
- messages_.clear();
-}
-
-const Message* TestSink::GetMessageAt(size_t index) const {
- if (index >= messages_.size())
- return NULL;
- return &messages_[index];
-}
-
-const Message* TestSink::GetFirstMessageMatching(uint32 id) const {
- for (size_t i = 0; i < messages_.size(); i++) {
- if (messages_[i].type() == id)
- return &messages_[i];
- }
- return NULL;
-}
-
-const Message* TestSink::GetUniqueMessageMatching(uint32 id) const {
- size_t found_index = 0;
- size_t found_count = 0;
- for (size_t i = 0; i < messages_.size(); i++) {
- if (messages_[i].type() == id) {
- found_count++;
- found_index = i;
- }
- }
- if (found_count != 1)
- return NULL; // Didn't find a unique one.
- return &messages_[found_index];
-}
-
-} // namespace IPC
« no previous file with comments | « chrome/common/ipc_test_sink.h ('k') | chrome/renderer/mock_render_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698