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

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: merged ToT 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. Sometimes a test needs to drain currently enqueued tasks
16 // mid-test. Browser tests should call content::RunAllPendingInMessageLoop().
17 // Unit tests should use base::RunLoop (e.g., base::RunLoop().RunUntilIdle()).
18 // TODO(phajdan.jr): Revise this comment after switch to Aura.
19 //
20 // Some tests using the IO thread expect a MessageLoopForIO. Passing
21 // IO_MAINLOOP will use a MessageLoopForIO for the main MessageLoop.
22 // Most of the time, this avoids needing to use a REAL_IO_THREAD.
23
24 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_TEST_BUNDLE_H_
25 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_THREAD_TEST_BUNDLE_H_
26
27 #include "base/memory/scoped_ptr.h"
28 #include "testing/gtest/include/gtest/gtest.h"
29
30 namespace base {
31 class MessageLoop;
32 } // namespace base
33
34 namespace content {
35
36 class TestBrowserThread;
37
38 class TestBrowserThreadBundle {
39 public:
40 // Used to specify the type of MessageLoop that backs the UI thread, and
41 // which of the named BrowserThreads should be backed by a real
42 // threads. The UI thread is always the main thread in a unit test.
43 enum Options {
44 DEFAULT = 0x00,
45 IO_MAINLOOP = 0x01,
46 REAL_DB_THREAD = 0x02,
47 REAL_WEBKIT_DEPRECATED_THREAD = 0x04,
48 REAL_FILE_THREAD = 0x08,
49 REAL_FILE_USER_BLOCKING_THREAD = 0x10,
50 REAL_PROCESS_LAUNCHER_THREAD = 0x20,
51 REAL_CACHE_THREAD = 0x40,
52 REAL_IO_THREAD = 0x80,
53 };
54
55 TestBrowserThreadBundle();
56 explicit TestBrowserThreadBundle(int options);
57
58 ~TestBrowserThreadBundle();
59
60 private:
61 void Init(int options);
62
63 scoped_ptr<base::MessageLoop> message_loop_;
64 scoped_ptr<TestBrowserThread> ui_thread_;
65 scoped_ptr<TestBrowserThread> db_thread_;
66 scoped_ptr<TestBrowserThread> webkit_deprecated_thread_;
67 scoped_ptr<TestBrowserThread> file_thread_;
68 scoped_ptr<TestBrowserThread> file_user_blocking_thread_;
69 scoped_ptr<TestBrowserThread> process_launcher_thread_;
70 scoped_ptr<TestBrowserThread> cache_thread_;
71 scoped_ptr<TestBrowserThread> io_thread_;
72
73 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadBundle);
74 };
75
76 } // namespace content
77
78 #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