OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef CONTENT_TEST_TEST_BROWSER_THREAD_H_ | |
6 #define CONTENT_TEST_TEST_BROWSER_THREAD_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "content/public/browser/browser_thread.h" | |
12 | |
13 class MessageLoop; | |
14 | |
15 namespace base { | |
16 class Thread; | |
17 } | |
18 | |
19 namespace content { | |
20 | |
21 class TestBrowserThreadImpl; | |
22 | |
23 // A BrowserThread for unit tests; this lets unit tests in chrome/ | |
24 // create BrowserThread instances. | |
25 class TestBrowserThread { | |
26 public: | |
27 explicit TestBrowserThread(BrowserThread::ID identifier); | |
28 TestBrowserThread(BrowserThread::ID identifier, MessageLoop* message_loop); | |
29 ~TestBrowserThread(); | |
30 | |
31 // We provide a subset of the capabilities of the Thread interface | |
32 // to enable certain unit tests. To avoid a stronger dependency of | |
33 // the internals of BrowserThread, we do not provide the full Thread | |
34 // interface. | |
35 | |
36 // Starts the thread with a generic message loop. | |
37 bool Start(); | |
38 | |
39 // Starts the thread with an IOThread message loop. | |
40 bool StartIOThread(); | |
41 | |
42 // Stops the thread. | |
43 void Stop(); | |
44 | |
45 // Returns true if the thread is running. | |
46 bool IsRunning(); | |
47 | |
48 // Returns a Thread pointer for the thread. This should not be used | |
49 // in new tests. | |
50 base::Thread* DeprecatedGetThreadObject(); | |
51 | |
52 // Sets the message loop to use for the thread. This should not be | |
53 // used in new tests. | |
54 void DeprecatedSetMessageLoop(MessageLoop* loop); | |
55 | |
56 private: | |
57 scoped_ptr<TestBrowserThreadImpl> impl_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(TestBrowserThread); | |
60 }; | |
61 | |
62 } // namespace content | |
63 | |
64 #endif // CONTENT_TEST_TEST_BROWSER_THREAD_H_ | |
OLD | NEW |