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 CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "third_party/WebKit/public/platform/WebGamepads.h"
15 namespace WebTestRunner
{
16 class WebTestDelegate
;
21 class GamepadController
: public base::SupportsWeakPtr
<GamepadController
> {
27 void Install(blink::WebFrame
* frame
);
28 void SetDelegate(WebTestRunner::WebTestDelegate
* delegate
);
31 friend class GamepadControllerBindings
;
33 // TODO(b.kelemen): for historical reasons Connect just initializes the
34 // object. The 'gamepadconnected' event will be dispatched via
35 // DispatchConnected. Tests for connected events need to first connect(),
36 // then set the gamepad data and finally call dispatchConnected().
37 // We should consider renaming Connect to Init and DispatchConnected to
38 // Connect and at the same time updating all the gamepad tests.
39 void Connect(int index
);
40 void DispatchConnected(int index
);
42 void Disconnect(int index
);
43 void SetId(int index
, const std::string
& src
);
44 void SetButtonCount(int index
, int buttons
);
45 void SetButtonData(int index
, int button
, double data
);
46 void SetAxisCount(int index
, int axes
);
47 void SetAxisData(int index
, int axis
, double data
);
49 blink::WebGamepads gamepads_
;
51 WebTestRunner::WebTestDelegate
* delegate_
;
53 base::WeakPtrFactory
<GamepadController
> weak_factory_
;
55 DISALLOW_COPY_AND_ASSIGN(GamepadController
);
58 } // namespace content
60 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_