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

Side by Side Diff: chrome/test/thread_test_helper.h

Issue 7239023: Move the thread test helper to base/test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | « chrome/chrome_tests.gypi ('k') | chrome/test/thread_test_helper.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) 2011 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 CHROME_TEST_THREAD_TEST_HELPER_H_
6 #define CHROME_TEST_THREAD_TEST_HELPER_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "content/browser/browser_thread.h"
13
14 // Helper class that executes code on a given thread while blocking on the
15 // invoking thread (normally the UI thread). To use, derive from this class and
16 // overwrite RunTest. An alternative use of this class is to use it directly.
17 // It will then block until all pending tasks on a given thread have been
18 // executed.
19 class ThreadTestHelper : public base::RefCountedThreadSafe<ThreadTestHelper> {
20 public:
21 explicit ThreadTestHelper(BrowserThread::ID thread_id);
22
23 // True if RunTest() was successfully executed on the target thread.
24 bool Run() WARN_UNUSED_RESULT;
25
26 virtual void RunTest();
27
28 protected:
29 friend class base::RefCountedThreadSafe<ThreadTestHelper>;
30
31 virtual ~ThreadTestHelper();
32
33 // Use this method to store the result of RunTest().
34 void set_test_result(bool test_result) { test_result_ = test_result; }
35
36 private:
37 void RunInThread();
38
39 bool test_result_;
40 BrowserThread::ID thread_id_;
41 base::WaitableEvent done_event_;
42
43 DISALLOW_COPY_AND_ASSIGN(ThreadTestHelper);
44 };
45
46 #endif // CHROME_TEST_THREAD_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/thread_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698