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 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 orientation.setBeta(arguments[3].toDouble()); | 1499 orientation.setBeta(arguments[3].toDouble()); |
1496 if (arguments[4].toBoolean()) | 1500 if (arguments[4].toBoolean()) |
1497 orientation.setGamma(arguments[5].toDouble()); | 1501 orientation.setGamma(arguments[5].toDouble()); |
1498 | 1502 |
1499 // Note that we only call setOrientation on the main page's mock since this | 1503 // Note that we only call setOrientation on the main page's mock since this |
1500 // tests require. If necessary, we could get a list of WebViewHosts from th | 1504 // tests require. If necessary, we could get a list of WebViewHosts from th |
1501 // call setOrientation on each DeviceOrientationClientMock. | 1505 // call setOrientation on each DeviceOrientationClientMock. |
1502 m_proxy->deviceOrientationClientMock()->setOrientation(orientation); | 1506 m_proxy->deviceOrientationClientMock()->setOrientation(orientation); |
1503 } | 1507 } |
1504 | 1508 |
| 1509 void TestRunner::setMockDeviceMotion(const CppArgumentList& arguments, CppVarian
t* result) |
| 1510 { |
| 1511 m_delegate->setDeviceMotionHandler(m_proxy->deviceMotionHandlerMock()); |
| 1512 } |
| 1513 |
| 1514 void TestRunner::fireMockDeviceMotion(const CppArgumentList& arguments, CppVaria
nt* result) |
| 1515 { |
| 1516 result->setNull(); |
| 1517 if (arguments.size() < 19 |
| 1518 || !arguments[0].isBool() || !arguments[1].isNumber() // acceleration.x |
| 1519 || !arguments[2].isBool() || !arguments[3].isNumber() // acceleration.y |
| 1520 || !arguments[4].isBool() || !arguments[5].isNumber() // acceleration.z |
| 1521 || !arguments[6].isBool() || !arguments[7].isNumber() // accelerationInc
ludingGravity.x |
| 1522 || !arguments[8].isBool() || !arguments[9].isNumber() // accelerationInc
ludingGravity.y |
| 1523 || !arguments[10].isBool() || !arguments[11].isNumber() // accelerationI
ncludingGravity.z |
| 1524 || !arguments[12].isBool() || !arguments[13].isNumber() // rotationRate.
alpha |
| 1525 || !arguments[14].isBool() || !arguments[15].isNumber() // rotationRate.
beta |
| 1526 || !arguments[16].isBool() || !arguments[17].isNumber() // rotationRate.
gamma |
| 1527 || !arguments[18].isNumber()) // interval |
| 1528 return; |
| 1529 |
| 1530 WebDeviceMotionData motion; |
| 1531 |
| 1532 // acceleration |
| 1533 if (arguments[0].toBoolean()) |
| 1534 motion.setAccelerationX(arguments[1].toDouble()); |
| 1535 if (arguments[2].toBoolean()) |
| 1536 motion.setAccelerationY(arguments[3].toDouble()); |
| 1537 if (arguments[4].toBoolean()) |
| 1538 motion.setAccelerationZ(arguments[5].toDouble()); |
| 1539 |
| 1540 // accelerationIncludingGravity |
| 1541 if (arguments[6].toBoolean()) |
| 1542 motion.setAccelerationIncludingGravityX(arguments[7].toDouble()); |
| 1543 if (arguments[8].toBoolean()) |
| 1544 motion.setAccelerationIncludingGravityY(arguments[9].toDouble()); |
| 1545 if (arguments[10].toBoolean()) |
| 1546 motion.setAccelerationIncludingGravityZ(arguments[11].toDouble()); |
| 1547 |
| 1548 // rotationRate |
| 1549 if (arguments[12].toBoolean()) |
| 1550 motion.setRotationRateAlpha(arguments[13].toDouble()); |
| 1551 if (arguments[14].toBoolean()) |
| 1552 motion.setRotationRateBeta(arguments[15].toDouble()); |
| 1553 if (arguments[16].toBoolean()) |
| 1554 motion.setRotationRateGamma(arguments[17].toDouble()); |
| 1555 |
| 1556 // interval |
| 1557 motion.setInterval(arguments[18].toDouble()); |
| 1558 |
| 1559 m_proxy->deviceMotionHandlerMock()->fireEvent(motion); |
| 1560 } |
| 1561 |
1505 void TestRunner::setUserStyleSheetEnabled(const CppArgumentList& arguments, CppV
ariant* result) | 1562 void TestRunner::setUserStyleSheetEnabled(const CppArgumentList& arguments, CppV
ariant* result) |
1506 { | 1563 { |
1507 if (arguments.size() > 0 && arguments[0].isBool()) { | 1564 if (arguments.size() > 0 && arguments[0].isBool()) { |
1508 m_delegate->preferences()->userStyleSheetLocation = arguments[0].value.b
oolValue ? m_userStyleSheetLocation : WebURL(); | 1565 m_delegate->preferences()->userStyleSheetLocation = arguments[0].value.b
oolValue ? m_userStyleSheetLocation : WebURL(); |
1509 m_delegate->applyPreferences(); | 1566 m_delegate->applyPreferences(); |
1510 } | 1567 } |
1511 result->setNull(); | 1568 result->setNull(); |
1512 } | 1569 } |
1513 | 1570 |
1514 void TestRunner::setUserStyleSheetLocation(const CppArgumentList& arguments, Cpp
Variant* result) | 1571 void TestRunner::setUserStyleSheetLocation(const CppArgumentList& arguments, Cpp
Variant* result) |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 result->setNull(); | 2085 result->setNull(); |
2029 } | 2086 } |
2030 | 2087 |
2031 void TestRunner::setPointerLockWillFailSynchronously(const CppArgumentList&, Cpp
Variant* result) | 2088 void TestRunner::setPointerLockWillFailSynchronously(const CppArgumentList&, Cpp
Variant* result) |
2032 { | 2089 { |
2033 m_pointerLockPlannedResult = PointerLockWillFailSync; | 2090 m_pointerLockPlannedResult = PointerLockWillFailSync; |
2034 result->setNull(); | 2091 result->setNull(); |
2035 } | 2092 } |
2036 | 2093 |
2037 } | 2094 } |
OLD | NEW |