ui: Stop converting Rect to RectF implicitly in native_theme_win.cc
[chromium-blink-merge.git] / components / test_runner / gamepad_controller.h
blobfe32cb3bab5fd41880f15762624a10d6498fdf83
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 COMPONENTS_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
6 #define COMPONENTS_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
8 #include <map>
10 #include "base/memory/weak_ptr.h"
11 #include "components/test_runner/test_runner_export.h"
12 #include "third_party/WebKit/public/platform/WebGamepads.h"
14 namespace blink {
15 class WebFrame;
16 class WebGamepadListener;
19 namespace test_runner {
21 class WebTestDelegate;
23 class TEST_RUNNER_EXPORT GamepadController
24 : public base::SupportsWeakPtr<GamepadController> {
25 public:
26 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate);
27 ~GamepadController();
29 void Reset();
30 void Install(blink::WebFrame* frame);
32 void SampleGamepads(blink::WebGamepads& gamepads);
33 void SetListener(blink::WebGamepadListener* listener);
35 private:
36 friend class GamepadControllerBindings;
37 GamepadController();
39 // TODO(b.kelemen): for historical reasons Connect just initializes the
40 // object. The 'gamepadconnected' event will be dispatched via
41 // DispatchConnected. Tests for connected events need to first connect(),
42 // then set the gamepad data and finally call dispatchConnected().
43 // We should consider renaming Connect to Init and DispatchConnected to
44 // Connect and at the same time updating all the gamepad tests.
45 void Connect(int index);
46 void DispatchConnected(int index);
48 void Disconnect(int index);
49 void SetId(int index, const std::string& src);
50 void SetButtonCount(int index, int buttons);
51 void SetButtonData(int index, int button, double data);
52 void SetAxisCount(int index, int axes);
53 void SetAxisData(int index, int axis, double data);
55 blink::WebGamepadListener* listener_;
57 blink::WebGamepads gamepads_;
59 // Mapping from gamepad index to connection state.
60 std::map<int, bool> pending_changes_;
62 base::WeakPtrFactory<GamepadController> weak_factory_;
64 DISALLOW_COPY_AND_ASSIGN(GamepadController);
67 } // namespace test_runner
69 #endif // COMPONENTS_TEST_RUNNER_GAMEPAD_CONTROLLER_H_