OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SHELL_SHELL_TEST_HELPER_ | 5 #ifndef MOJO_SHELL_SHELL_TEST_HELPER_ |
6 #define MOJO_SHELL_SHELL_TEST_HELPER_ | 6 #define MOJO_SHELL_SHELL_TEST_HELPER_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | |
12 #include "mojo/service_manager/service_loader.h" | 11 #include "mojo/service_manager/service_loader.h" |
13 #include "mojo/shell/context.h" | 12 #include "mojo/shell/context.h" |
14 | 13 |
15 class GURL; | 14 class GURL; |
16 | 15 |
17 namespace mojo { | 16 namespace mojo { |
18 | 17 |
19 class ServiceLoader; | 18 class ServiceLoader; |
20 | 19 |
21 namespace shell { | 20 namespace shell { |
22 | 21 |
23 // ShellTestHelper is useful for tests to establish a connection to the | 22 // ShellTestHelper is useful for tests to establish a connection to the |
24 // ServiceProvider. Invoke Init() to establish the connection. Once done, | 23 // ServiceManager. Invoke Init() to establish the connection. Once done, |
25 // service_provider() returns the handle to the ServiceProvider. | 24 // service_manager() returns the ServiceManager. |
26 class ShellTestHelper { | 25 class ShellTestHelper { |
27 public: | 26 public: |
28 ShellTestHelper(); | 27 ShellTestHelper(); |
29 ~ShellTestHelper(); | 28 ~ShellTestHelper(); |
30 | 29 |
31 void Init(); | 30 void Init(); |
32 | 31 |
33 // Returns a handle to the ServiceManager. ShellTestHelper owns the | |
34 // ServiceProvider. | |
35 ServiceManager* service_manager() { return context_.service_manager(); } | 32 ServiceManager* service_manager() { return context_.service_manager(); } |
36 | 33 |
37 // Sets a ServiceLoader for the specified URL. |loader| is ultimately used on | 34 // Sets a ServiceLoader for the specified URL. |loader| is ultimately used on |
38 // the thread this class spawns. | 35 // the thread this class spawns. |
39 void SetLoaderForURL(scoped_ptr<ServiceLoader> loader, const GURL& url); | 36 void SetLoaderForURL(scoped_ptr<ServiceLoader> loader, const GURL& url); |
40 | 37 |
41 private: | 38 private: |
42 Context context_; | 39 Context context_; |
43 base::MessageLoop shell_loop_; | 40 base::MessageLoop shell_loop_; |
44 scoped_ptr<ServiceManager::TestAPI> test_api_; | 41 scoped_ptr<ServiceManager::TestAPI> test_api_; |
45 DISALLOW_COPY_AND_ASSIGN(ShellTestHelper); | 42 DISALLOW_COPY_AND_ASSIGN(ShellTestHelper); |
46 }; | 43 }; |
47 | 44 |
48 } // namespace shell | 45 } // namespace shell |
49 } // namespace mojo | 46 } // namespace mojo |
50 | 47 |
51 #endif // MOJO_SHELL_SHELL_TEST_HELPER_ | 48 #endif // MOJO_SHELL_SHELL_TEST_HELPER_ |
OLD | NEW |