OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // TestBrowserThreadBundle is a convenience class for creating a set of | 5 // TestBrowserThreadBundle is a convenience class for creating a set of |
6 // TestBrowserThreads, a blocking pool, and a task scheduler in unit tests. For | 6 // TestBrowserThreads, a blocking pool, and a task scheduler in unit tests. For |
7 // most tests, it is sufficient to just instantiate the TestBrowserThreadBundle | 7 // most tests, it is sufficient to just instantiate the TestBrowserThreadBundle |
8 // as a member variable. It is a good idea to put the TestBrowserThreadBundle as | 8 // as a member variable. It is a good idea to put the TestBrowserThreadBundle as |
9 // the first member variable in test classes, so it is destroyed last, and the | 9 // the first member variable in test classes, so it is destroyed last, and the |
10 // test threads always exist from the perspective of other classes. | 10 // test threads always exist from the perspective of other classes. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 // IO_MAINLOOP option. Most of the time, IO_MAINLOOP avoids needing to use a | 46 // IO_MAINLOOP option. Most of the time, IO_MAINLOOP avoids needing to use a |
47 // REAL_IO_THREAD. | 47 // REAL_IO_THREAD. |
48 // | 48 // |
49 // For some tests it is important to emulate real browser startup. During real | 49 // For some tests it is important to emulate real browser startup. During real |
50 // browser startup, the main MessageLoop is created before other threads. | 50 // browser startup, the main MessageLoop is created before other threads. |
51 // Passing DONT_CREATE_THREADS to constructor will delay creating other threads | 51 // Passing DONT_CREATE_THREADS to constructor will delay creating other threads |
52 // until the test explicitly calls CreateThreads(). | 52 // until the test explicitly calls CreateThreads(). |
53 // | 53 // |
54 // DONT_CREATE_THREADS should only be used when the options specify at least | 54 // DONT_CREATE_THREADS should only be used when the options specify at least |
55 // one real thread other than the main thread. | 55 // one real thread other than the main thread. |
56 // | |
57 // TestBrowserThreadBundle may be instantiated in a scope where there is already | |
58 // a ScopedTaskEnvironment. In that case, it will use the MessageLoop and the | |
gab
2017/05/03 17:44:41
base::test::ScopedTaskEnvironment
fdoray
2017/05/03 17:59:57
Done.
| |
59 // TaskScheduler provided by this ScopedTaskEnvironment instead of creating its | |
60 // own. The ability to have a ScopedTaskEnvironment and a | |
61 // TestBrowserThreadBundle in the same scope is useful when a fixture that | |
62 // inherits from a fixture that provides a ScopedTaskEnvironment needs to add | |
63 // support for browser threads. | |
56 | 64 |
57 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ | 65 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ |
58 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ | 66 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ |
59 | 67 |
60 #include <memory> | 68 #include <memory> |
61 | 69 |
62 #include "base/macros.h" | 70 #include "base/macros.h" |
63 | 71 |
64 namespace base { | 72 namespace base { |
65 class MessageLoop; | 73 class MessageLoop; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 119 |
112 int options_; | 120 int options_; |
113 bool threads_created_; | 121 bool threads_created_; |
114 | 122 |
115 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadBundle); | 123 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadBundle); |
116 }; | 124 }; |
117 | 125 |
118 } // namespace content | 126 } // namespace content |
119 | 127 |
120 #endif // CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ | 128 #endif // CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_BUNDLE_H_ |
OLD | NEW |