Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / shell / renderer / test_runner / gamepad_controller.h
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 CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "third_party/WebKit/public/platform/WebGamepads.h"
10
11 namespace blink {
12 class WebFrame;
13 }
14
15 namespace content {
16
17 class WebTestDelegate;
18
19 class GamepadController : public base::SupportsWeakPtr<GamepadController> {
20  public:
21   GamepadController();
22   ~GamepadController();
23
24   void Reset();
25   void Install(blink::WebFrame* frame);
26   void SetDelegate(WebTestDelegate* delegate);
27
28  private:
29   friend class GamepadControllerBindings;
30
31   // TODO(b.kelemen): for historical reasons Connect just initializes the
32   // object. The 'gamepadconnected' event will be dispatched via
33   // DispatchConnected. Tests for connected events need to first connect(),
34   // then set the gamepad data and finally call dispatchConnected().
35   // We should consider renaming Connect to Init and DispatchConnected to
36   // Connect and at the same time updating all the gamepad tests.
37   void Connect(int index);
38   void DispatchConnected(int index);
39
40   void Disconnect(int index);
41   void SetId(int index, const std::string& src);
42   void SetButtonCount(int index, int buttons);
43   void SetButtonData(int index, int button, double data);
44   void SetAxisCount(int index, int axes);
45   void SetAxisData(int index, int axis, double data);
46
47   blink::WebGamepads gamepads_;
48
49   WebTestDelegate* delegate_;
50
51   base::WeakPtrFactory<GamepadController> weak_factory_;
52
53   DISALLOW_COPY_AND_ASSIGN(GamepadController);
54 };
55
56 }  // namespace content
57
58 #endif  // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_