summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_tests.h
blob: 09a5ab8d1f6e98edb8ab04a1ae2a4731b7d02962 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2006-2008 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 IPC_IPC_TESTS_H__
#define IPC_IPC_TESTS_H__
#pragma once

#include "base/multiprocess_test.h"
#include "base/process.h"

// This unit test uses 3 types of child processes, a regular pipe client,
// a client reflector and a IPC server used for fuzzing tests.
enum ChildType {
  TEST_CLIENT,
  TEST_DESCRIPTOR_CLIENT,
  TEST_DESCRIPTOR_CLIENT_SANDBOXED,
  TEST_REFLECTOR,
  FUZZER_SERVER,
  SYNC_SOCKET_SERVER
};

// The different channel names for the child processes.
extern const char kTestClientChannel[];
extern const char kReflectorChannel[];
extern const char kFuzzerChannel[];
extern const char kSyncSocketChannel[];

class MessageLoopForIO;
namespace IPC {
class Channel;
}  // namespace IPC

//Base class to facilitate Spawning IPC Client processes.
class IPCChannelTest : public MultiProcessTest {
 protected:

  // Create a new MessageLoopForIO For each test.
  virtual void SetUp();
  virtual void TearDown();

  // Spawns a child process of the specified type
  base::ProcessHandle SpawnChild(ChildType child_type, IPC::Channel* channel);

  // Created around each test instantiation.
  MessageLoopForIO* message_loop_;
};

#endif  // IPC_IPC_TESTS_H__