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 3 // found in the LICENSE file. 4 5 #ifndef MOJO_SHELL_SHELL_TEST_BASE_H_ 6 #define MOJO_SHELL_SHELL_TEST_BASE_H_ 7 8 #include <string> 9 10 #include "base/macros.h" 11 #include "base/memory/scoped_ptr.h" 12 #include "mojo/public/cpp/system/core.h" 13 #include "testing/gtest/include/gtest/gtest.h" 14 15 class GURL; 16 17 namespace base { 18 class MessageLoop; 19 } 20 21 namespace mojo { 22 namespace shell { 23 24 class Context; 25 26 namespace test { 27 28 class ShellTestBase : public testing::Test { 29 public: 30 ShellTestBase(); 31 virtual ~ShellTestBase(); 32 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 37 // mojo: URL (the origin will be set to an "appropriate" file: URL). 38 void LaunchServiceInProcess(const GURL& service_url, 39 const std::string& service_name, 40 ScopedMessagePipeHandle client_handle); 41 42 base::MessageLoop* message_loop() { return message_loop_.get(); } 43 Context* shell_context() { return shell_context_.get(); } 44 45 private: 46 // Only set if/when |InitMojo()| is called. 47 scoped_ptr<base::MessageLoop> message_loop_; 48 scoped_ptr<Context> shell_context_; 49 50 DISALLOW_COPY_AND_ASSIGN(ShellTestBase); 51 }; 52 53 } // namespace test 54 55 } // namespace shell 56 } // namespace mojo 57 58 #endif // MOJO_SHELL_SHELL_TEST_BASE_H_ 59