Chromium Code Reviews| Index: content/public/test/test_browser_thread_bundle.h |
| diff --git a/content/public/test/test_browser_thread_bundle.h b/content/public/test/test_browser_thread_bundle.h |
| index 4a6b030c21f67b83e59c3cc0a4aacfaf06baf790..ebc3a5f67fe96d4eea1cb3d4c4619a0abfcf4001 100644 |
| --- a/content/public/test/test_browser_thread_bundle.h |
| +++ b/content/public/test/test_browser_thread_bundle.h |
| @@ -25,6 +25,10 @@ |
| // FileDescriptorWatcher. Most of the time, IO_MAINLOOP avoids needing to use a |
| // REAL_IO_THREAD. |
| // |
| +// If a test needs a TaskScheduler that runs tasks on a dedicated thread, it |
| +// should use REAL_TASK_SCHEDULER. Usage of this option should be justified as |
| +// it is easier to understand and debug a single-threaded unit test. |
| +// |
| // For some tests it is important to emulate real browser startup. During real |
| // browser startup, the main MessageLoop is created before other threads. |
| // Passing DONT_CREATE_THREADS to constructor will delay creating other threads |
| @@ -43,6 +47,7 @@ |
| namespace base { |
| class MessageLoop; |
| namespace test { |
| +class ScopedAsyncTaskScheduler; |
| class ScopedTaskScheduler; |
| } // namespace test |
| } // namespace base |
| @@ -57,12 +62,13 @@ class TestBrowserThreadBundle { |
| // which of the named BrowserThreads should be backed by a real |
| // threads. The UI thread is always the main thread in a unit test. |
| enum Options { |
| - DEFAULT = 0x00, |
| - IO_MAINLOOP = 0x01, |
| - REAL_DB_THREAD = 0x02, |
| - REAL_FILE_THREAD = 0x08, |
| - REAL_IO_THREAD = 0x10, |
| - DONT_CREATE_THREADS = 0x20, |
| + DEFAULT = 0, |
| + IO_MAINLOOP = 1 << 0, |
|
robliao
2017/01/12 21:36:01
While we're here, might be worthwhile to comment t
fdoray
2017/01/13 13:11:45
Done. Reenumerated. There is no good reason not to
|
| + REAL_DB_THREAD = 1 << 2, |
| + REAL_FILE_THREAD = 1 << 3, |
| + REAL_IO_THREAD = 1 << 4, |
| + REAL_TASK_SCHEDULER = 1 << 5, |
| + DONT_CREATE_THREADS = 1 << 6, |
| }; |
| TestBrowserThreadBundle(); |
| @@ -78,7 +84,9 @@ class TestBrowserThreadBundle { |
| void Init(); |
| std::unique_ptr<base::MessageLoop> message_loop_; |
| - std::unique_ptr<base::test::ScopedTaskScheduler> task_scheduler_; |
| + std::unique_ptr<base::test::ScopedAsyncTaskScheduler> |
| + scoped_async_task_scheduler_; |
| + std::unique_ptr<base::test::ScopedTaskScheduler> scoped_task_scheduler_; |
| std::unique_ptr<TestBrowserThread> ui_thread_; |
| std::unique_ptr<TestBrowserThread> db_thread_; |
| std::unique_ptr<TestBrowserThread> file_thread_; |