1 // Copyright 2015 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 COMPONENTS_HTML_VIEWER_WEB_TEST_DELEGATE_IMPL_H_
6 #define COMPONENTS_HTML_VIEWER_WEB_TEST_DELEGATE_IMPL_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "components/test_runner/test_preferences.h"
11 #include "components/test_runner/web_test_delegate.h"
13 namespace test_runner
{
14 class WebTestInterfaces
;
15 class WebTestProxyBase
;
18 namespace html_viewer
{
20 class WebTestDelegateImpl
: public test_runner::WebTestDelegate
{
22 WebTestDelegateImpl();
23 ~WebTestDelegateImpl();
25 void set_test_interfaces(test_runner::WebTestInterfaces
* test_interfaces
) {
26 test_interfaces_
= test_interfaces
;
28 void set_test_proxy(test_runner::WebTestProxyBase
* proxy
) {
31 void set_completion_callback(const base::Closure
& callback
) {
32 completion_callback_
= callback
;
36 // From test_runner::WebTestDelegate:
37 void ClearEditCommand() override
;
38 void SetEditCommand(const std::string
& name
,
39 const std::string
& value
) override
;
40 void SetGamepadProvider(test_runner::GamepadController
* controller
) override
;
41 void SetDeviceLightData(const double data
) override
;
42 void SetDeviceMotionData(const blink::WebDeviceMotionData
& data
) override
;
43 void SetDeviceOrientationData(
44 const blink::WebDeviceOrientationData
& data
) override
;
45 void SetScreenOrientation(
46 const blink::WebScreenOrientationType
& orientation
) override
;
47 void ResetScreenOrientation() override
;
48 void DidChangeBatteryStatus(const blink::WebBatteryStatus
& status
) override
;
49 void PrintMessage(const std::string
& message
) override
;
50 void PostTask(test_runner::WebTask
* task
) override
;
51 void PostDelayedTask(test_runner::WebTask
* task
, long long ms
) override
;
52 blink::WebString
RegisterIsolatedFileSystem(
53 const blink::WebVector
<blink::WebString
>& absolute_filenames
) override
;
54 long long GetCurrentTimeInMillisecond() override
;
55 blink::WebString
GetAbsoluteWebStringFromUTF8Path(
56 const std::string
& path
) override
;
57 blink::WebURL
LocalFileToDataURL(const blink::WebURL
& file_url
) override
;
58 blink::WebURL
RewriteLayoutTestsURL(const std::string
& utf8_url
) override
;
59 test_runner::TestPreferences
* Preferences() override
;
60 void ApplyPreferences() override
;
61 void UseUnfortunateSynchronousResizeMode(bool enable
) override
;
62 void EnableAutoResizeMode(const blink::WebSize
& min_size
,
63 const blink::WebSize
& max_size
) override
;
64 void DisableAutoResizeMode(const blink::WebSize
& new_size
) override
;
65 void ClearDevToolsLocalStorage() override
;
66 void ShowDevTools(const std::string
& settings
,
67 const std::string
& frontend_url
) override
;
68 void CloseDevTools() override
;
69 void EvaluateInWebInspector(long call_id
, const std::string
& script
) override
;
70 void ClearAllDatabases() override
;
71 void SetDatabaseQuota(int quota
) override
;
72 void SimulateWebNotificationClick(const std::string
& title
,
73 int action_index
) override
;
74 void SetDeviceScaleFactor(float factor
) override
;
75 void SetDeviceColorProfile(const std::string
& name
) override
;
76 void SetBluetoothMockDataSet(const std::string
& data_set
) override
;
77 void SetBluetoothManualChooser() override
;
78 std::vector
<std::string
> GetBluetoothManualChooserEvents() override
;
79 void SendBluetoothManualChooserEvent(const std::string
& event
,
80 const std::string
& argument
) override
;
81 void SetGeofencingMockProvider(bool service_available
) override
;
82 void ClearGeofencingMockProvider() override
;
83 void SetGeofencingMockPosition(double latitude
, double longitude
) override
;
84 void SetFocus(test_runner::WebTestProxyBase
* proxy
, bool focus
) override
;
85 void SetAcceptAllCookies(bool accept
) override
;
86 std::string
PathToLocalResource(const std::string
& resource
) override
;
87 void SetLocale(const std::string
& locale
) override
;
88 void TestFinished() override
;
89 void CloseRemainingWindows() override
;
90 void DeleteAllCookies() override
;
91 int NavigationEntryCount() override
;
92 void GoToOffset(int offset
) override
;
93 void Reload() override
;
94 void LoadURLForFrame(const blink::WebURL
& url
,
95 const std::string
& frame_name
) override
;
96 bool AllowExternalPages() override
;
97 std::string
DumpHistoryForWindow(
98 test_runner::WebTestProxyBase
* proxy
) override
;
100 blink::WebView
* view
,
102 const base::Callback
<void(const blink::WebURLResponse
& response
,
103 const std::string
& data
)>& callback
) override
;
104 void SetPermission(const std::string
& permission_name
,
105 const std::string
& permission_value
,
107 const GURL
& embedding_origin
) override
;
108 void ResetPermissions() override
;
109 cc::SharedBitmapManager
* GetSharedBitmapManager() override
;
110 void DispatchBeforeInstallPromptEvent(
112 const std::vector
<std::string
>& event_platforms
,
113 const base::Callback
<void(bool)>& callback
) override
;
114 void ResolveBeforeInstallPromptPromise(int request_id
,
115 const std::string
& platform
) override
;
116 blink::WebPlugin
* CreatePluginPlaceholder(
117 blink::WebLocalFrame
* frame
,
118 const blink::WebPluginParams
& params
) override
;
119 void OnWebTestProxyBaseDestroy(test_runner::WebTestProxyBase
* base
) override
;
121 test_runner::TestPreferences prefs_
;
122 test_runner::WebTestInterfaces
* test_interfaces_
;
123 test_runner::WebTestProxyBase
* proxy_
;
124 base::Closure completion_callback_
;
126 DISALLOW_COPY_AND_ASSIGN(WebTestDelegateImpl
);
129 } // namespace html_viewer
131 #endif // COMPONENTS_HTML_VIEWER_WEB_TEST_DELEGATE_IMPL_H_