| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "mojo/public/cpp/system/core.h" | 12 #include "mojo/public/cpp/system/core.h" |
| 13 #include "mojo/shell/context.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 class GURL; | 16 class GURL; |
| 16 | 17 |
| 17 namespace base { | |
| 18 class MessageLoop; | |
| 19 } | |
| 20 | |
| 21 namespace mojo { | 18 namespace mojo { |
| 22 namespace shell { | 19 namespace shell { |
| 23 | |
| 24 class Context; | |
| 25 | |
| 26 namespace test { | 20 namespace test { |
| 27 | 21 |
| 28 class ShellTestBase : public testing::Test { | 22 class ShellTestBase : public testing::Test { |
| 29 public: | 23 public: |
| 30 ShellTestBase(); | 24 ShellTestBase(); |
| 31 virtual ~ShellTestBase(); | 25 virtual ~ShellTestBase(); |
| 32 | 26 |
| 33 // Should be called before any of the methods below are called. | |
| 34 void InitMojo(); | |
| 35 | |
| 36 // Launches the given service in-process; |service_url| should typically be a | 27 // Launches the given service in-process; |service_url| should typically be a |
| 37 // mojo: URL (the origin will be set to an "appropriate" file: URL). | 28 // mojo: URL (the origin will be set to an "appropriate" file: URL). |
| 38 void LaunchServiceInProcess(const GURL& service_url, | 29 void LaunchServiceInProcess(const GURL& service_url, |
| 39 const std::string& service_name, | 30 const std::string& service_name, |
| 40 ScopedMessagePipeHandle client_handle); | 31 ScopedMessagePipeHandle client_handle); |
| 41 | 32 |
| 42 base::MessageLoop* message_loop() { return message_loop_.get(); } | 33 base::MessageLoop* message_loop() { return &message_loop_; } |
| 43 Context* shell_context() { return shell_context_.get(); } | 34 Context* shell_context() { return &shell_context_; } |
| 44 | 35 |
| 45 private: | 36 private: |
| 46 // Only set if/when |InitMojo()| is called. | 37 base::MessageLoop message_loop_; |
| 47 scoped_ptr<base::MessageLoop> message_loop_; | 38 Context shell_context_; |
| 48 scoped_ptr<Context> shell_context_; | |
| 49 | 39 |
| 50 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); | 40 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); |
| 51 }; | 41 }; |
| 52 | 42 |
| 53 } // namespace test | 43 } // namespace test |
| 54 | |
| 55 } // namespace shell | 44 } // namespace shell |
| 56 } // namespace mojo | 45 } // namespace mojo |
| 57 | 46 |
| 58 #endif // MOJO_SHELL_SHELL_TEST_BASE_H_ | 47 #endif // MOJO_SHELL_SHELL_TEST_BASE_H_ |
| OLD | NEW |