shell_test_base.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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/message_loop/message_loop.h"
12#include "mojo/public/cpp/system/core.h"
13#include "mojo/shell/context.h"
14#include "testing/gtest/include/gtest/gtest.h"
15
16class GURL;
17
18namespace net {
19namespace test_server {
20class EmbeddedTestServer;
21}
22}  // namespace net
23
24namespace mojo {
25namespace shell {
26namespace test {
27
28class ShellTestBase : public testing::Test {
29 public:
30  ShellTestBase();
31  virtual ~ShellTestBase();
32
33  virtual void SetUp() OVERRIDE;
34
35  // |application_url| should typically be a mojo: URL (the origin will be set
36  // to an "appropriate" file: URL).
37  // TODO(tim): Should the test base be a ServiceProvider?
38  ScopedMessagePipeHandle ConnectToService(
39      const GURL& application_url,
40      const std::string& service_name);
41
42  ScopedMessagePipeHandle ConnectToServiceViaNetwork(
43      const GURL& application_url,
44      const std::string& service_name);
45
46  base::MessageLoop* message_loop() { return &message_loop_; }
47  Context* shell_context() { return &shell_context_; }
48
49 private:
50  scoped_ptr<net::test_server::EmbeddedTestServer> test_server_;
51  Context shell_context_;
52  base::MessageLoop message_loop_;
53
54  DISALLOW_COPY_AND_ASSIGN(ShellTestBase);
55};
56
57}  // namespace test
58}  // namespace shell
59}  // namespace mojo
60
61#endif  // MOJO_SHELL_SHELL_TEST_BASE_H_
62