1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IPC_IPC_TEST_CHANNEL_LISTENER_H_
6 #define IPC_IPC_TEST_CHANNEL_LISTENER_H_
10 #include "ipc/ipc_listener.h"
16 // A generic listener that expects messages of a certain type (see
17 // OnMessageReceived()), and either sends a generic response or quits after the
18 // 50th message (or on channel error).
19 class TestChannelListener
: public Listener
{
21 static const size_t kLongMessageStringNumBytes
= 50000;
22 static void SendOneMessage(Sender
* sender
, const char* text
);
24 TestChannelListener() : sender_(NULL
), messages_left_(50) {}
25 ~TestChannelListener() override
{}
27 bool OnMessageReceived(const Message
& message
) override
;
28 void OnChannelError() override
;
30 void Init(Sender
* s
) {
34 bool HasSentAll() const { return 0 == messages_left_
; }
37 void SendNextMessage();
46 #endif // IPC_IPC_TEST_CHANNEL_LISTENER_H_