WK2 Gamepad layout test support.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2016 19:41:00 +0000 (19:41 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2016 19:41:00 +0000 (19:41 +0000)
commit1318c949bd285c30a4f1775b524b005c15b782bf
treef94884b8924f52d44538966944403e2a7fcbfa6c
parentb042cf48f5db25bafbffe2c122ff180005d84068
WK2 Gamepad layout test support.
https://bugs.webkit.org/show_bug.cgi?id=134671
Source/WebCore:

Reviewed by Alex Christensen.

No new tests (Covered by changes to existing tests).

Add a MockGamepadProvider and expose it in WebCoreTestSupport.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:

* Modules/gamepad/Gamepad.cpp:
(WebCore::Gamepad::Gamepad):

* bindings/generic/RuntimeEnabledFeatures.cpp:
(WebCore::RuntimeEnabledFeatures::reset): Deleted. Gamepads should either always be enabled during tests
  (As in Mac WK2), or never enabled (As in all other platforms).
* bindings/generic/RuntimeEnabledFeatures.h:

* platform/gamepad/GamepadProvider.h:
(WebCore::GamepadProvider::isMockGamepadProvider):

* testing/MockGamepad.cpp: Copied from Source/WebKit2/Shared/Gamepad/GamepadData.cpp.
(WebCore::MockGamepad::MockGamepad):
(WebCore::MockGamepad::updateDetails):
(WebCore::MockGamepad::setAxisValue):
(WebCore::MockGamepad::setButtonValue):
* testing/MockGamepad.h: Copied from Source/WebKit2/UIProcess/Gamepad/UIGamepad.h.

* testing/MockGamepadProvider.cpp: Added.
(WebCore::MockGamepadProvider::singleton):
(WebCore::MockGamepadProvider::MockGamepadProvider):
(WebCore::MockGamepadProvider::startMonitoringGamepads):
(WebCore::MockGamepadProvider::stopMonitoringGamepads):
(WebCore::MockGamepadProvider::setMockGamepadDetails):
(WebCore::MockGamepadProvider::connectMockGamepad):
(WebCore::MockGamepadProvider::disconnectMockGamepad):
(WebCore::MockGamepadProvider::setMockGamepadAxisValue):
(WebCore::MockGamepadProvider::setMockGamepadButtonValue):
(WebCore::MockGamepadProvider::gamepadInputActivity):

* testing/MockGamepadProvider.h: Copied from Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.h.
(WebCore::MockGamepadProvider::~MockGamepadProvider):

* testing/js/WebCoreTestSupport.cpp:
(WebCoreTestSupport::installMockGamepadProvider):
(WebCoreTestSupport::connectMockGamepad):
(WebCoreTestSupport::disconnectMockGamepad):
(WebCoreTestSupport::setMockGamepadDetails):
(WebCoreTestSupport::setMockGamepadAxisValue):
(WebCoreTestSupport::setMockGamepadButtonValue):
* testing/js/WebCoreTestSupport.h:

Source/WebKit2:

Reviewed by Alex Christensen.

- Teach the UIGamepadProvider to use the default shared provider.
- Especially if its the MockGamepadProvider, don't overwrite it.

* Shared/Gamepad/GamepadData.cpp:
(WebKit::GamepadData::GamepadData):
(WebKit::GamepadData::encode):
(WebKit::GamepadData::decode):
(WebKit::GamepadData::loggingString):
(WebKit::GamepadData::isNull): Deleted.
* Shared/Gamepad/GamepadData.h:
(WebKit::GamepadData::GamepadData):
(WebKit::GamepadData::isNull):
(WebKit::GamepadData::index):
(WebKit::GamepadData::axisValues):
(WebKit::GamepadData::buttonValues):

* UIProcess/Gamepad/UIGamepad.h:

* UIProcess/Gamepad/UIGamepadProvider.cpp:
(WebKit::UIGamepadProvider::UIGamepadProvider):
(WebKit::UIGamepadProvider::~UIGamepadProvider):
(WebKit::UIGamepadProvider::platformGamepadInputActivity):
(WebKit::UIGamepadProvider::startMonitoringGamepads):
(WebKit::UIGamepadProvider::stopMonitoringGamepads):
(WebKit::UIGamepadProvider::platformSetDefaultGamepadProvider):
* UIProcess/Gamepad/UIGamepadProvider.h:

* UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp:
(WebKit::UIGamepadProvider::platformSetDefaultGamepadProvider):
(WebKit::UIGamepadProvider::platformStopMonitoringInput):
(WebKit::UIGamepadProvider::platformStartMonitoringInput):
(WebKit::UIGamepadProvider::platformStartMonitoringGamepads): Deleted.
(WebKit::UIGamepadProvider::platformStopMonitoringGamepads): Deleted.
(WebKit::UIGamepadProvider::platformGamepads): Deleted.

* UIProcess/WebPageProxy.h:

* WebProcess/Gamepad/WebGamepad.cpp:
(WebKit::WebGamepad::WebGamepad):
(WebKit::WebGamepad::updateValues):
* WebProcess/Gamepad/WebGamepad.h:

* WebProcess/Gamepad/WebGamepadProvider.cpp:
(WebKit::WebGamepadProvider::gamepadConnected):
* WebProcess/Gamepad/WebGamepadProvider.h:

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebProcess.h:

Tools:

Reviewed by Alex Christensen.

Have the injected bundle expose the MockGamepadProvider to the UI process, which will then
feed back into the UIGamepadProvider.

Also, fool NSApplication into treating the most recently created "isKeyWindow" of the test windows
as the actual keyWindow for the test runner, which will allow the view to get gamepad updates.

* WebKitTestRunner/Configurations/WebKitTestRunner.xcconfig:

* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setMockGamepadDetails):
(WTR::TestRunner::setMockGamepadAxisValue):
(WTR::TestRunner::setMockGamepadButtonValue):

