Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: content/public/test/test_browser_thread_bundle.h

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile fixes. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/test_browser_thread_bundle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 // TestBrowserThreadBundle is a convenience class for creating a set of
6 // TestBrowserThreads in unit tests. For most tests, it is sufficient to
7 // just instantiate the TestBrowserThreadBundle as a member variable.
8 //
9 // By default, all of the created TestBrowserThreads will be backed by a single
10 // shared MessageLoop. If a test truly needs separate threads, it can do
11 // so by passing the appropriate combination of RealThreadsMask values during
12 // the TestBrowserThreadBundle construction.
13 //
14 // The TestBrowserThreadBundle will attempt to drain the MessageLoop on
15 // destruction. If a test needs to drain currently enqueued tasks mid-test,
16 // it should call content::RunAllPendingInMessageLoop() or use base::RunLoop
17 // (eg., base::RunLoop().RunUntilIdle()) as appropriate.
jam 2013/06/05 17:01:39 I think saying "as appropriate" won't be clear. i.
awong 2013/06/05 17:54:38 My confusion is as follows: - This CL uses base:
awong 2013/06/05 21:16:56 Comment amended say RunLoop for unit tests and con
18 //
19 // Some tests using the IO thread expect a MessageLoopForIO. Passing
20 // USE_IO_LOOP_FOR_UI will use a MessageLoopForIO for the main MessageLoop.
21 // Most of the time, this avoids needing to use a REAL_IO_THREAD.
22
23 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_TEST_BUNDLE_H_
24 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_TEST_BUNDLE_H_
25
26 #include "base/memory/scoped_ptr.h"
27 #include "testing/gtest/include/gtest/gtest.h"
28
29 namespace base {
30 class MessageLoop;
31 } // namespace base
32
33 namespace content {
34
35 class TestBrowserThread;
36
37 class TestBrowserThreadBundle {
38 public:
39 // Used to specify the type of MessageLoop that backs the UI thread, and
40 // which of the named BrowserThreads should be backed by a real
41 // threads. The UI thread is always the main thread in a unit test.
42 enum Options {
43 DEFAULT = 0x00,
44 IO_MAINLOOP = 0x01,
45 REAL_DB_THREAD = 0x02,
46 REAL_WEBKIT_DEPRECATED_THREAD = 0x04,
47 REAL_FILE_THREAD = 0x08,
48 REAL_FILE_USER_BLOCKING_THREAD = 0x10,
49 REAL_PROCESS_LAUNCHER_THREAD = 0x20,
50 REAL_CACHE_THREAD = 0x40,
51 REAL_IO_THREAD = 0x80,
52 };
53
54 TestBrowserThreadBundle();
55 explicit TestBrowserThreadBundle(int options);
56
57 ~TestBrowserThreadBundle();
58
59 private:
60 void Init(int options);
61
62 scoped_ptr<base::MessageLoop> message_loop_;
63 scoped_ptr<TestBrowserThread> ui_thread_;
64 scoped_ptr<TestBrowserThread> db_thread_;
65 scoped_ptr<TestBrowserThread> webkit_deprecated_thread_;
66 scoped_ptr<TestBrowserThread> file_thread_;
67 scoped_ptr<TestBrowserThread> file_user_blocking_thread_;
68 scoped_ptr<TestBrowserThread> process_launcher_thread_;
69 scoped_ptr<TestBrowserThread> cache_thread_;
70 scoped_ptr<TestBrowserThread> io_thread_;
71
72 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadBundle);
73 };
74
75 } // namespace content
76
77 #endif /* CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_TEST_BUNDLE_H_ */
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/test_browser_thread_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698