summaryrefslogtreecommitdiffstats
path: root/ios/web/public/test/test_web_thread.h
blob: 4ad9eb705c806b16db93a76aebaad0c6d5dbc290 (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
50
51
52
53
54
// Copyright 2014 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 IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_H_
#define IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ios/web/public/web_thread.h"

namespace base {
class MessageLoop;
}

namespace web {

class TestWebThreadImpl;

// DEPRECATED: use TestWebThreadBundle instead.
// A WebThread for unit tests; this lets unit tests outside of web create
// WebThread instances.
class TestWebThread {
 public:
  explicit TestWebThread(WebThread::ID identifier);
  TestWebThread(WebThread::ID identifier, base::MessageLoop* message_loop);

  ~TestWebThread();

  // Provides a subset of the capabilities of the Thread interface to enable
  // certain unit tests. To avoid a stronger dependency of the internals of
  // WebThread, do no provide the full Thread interface.

  // Starts the thread with a generic message loop.
  bool Start();

  // Starts the thread with an IOThread message loop.
  bool StartIOThread();

  // Stops the thread.
  void Stop();

  // Returns true if the thread is running.
  bool IsRunning();

 private:
  scoped_ptr<TestWebThreadImpl> impl_;

  DISALLOW_COPY_AND_ASSIGN(TestWebThread);
};

}  // namespace web

#endif  // IOS_WEB_PUBLIC_TEST_TEST_WEB_THREAD_H_