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 SHELL_SHELL_TEST_BASE_H_ | 5 #ifndef SHELL_SHELL_TEST_BASE_H_ |
6 #define SHELL_SHELL_TEST_BASE_H_ | 6 #define SHELL_SHELL_TEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 ~ShellTestBase() override; | 25 ~ShellTestBase() override; |
26 | 26 |
27 void SetUp() override; | 27 void SetUp() override; |
28 | 28 |
29 // |application_url| should typically be a mojo: URL (the origin will be set | 29 // |application_url| should typically be a mojo: URL (the origin will be set |
30 // to an "appropriate" file: URL). | 30 // to an "appropriate" file: URL). |
31 // TODO(tim): Should the test base be a ServiceProvider? | 31 // TODO(tim): Should the test base be a ServiceProvider? |
32 ScopedMessagePipeHandle ConnectToService(const GURL& application_url, | 32 ScopedMessagePipeHandle ConnectToService(const GURL& application_url, |
33 const std::string& service_name); | 33 const std::string& service_name); |
34 | 34 |
35 ScopedMessagePipeHandle ConnectToServiceViaNetwork( | |
36 const GURL& application_url, | |
37 const std::string& service_name); | |
38 | |
39 template <typename Interface> | 35 template <typename Interface> |
40 void ConnectToService(const GURL& application_url, | 36 void ConnectToService(const GURL& application_url, |
41 InterfacePtr<Interface>* ptr) { | 37 InterfacePtr<Interface>* ptr) { |
42 ptr->Bind(ConnectToService(application_url, Interface::Name_).Pass()); | 38 ptr->Bind(ConnectToService(application_url, Interface::Name_).Pass()); |
43 } | 39 } |
44 | 40 |
45 template <typename Interface> | |
46 void ConnectToServiceViaNetwork(const GURL& application_url, | |
47 InterfacePtr<Interface>* ptr) { | |
48 ptr->Bind( | |
49 ConnectToServiceViaNetwork(application_url, Interface::Name_).Pass()); | |
50 } | |
51 | |
52 base::MessageLoop* message_loop() { return &message_loop_; } | 41 base::MessageLoop* message_loop() { return &message_loop_; } |
53 Context* shell_context() { return &shell_context_; } | 42 Context* shell_context() { return &shell_context_; } |
54 | 43 |
55 private: | 44 private: |
| 45 // Set up the test applications so that mojo: URL resolves to those. |
| 46 void SetUpTestApplications(); |
| 47 |
56 Context shell_context_; | 48 Context shell_context_; |
57 base::MessageLoop message_loop_; | 49 base::MessageLoop message_loop_; |
58 | 50 |
59 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); | 51 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); |
60 }; | 52 }; |
61 | 53 |
62 } // namespace test | 54 } // namespace test |
63 } // namespace shell | 55 } // namespace shell |
64 } // namespace mojo | 56 } // namespace mojo |
65 | 57 |
66 #endif // SHELL_SHELL_TEST_BASE_H_ | 58 #endif // SHELL_SHELL_TEST_BASE_H_ |
OLD | NEW |