* WebKitTestRunner/PlatformWebView.h:

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Deleted.

* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:

* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(-[WebKitTestRunnerWindow initWithFrame:]):
(-[WebKitTestRunnerWindow dealloc]):
(WTR::PlatformWebView::keyWindow):

* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::wtr_NSApplication_keyWindow):
(WTR::TestController::platformInitialize):

* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(+[WebKitTestRunnerWindow _WTR_keyWindow]):
(-[WebKitTestRunnerWindow initWithContentRect:styleMask:backing:defer:]):
(-[WebKitTestRunnerWindow dealloc]):
(WTR::PlatformWebView::keyWindow):

* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::wtr_NSApplication_keyWindow):
(WTR::TestController::platformInitialize):
* WebKitTestRunner/mac/main.mm:

LayoutTests:

Reviewed by Alex Christensen.

* gamepad/gamepad-api-expected.txt:
* gamepad/gamepad-api.html:
* gamepad/gamepad-out-of-range-crasher-expected.txt: Removed.
* gamepad/gamepad-out-of-range-crasher.html: Removed.
* gamepad/gamepad-polling-access-expected.txt:
* gamepad/gamepad-polling-access.html:

* platform/mac/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
51 files changed:
LayoutTests/ChangeLog
LayoutTests/gamepad/gamepad-api-expected.txt
LayoutTests/gamepad/gamepad-api.html
LayoutTests/gamepad/gamepad-out-of-range-crasher-expected.txt [deleted file]
LayoutTests/gamepad/gamepad-out-of-range-crasher.html [deleted file]
LayoutTests/gamepad/gamepad-polling-access-expected.txt
LayoutTests/gamepad/gamepad-polling-access.html
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/gamepad/Gamepad.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/platform/gamepad/GamepadProvider.h
Source/WebCore/testing/MockGamepad.cpp [new file with mode: 0644]
Source/WebCore/testing/MockGamepad.h [new file with mode: 0644]
Source/WebCore/testing/MockGamepadProvider.cpp [new file with mode: 0644]
Source/WebCore/testing/MockGamepadProvider.h [new file with mode: 0644]
Source/WebCore/testing/js/WebCoreTestSupport.cpp
Source/WebCore/testing/js/WebCoreTestSupport.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Gamepad/GamepadData.cpp
Source/WebKit2/Shared/Gamepad/GamepadData.h
Source/WebKit2/UIProcess/Gamepad/UIGamepad.h
Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.cpp
Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.h
Source/WebKit2/UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/Gamepad/WebGamepad.cpp
Source/WebKit2/WebProcess/Gamepad/WebGamepad.h
Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.cpp
Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/Configurations/WebKitTestRunner.xcconfig
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm
Tools/WebKitTestRunner/mac/main.mm