OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2010 Pawel Hajdan (phajdan.jr@chromium.org) | 3 * Copyright (C) 2010 Pawel Hajdan (phajdan.jr@chromium.org) |
4 * Copyright (C) 2012 Apple Inc. All Rights Reserved. | 4 * Copyright (C) 2012 Apple Inc. All Rights Reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 */ | 31 */ |
32 | 32 |
33 #include "config.h" | 33 #include "config.h" |
34 #include "TestRunner.h" | 34 #include "TestRunner.h" |
35 | 35 |
| 36 #include "MockWebDeviceMotionHandler.h" |
36 #include "MockWebSpeechInputController.h" | 37 #include "MockWebSpeechInputController.h" |
37 #include "MockWebSpeechRecognizer.h" | 38 #include "MockWebSpeechRecognizer.h" |
38 #include "NotificationPresenter.h" | 39 #include "NotificationPresenter.h" |
39 #include "TestInterfaces.h" | 40 #include "TestInterfaces.h" |
40 #include "WebBindings.h" | 41 #include "WebBindings.h" |
41 #include "WebDataSource.h" | 42 #include "WebDataSource.h" |
42 #include "WebDeviceOrientation.h" | 43 #include "WebDeviceOrientation.h" |
43 #include "WebDeviceOrientationClientMock.h" | 44 #include "WebDeviceOrientationClientMock.h" |
44 #include "WebDocument.h" | 45 #include "WebDocument.h" |
45 #include "WebElement.h" | 46 #include "WebElement.h" |
46 #include "WebFindOptions.h" | 47 #include "WebFindOptions.h" |
47 #include "WebFrame.h" | 48 #include "WebFrame.h" |
48 #include "WebGeolocationClientMock.h" | 49 #include "WebGeolocationClientMock.h" |
49 #include "WebInputElement.h" | 50 #include "WebInputElement.h" |
50 #include "WebPermissions.h" | 51 #include "WebPermissions.h" |
51 #include "WebPreferences.h" | 52 #include "WebPreferences.h" |
52 #include "WebScriptSource.h" | 53 #include "WebScriptSource.h" |
53 #include "WebSecurityPolicy.h" | 54 #include "WebSecurityPolicy.h" |
54 #include "WebSerializedScriptValue.h" | 55 #include "WebSerializedScriptValue.h" |
55 #include "WebSettings.h" | 56 #include "WebSettings.h" |
56 #include "WebSurroundingText.h" | 57 #include "WebSurroundingText.h" |
57 #include "WebTask.h" | 58 #include "WebTask.h" |
58 #include "WebTestDelegate.h" | 59 #include "WebTestDelegate.h" |
59 #include "WebTestProxy.h" | 60 #include "WebTestProxy.h" |
60 #include "WebView.h" | 61 #include "WebView.h" |
61 #include "v8/include/v8.h" | 62 #include "v8/include/v8.h" |
62 #include <limits> | 63 #include <limits> |
63 #include <memory> | 64 #include <memory> |
64 #include <public/WebData.h> | 65 #include <public/WebData.h> |
| 66 #include <public/WebDeviceMotionData.h> |
65 #include <public/WebPoint.h> | 67 #include <public/WebPoint.h> |
66 #include <public/WebURLResponse.h> | 68 #include <public/WebURLResponse.h> |
67 | 69 |
68 #if defined(__linux__) || defined(ANDROID) | 70 #if defined(__linux__) || defined(ANDROID) |
69 #include "linux/WebFontRendering.h" | 71 #include "linux/WebFontRendering.h" |
70 #endif | 72 #endif |
71 | 73 |
72 using namespace WebKit; | 74 using namespace WebKit; |
73 using namespace std; | 75 using namespace std; |
74 | 76 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bindMethod("setFixedLayoutSize", &TestRunner::setFixedLayoutSize); | 202 bindMethod("setFixedLayoutSize", &TestRunner::setFixedLayoutSize); |
201 bindMethod("selectionAsMarkup", &TestRunner::selectionAsMarkup); | 203 bindMethod("selectionAsMarkup", &TestRunner::selectionAsMarkup); |
202 bindMethod("setTextSubpixelPositioning", &TestRunner::setTextSubpixelPositio
ning); | 204 bindMethod("setTextSubpixelPositioning", &TestRunner::setTextSubpixelPositio
ning); |
203 bindMethod("resetPageVisibility", &TestRunner::resetPageVisibility); | 205 bindMethod("resetPageVisibility", &TestRunner::resetPageVisibility); |
204 bindMethod("setPageVisibility", &TestRunner::setPageVisibility); | 206 bindMethod("setPageVisibility", &TestRunner::setPageVisibility); |
205 bindMethod("setTextDirection", &TestRunner::setTextDirection); | 207 bindMethod("setTextDirection", &TestRunner::setTextDirection); |
206 bindMethod("textSurroundingNode", &TestRunner::textSurroundingNode); | 208 bindMethod("textSurroundingNode", &TestRunner::textSurroundingNode); |
207 bindMethod("disableAutoResizeMode", &TestRunner::disableAutoResizeMode); | 209 bindMethod("disableAutoResizeMode", &TestRunner::disableAutoResizeMode); |
208 bindMethod("enableAutoResizeMode", &TestRunner::enableAutoResizeMode); | 210 bindMethod("enableAutoResizeMode", &TestRunner::enableAutoResizeMode); |
209 bindMethod("setMockDeviceOrientation", &TestRunner::setMockDeviceOrientation
); | 211 bindMethod("setMockDeviceOrientation", &TestRunner::setMockDeviceOrientation
); |
| 212 bindMethod("fireMockDeviceMotion", &TestRunner::fireMockDeviceMotion); |
| 213 bindMethod("setMockDeviceMotion", &TestRunner::setMockDeviceMotion); |
210 bindMethod("didAcquirePointerLock", &TestRunner::didAcquirePointerLock); | 214 bindMethod("didAcquirePointerLock", &TestRunner::didAcquirePointerLock); |
211 bindMethod("didLosePointerLock", &TestRunner::didLosePointerLock); | 215 bindMethod("didLosePointerLock", &TestRunner::didLosePointerLock); |
212 bindMethod("didNotAcquirePointerLock", &TestRunner::didNotAcquirePointerLock
); | 216 bindMethod("didNotAcquirePointerLock", &TestRunner::didNotAcquirePointerLock
); |
213 bindMethod("setPointerLockWillRespondAsynchronously", &TestRunner::setPointe
rLockWillRespondAsynchronously); | 217 bindMethod("setPointerLockWillRespondAsynchronously", &TestRunner::setPointe
rLockWillRespondAsynchronously); |
214 bindMethod("setPointerLockWillFailSynchronously", &TestRunner::setPointerLoc
kWillFailSynchronously); | 218 bindMethod("setPointerLockWillFailSynchronously", &TestRunner::setPointerLoc
kWillFailSynchronously); |
215 | 219 |
216 // The following modify WebPreferences. | 220 // The following modify WebPreferences. |
217 bindMethod("setUserStyleSheetEnabled", &TestRunner::setUserStyleSheetEnabled
); | 221 bindMethod("setUserStyleSheetEnabled", &TestRunner::setUserStyleSheetEnabled
); |
218 bindMethod("setUserStyleSheetLocation", &TestRunner::setUserStyleSheetLocati
on); | 222 bindMethod("setUserStyleSheetLocation", &TestRunner::setUserStyleSheetLocati
on); |
219 bindMethod("setAuthorAndUserStylesEnabled", &TestRunner::setAuthorAndUserSty
lesEnabled); | 223 bindMethod("setAuthorAndUserStylesEnabled", &TestRunner::setAuthorAndUserSty
lesEnabled); |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 orientation.setBeta(arguments[3].toDouble()); | 1507 orientation.setBeta(arguments[3].toDouble()); |
1504 if (arguments[4].toBoolean()) | 1508 if (arguments[4].toBoolean()) |
1505 orientation.setGamma(arguments[5].toDouble()); | 1509 orientation.setGamma(arguments[5].toDouble()); |
1506 | 1510 |
1507 // Note that we only call setOrientation on the main page's mock since this | 1511 // Note that we only call setOrientation on the main page's mock since this |
1508 // tests require. If necessary, we could get a list of WebViewHosts from th | 1512 // tests require. If necessary, we could get a list of WebViewHosts from th |
1509 // call setOrientation on each DeviceOrientationClientMock. | 1513 // call setOrientation on each DeviceOrientationClientMock. |
1510 m_proxy->deviceOrientationClientMock()->setOrientation(orientation); | 1514 m_proxy->deviceOrientationClientMock()->setOrientation(orientation); |
1511 } | 1515 } |
1512 | 1516 |
| 1517 void TestRunner::setMockDeviceMotion(const CppArgumentList& arguments, CppVarian
t* result) |
| 1518 { |
| 1519 m_delegate->setDeviceMotionHandler(m_proxy->deviceMotionHandlerMock()); |
| 1520 } |
| 1521 |
| 1522 void TestRunner::fireMockDeviceMotion(const CppArgumentList& arguments, CppVaria
nt* result) |
| 1523 { |
| 1524 result->setNull(); |
| 1525 if (arguments.size() < 19 |
| 1526 || !arguments[0].isBool() || !arguments[1].isNumber() // acceleration.x |
| 1527 || !arguments[2].isBool() || !arguments[3].isNumber() // acceleration.y |
| 1528 || !arguments[4].isBool() || !arguments[5].isNumber() // acceleration.z |
| 1529 || !arguments[6].isBool() || !arguments[7].isNumber() // accelerationInc
ludingGravity.x |
| 1530 || !arguments[8].isBool() || !arguments[9].isNumber() // accelerationInc
ludingGravity.y |
| 1531 || !arguments[10].isBool() || !arguments[11].isNumber() // accelerationI
ncludingGravity.z |
| 1532 || !arguments[12].isBool() || !arguments[13].isNumber() // rotationRate.
alpha |
| 1533 || !arguments[14].isBool() || !arguments[15].isNumber() // rotationRate.
beta |
| 1534 || !arguments[16].isBool() || !arguments[17].isNumber() // rotationRate.
gamma |
| 1535 || !arguments[18].isNumber()) // interval |
| 1536 return; |
| 1537 |
| 1538 WebDeviceMotionData motion; |
| 1539 |
| 1540 // acceleration |
| 1541 if (arguments[0].toBoolean()) |
| 1542 motion.setAccelerationX(arguments[1].toDouble()); |
| 1543 if (arguments[2].toBoolean()) |
| 1544 motion.setAccelerationY(arguments[3].toDouble()); |
| 1545 if (arguments[4].toBoolean()) |
| 1546 motion.setAccelerationZ(arguments[5].toDouble()); |
| 1547 |
| 1548 // accelerationIncludingGravity |
| 1549 if (arguments[6].toBoolean()) |
| 1550 motion.setAccelerationIncludingGravityX(arguments[7].toDouble()); |
| 1551 if (arguments[8].toBoolean()) |
| 1552 motion.setAccelerationIncludingGravityY(arguments[9].toDouble()); |
| 1553 if (arguments[10].toBoolean()) |
| 1554 motion.setAccelerationIncludingGravityZ(arguments[11].toDouble()); |
| 1555 |
| 1556 // rotationRate |
| 1557 if (arguments[12].toBoolean()) |
| 1558 motion.setRotationRateAlpha(arguments[13].toDouble()); |
| 1559 if (arguments[14].toBoolean()) |
| 1560 motion.setRotationRateBeta(arguments[15].toDouble()); |
| 1561 if (arguments[16].toBoolean()) |
| 1562 motion.setRotationRateGamma(arguments[17].toDouble()); |
| 1563 |
| 1564 // interval |
| 1565 motion.setInterval(arguments[18].toDouble()); |
| 1566 |
| 1567 m_proxy->deviceMotionHandlerMock()->fireEvent(motion); |
| 1568 } |
| 1569 |
1513 void TestRunner::setUserStyleSheetEnabled(const CppArgumentList& arguments, CppV
ariant* result) | 1570 void TestRunner::setUserStyleSheetEnabled(const CppArgumentList& arguments, CppV
ariant* result) |
1514 { | 1571 { |
1515 if (arguments.size() > 0 && arguments[0].isBool()) { | 1572 if (arguments.size() > 0 && arguments[0].isBool()) { |
1516 m_delegate->preferences()->userStyleSheetLocation = arguments[0].value.b
oolValue ? m_userStyleSheetLocation : WebURL(); | 1573 m_delegate->preferences()->userStyleSheetLocation = arguments[0].value.b
oolValue ? m_userStyleSheetLocation : WebURL(); |
1517 m_delegate->applyPreferences(); | 1574 m_delegate->applyPreferences(); |
1518 } | 1575 } |
1519 result->setNull(); | 1576 result->setNull(); |
1520 } | 1577 } |
1521 | 1578 |
1522 void TestRunner::setUserStyleSheetLocation(const CppArgumentList& arguments, Cpp
Variant* result) | 1579 void TestRunner::setUserStyleSheetLocation(const CppArgumentList& arguments, Cpp
Variant* result) |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 result->setNull(); | 2093 result->setNull(); |
2037 } | 2094 } |
2038 | 2095 |
2039 void TestRunner::setPointerLockWillFailSynchronously(const CppArgumentList&, Cpp
Variant* result) | 2096 void TestRunner::setPointerLockWillFailSynchronously(const CppArgumentList&, Cpp
Variant* result) |
2040 { | 2097 { |
2041 m_pointerLockPlannedResult = PointerLockWillFailSync; | 2098 m_pointerLockPlannedResult = PointerLockWillFailSync; |
2042 result->setNull(); | 2099 result->setNull(); |
2043 } | 2100 } |
2044 | 2101 |
2045 } | 2102 } |
OLD | NEW |