1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68

fuchsia_web / webengine / test / web_engine_browser_test.h [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FUCHSIA_WEB_WEBENGINE_TEST_WEB_ENGINE_BROWSER_TEST_H_
#define FUCHSIA_WEB_WEBENGINE_TEST_WEB_ENGINE_BROWSER_TEST_H_

#include <fuchsia/web/cpp/fidl.h>
#include <memory>
#include <vector>

#include "base/files/file_path.h"
#include "content/public/test/browser_test_base.h"

class ContextImpl;
class FrameHostImpl;

namespace base {
class CommandLine;
}

namespace sys {
class ServiceDirectory;
}

// Base test class used for testing the WebEngine Context FIDL service in
// integration.
class WebEngineBrowserTest : public content::BrowserTestBase {
 public:
  WebEngineBrowserTest();
  ~WebEngineBrowserTest() override;

  WebEngineBrowserTest(const WebEngineBrowserTest&) = delete;
  WebEngineBrowserTest& operator=(const WebEngineBrowserTest&) = delete;

  // Provides access to the set of services published by this browser process,
  // through its outgoing directory.
  sys::ServiceDirectory& published_services();

  // Gets the client object for the Context service.
  fuchsia::web::ContextPtr& context() { return context_; }

  // Gets the bound ContextImpl instance. Crashes if there is no ContextImpl.
  ContextImpl* context_impl() const;

  // Gets the FrameHostImpl instances that are bound.
  std::vector<FrameHostImpl*> frame_host_impls() const;

  void SetHeadlessInCommandLine(base::CommandLine* command_line);

  void set_test_server_root(const base::FilePath& path) {
    test_server_root_ = path;
  }

  // content::BrowserTestBase implementation.
  void SetUp() override;
  void PreRunTestOnMainThread() override;
  void PostRunTestOnMainThread() override;

 private:
  base::FilePath test_server_root_;
  fuchsia::web::ContextPtr context_;

  // Client for the directory of services published by this browser process.
  std::shared_ptr<sys::ServiceDirectory> published_services_;
};

#endif  // FUCHSIA_WEB_WEBENGINE_TEST_WEB_ENGINE_BROWSER_TEST_H_