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_RUNNER_SHELL_TEST_BASE_H_ | 5 #ifndef MOJO_RUNNER_SHELL_TEST_BASE_H_ |
6 #define MOJO_RUNNER_SHELL_TEST_BASE_H_ | 6 #define MOJO_RUNNER_SHELL_TEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
12 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
13 #include "mojo/runner/context.h" | 14 #include "mojo/runner/context.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 class GURL; | 17 class GURL; |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 namespace runner { | 20 namespace runner { |
20 namespace test { | 21 namespace test { |
21 | 22 |
22 class ShellTestBase : public testing::Test { | 23 class ShellTestBase : public testing::Test { |
23 public: | 24 public: |
24 ShellTestBase(); | 25 ShellTestBase(); |
25 ~ShellTestBase() override; | 26 ~ShellTestBase() override; |
26 | 27 |
27 void SetUp() override; | 28 void SetUp() override; |
28 void TearDown() override; | 29 void TearDown() override; |
29 | 30 |
30 // |application_url| should typically be a mojo: URL (the origin will be set | 31 // |application_url| should typically be a mojo: URL (the origin will be set |
31 // to an "appropriate" file: URL). | 32 // to an "appropriate" file: URL). |
32 // TODO(tim): Should the test base be a ServiceProvider? | 33 // TODO(tim): Should the test base be a ServiceProvider? |
33 ScopedMessagePipeHandle ConnectToService(const GURL& application_url, | 34 ScopedMessagePipeHandle ConnectToService(const GURL& application_url, |
34 const std::string& service_name); | 35 const std::string& service_name); |
35 | 36 |
36 template <typename Interface> | 37 template <typename Interface> |
37 void ConnectToService(const GURL& application_url, | 38 void ConnectToService(const GURL& application_url, |
38 InterfacePtr<Interface>* ptr) { | 39 InterfacePtr<Interface>* ptr) { |
39 ptr->Bind(ConnectToService(application_url, Interface::Name_).Pass()); | 40 ptr->Bind(InterfacePtrInfo<Interface>( |
| 41 ConnectToService(application_url, Interface::Name_).Pass(), 0u)); |
40 } | 42 } |
41 | 43 |
42 base::MessageLoop* message_loop() { return &message_loop_; } | 44 base::MessageLoop* message_loop() { return &message_loop_; } |
43 Context* shell_context() { return &shell_context_; } | 45 Context* shell_context() { return &shell_context_; } |
44 | 46 |
45 private: | 47 private: |
46 // Set up the test applications so that mojo: URL resolves to those. | 48 // Set up the test applications so that mojo: URL resolves to those. |
47 void SetUpTestApplications(); | 49 void SetUpTestApplications(); |
48 | 50 |
49 Context shell_context_; | 51 Context shell_context_; |
50 base::MessageLoop message_loop_; | 52 base::MessageLoop message_loop_; |
51 | 53 |
52 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); | 54 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); |
53 }; | 55 }; |
54 | 56 |
55 } // namespace test | 57 } // namespace test |
56 } // namespace runner | 58 } // namespace runner |
57 } // namespace mojo | 59 } // namespace mojo |
58 | 60 |
59 #endif // MOJO_RUNNER_SHELL_TEST_BASE_H_ | 61 #endif // MOJO_RUNNER_SHELL_TEST_BASE_H_ |
OLD | NEW |