| 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_BASE_H_ | 5 #ifndef MOJO_SHELL_SHELL_TEST_BASE_H_ |
| 6 #define MOJO_SHELL_SHELL_TEST_BASE_H_ | 6 #define MOJO_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 25 matching lines...) Expand all Loading... |
| 36 // to an "appropriate" file: URL). | 36 // to an "appropriate" file: URL). |
| 37 // TODO(tim): Should the test base be a ServiceProvider? | 37 // TODO(tim): Should the test base be a ServiceProvider? |
| 38 ScopedMessagePipeHandle ConnectToService( | 38 ScopedMessagePipeHandle ConnectToService( |
| 39 const GURL& application_url, | 39 const GURL& application_url, |
| 40 const std::string& service_name); | 40 const std::string& service_name); |
| 41 | 41 |
| 42 ScopedMessagePipeHandle ConnectToServiceViaNetwork( | 42 ScopedMessagePipeHandle ConnectToServiceViaNetwork( |
| 43 const GURL& application_url, | 43 const GURL& application_url, |
| 44 const std::string& service_name); | 44 const std::string& service_name); |
| 45 | 45 |
| 46 template <typename Interface> |
| 47 void ConnectToService(const GURL& application_url, |
| 48 InterfacePtr<Interface>* ptr) { |
| 49 ptr->Bind(ConnectToService(application_url, Interface::Name_).Pass()); |
| 50 } |
| 51 |
| 52 template <typename Interface> |
| 53 void ConnectToServiceViaNetwork(const GURL& application_url, |
| 54 InterfacePtr<Interface>* ptr) { |
| 55 ptr->Bind( |
| 56 ConnectToServiceViaNetwork(application_url, Interface::Name_).Pass()); |
| 57 } |
| 58 |
| 46 base::MessageLoop* message_loop() { return &message_loop_; } | 59 base::MessageLoop* message_loop() { return &message_loop_; } |
| 47 Context* shell_context() { return &shell_context_; } | 60 Context* shell_context() { return &shell_context_; } |
| 48 | 61 |
| 49 private: | 62 private: |
| 50 scoped_ptr<net::test_server::EmbeddedTestServer> test_server_; | 63 scoped_ptr<net::test_server::EmbeddedTestServer> test_server_; |
| 51 Context shell_context_; | 64 Context shell_context_; |
| 52 base::MessageLoop message_loop_; | 65 base::MessageLoop message_loop_; |
| 53 | 66 |
| 54 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); | 67 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); |
| 55 }; | 68 }; |
| 56 | 69 |
| 57 } // namespace test | 70 } // namespace test |
| 58 } // namespace shell | 71 } // namespace shell |
| 59 } // namespace mojo | 72 } // namespace mojo |
| 60 | 73 |
| 61 #endif // MOJO_SHELL_SHELL_TEST_BASE_H_ | 74 #endif // MOJO_SHELL_SHELL_TEST_BASE_H_ |
| OLD | NEW |