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