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

Side by Side Diff: mojo/system/test_utils.h

Issue 140403002: Mojo: Add the ability to hook up a channel to the embedder API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win Created 6 years, 11 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 | « mojo/system/test_embedder.cc ('k') | mojo/system/test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef MOJO_SYSTEM_TEST_UTILS_H_ 5 #ifndef MOJO_SYSTEM_TEST_UTILS_H_
6 #define MOJO_SYSTEM_TEST_UTILS_H_ 6 #define MOJO_SYSTEM_TEST_UTILS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/task_runner.h" 14 #include "base/task_runner.h"
15 #include "base/threading/thread.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 namespace tracked_objects { 19 namespace tracked_objects {
17 class Location; 20 class Location;
18 } 21 }
19 22
20 namespace mojo { 23 namespace mojo {
21 namespace system { 24 namespace system {
22 namespace test { 25 namespace test {
23 26
24 class Stopwatch { 27 class Stopwatch {
(...skipping 15 matching lines...) Expand all
40 DISALLOW_COPY_AND_ASSIGN(Stopwatch); 43 DISALLOW_COPY_AND_ASSIGN(Stopwatch);
41 }; 44 };
42 45
43 // Posts the given task (to the given task runner) and waits for it to complete. 46 // Posts the given task (to the given task runner) and waits for it to complete.
44 // (Note: Doesn't spin the current thread's message loop, so if you're careless 47 // (Note: Doesn't spin the current thread's message loop, so if you're careless
45 // this could easily deadlock.) 48 // this could easily deadlock.)
46 void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner, 49 void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner,
47 const tracked_objects::Location& from_here, 50 const tracked_objects::Location& from_here,
48 const base::Closure& task); 51 const base::Closure& task);
49 52
53 // TestWithIOThreadBase --------------------------------------------------------
54
55 class TestWithIOThreadBase : public testing::Test {
56 public:
57 TestWithIOThreadBase();
58 virtual ~TestWithIOThreadBase();
59
60 virtual void SetUp() OVERRIDE;
61 virtual void TearDown() OVERRIDE;
62
63 protected:
64 base::MessageLoop* io_thread_message_loop() {
65 return io_thread_.message_loop();
66 }
67
68 scoped_refptr<base::TaskRunner> io_thread_task_runner() {
69 return io_thread_message_loop()->message_loop_proxy();
70 }
71
72 private:
73 base::Thread io_thread_;
74
75 DISALLOW_COPY_AND_ASSIGN(TestWithIOThreadBase);
76 };
77
50 } // namespace test 78 } // namespace test
51 } // namespace system 79 } // namespace system
52 } // namespace mojo 80 } // namespace mojo
53 81
54 #endif // MOJO_SYSTEM_TEST_UTILS_H_ 82 #endif // MOJO_SYSTEM_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « mojo/system/test_embedder.cc ('k') | mojo/system/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698