1 // Copyright (c) 2012 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_PUBLIC_TEST_TEST_BROWSER_THREAD_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/scoped_ptr.h" 10 #include "content/public/browser/browser_thread.h" 11 12 namespace base { 13 class MessageLoop; 14 class Thread; 15 } 16 17 namespace content { 18 19 class TestBrowserThreadImpl; 20 21 // DEPRECATED: use TestBrowserThreadBundle instead. See http://crbug.com/272091 22 // A BrowserThread for unit tests; this lets unit tests in chrome/ create 23 // BrowserThread instances. 24 class TestBrowserThread { 25 public: 26 explicit TestBrowserThread(BrowserThread::ID identifier); 27 TestBrowserThread(BrowserThread::ID identifier, 28 base::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 private: 53 scoped_ptr<TestBrowserThreadImpl> impl_; 54 55 DISALLOW_COPY_AND_ASSIGN(TestBrowserThread); 56 }; 57 58 } // namespace content 59 60 #endif // CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_H_ 61