• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_TEST_RUNNER_H_
6 #define CEF_TESTS_CEFCLIENT_BROWSER_TEST_RUNNER_H_
7 #pragma once
8 
9 #include <set>
10 #include <string>
11 
12 #include "include/cef_browser.h"
13 #include "include/cef_request.h"
14 #include "include/wrapper/cef_message_router.h"
15 #include "include/wrapper/cef_resource_manager.h"
16 
17 namespace client {
18 namespace test_runner {
19 
20 // Run a test.
21 void RunTest(CefRefPtr<CefBrowser> browser, int id);
22 
23 // Returns the contents of the CefRequest as a string.
24 std::string DumpRequestContents(CefRefPtr<CefRequest> request);
25 
26 // Returns the dump response as a stream. |request| is the request.
27 // |response_headers| will be populated with extra response headers, if any.
28 CefRefPtr<CefStreamReader> GetDumpResponse(
29     CefRefPtr<CefRequest> request,
30     CefResponse::HeaderMap& response_headers);
31 
32 // Returns a data: URI with the specified contents.
33 std::string GetDataURI(const std::string& data, const std::string& mime_type);
34 
35 // Returns the string representation of the specified error code.
36 std::string GetErrorString(cef_errorcode_t code);
37 
38 typedef std::map<std::string, std::string> StringResourceMap;
39 
40 // Set up the resource manager for tests.
41 void SetupResourceManager(CefRefPtr<CefResourceManager> resource_manager,
42                           StringResourceMap* string_resource_map);
43 
44 // Show a JS alert message.
45 void Alert(CefRefPtr<CefBrowser> browser, const std::string& message);
46 
47 // Returns true if |url| is a test URL with the specified |path|. This matches
48 // both http://tests/<path> and http://localhost:xxxx/<path>.
49 bool IsTestURL(const std::string& url, const std::string& path);
50 
51 // Create all CefMessageRouterBrowserSide::Handler objects. They will be
52 // deleted when the ClientHandler is destroyed.
53 typedef std::set<CefMessageRouterBrowserSide::Handler*> MessageHandlerSet;
54 void CreateMessageHandlers(MessageHandlerSet& handlers);
55 
56 // Register scheme handlers for tests.
57 void RegisterSchemeHandlers();
58 
59 // Create a resource response filter for tests.
60 CefRefPtr<CefResponseFilter> GetResourceResponseFilter(
61     CefRefPtr<CefBrowser> browser,
62     CefRefPtr<CefFrame> frame,
63     CefRefPtr<CefRequest> request,
64     CefRefPtr<CefResponse> response);
65 
66 }  // namespace test_runner
67 }  // namespace client
68 
69 #endif  // CEF_TESTS_CEFCLIENT_BROWSER_TEST_RUNNER_H_
70