Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: content/shell/renderer/test_runner/gamepad_controller.h

Issue 1133753003: Split gamepad provider from test runner controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/public/renderer/renderer_gamepad_provider.h"
12 #include "third_party/WebKit/public/platform/WebGamepads.h" 11 #include "third_party/WebKit/public/platform/WebGamepads.h"
13 12
14 namespace blink { 13 namespace blink {
15 class WebFrame; 14 class WebFrame;
16 class WebGamepadListener; 15 class WebGamepadListener;
17 } 16 }
18 17
19 namespace content { 18 namespace content {
20 19
21 class WebTestDelegate; 20 class WebTestDelegate;
22 21
23 class GamepadController 22 class GamepadController : public base::SupportsWeakPtr<GamepadController> {
24 : public base::SupportsWeakPtr<GamepadController>,
25 public RendererGamepadProvider {
26 public: 23 public:
27 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate); 24 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate);
28 ~GamepadController() override; 25 ~GamepadController();
29 26
30 void Reset(); 27 void Reset();
31 void Install(blink::WebFrame* frame); 28 void Install(blink::WebFrame* frame);
32 29
33 // RendererGamepadProvider implementation. 30 void SampleGamepads(blink::WebGamepads& gamepads);
34 void SampleGamepads(blink::WebGamepads& gamepads) override; 31 void SetListener(blink::WebGamepadListener* listener);
35 bool OnControlMessageReceived(const IPC::Message& msg) override;
36 void SendStartMessage() override;
37 void SendStopMessage() override;
38 32
39 private: 33 private:
40 friend class GamepadControllerBindings; 34 friend class GamepadControllerBindings;
41 GamepadController(); 35 GamepadController();
42 36
43 // TODO(b.kelemen): for historical reasons Connect just initializes the 37 // TODO(b.kelemen): for historical reasons Connect just initializes the
44 // object. The 'gamepadconnected' event will be dispatched via 38 // object. The 'gamepadconnected' event will be dispatched via
45 // DispatchConnected. Tests for connected events need to first connect(), 39 // DispatchConnected. Tests for connected events need to first connect(),
46 // then set the gamepad data and finally call dispatchConnected(). 40 // then set the gamepad data and finally call dispatchConnected().
47 // We should consider renaming Connect to Init and DispatchConnected to 41 // We should consider renaming Connect to Init and DispatchConnected to
48 // Connect and at the same time updating all the gamepad tests. 42 // Connect and at the same time updating all the gamepad tests.
49 void Connect(int index); 43 void Connect(int index);
50 void DispatchConnected(int index); 44 void DispatchConnected(int index);
51 45
52 void Disconnect(int index); 46 void Disconnect(int index);
53 void SetId(int index, const std::string& src); 47 void SetId(int index, const std::string& src);
54 void SetButtonCount(int index, int buttons); 48 void SetButtonCount(int index, int buttons);
55 void SetButtonData(int index, int button, double data); 49 void SetButtonData(int index, int button, double data);
56 void SetAxisCount(int index, int axes); 50 void SetAxisCount(int index, int axes);
57 void SetAxisData(int index, int axis, double data); 51 void SetAxisData(int index, int axis, double data);
58 52
53 blink::WebGamepadListener* listener_;
54
59 blink::WebGamepads gamepads_; 55 blink::WebGamepads gamepads_;
60 56
61 // Mapping from gamepad index to connection state. 57 // Mapping from gamepad index to connection state.
62 std::map<int, bool> pending_changes_; 58 std::map<int, bool> pending_changes_;
63 59
64 base::WeakPtrFactory<GamepadController> weak_factory_; 60 base::WeakPtrFactory<GamepadController> weak_factory_;
65 61
66 DISALLOW_COPY_AND_ASSIGN(GamepadController); 62 DISALLOW_COPY_AND_ASSIGN(GamepadController);
67 }; 63 };
68 64
69 } // namespace content 65 } // namespace content
70 66
71 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ 67 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
OLDNEW
« no previous file with comments | « content/shell/renderer/layout_test/blink_test_runner.cc ('k') | content/shell/renderer/test_runner/gamepad_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698