Source/Platform/ChangeLog

 12012-08-16 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implements DeviceMotion by going through the platform layer, rather than
 9 through WebKit as is done by DeviceOrientation.
 10
 11 * Platform.gypi:
 12 * chromium/public/Platform.h:
 13 * chromium/public/WebDeviceMotionData.h: Added.
 14 * chromium/public/WebDeviceMotionDetector.h: Added.
 15 * chromium/public/WebDeviceMotionDetectorClient.h: Added.
 16
1172012-08-14 Gregg Tavares <gman@google.com>
218
319 Plumb through EXT_debug_marker entry points

Source/WebCore/ChangeLog

 12012-08-16 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implements DeviceMotion by going through the platform layer, rather than
 9 through WebKit as is done by DeviceOrientation.
 10
 11 * CMakelists.txt:
 12 * GNUmakefile.list.am:
 13 * Target.pri:
 14 * WebCore.gypi:
 15 * WebCore.vcproj/WebCore.vcproj:
 16 * dom/DOMAllInOne.cpp:
 17 * platform/DeviceMotionData.cpp: Renamed from Source/WebCore/dom/DeviceMotionData.cpp.
 18 * platform/DeviceMotionData.h: Renamed from Source/WebCore/dom/DeviceMotionData.h.
 19 * platform/chromium/DeviceMotionDetectorInternal.cpp: Added.
 20 * platform/chromium/DeviceMotionDetectorInternal.h: Added.
 21 * platform/chromium/support/WebDeviceMotionData.cpp: Added.
 22
1232012-08-16 Pierre Rossi <pierre.rossi@gmail.com>
224
325 [Qt] Remove FontQt4, HAVE_QRAWFONT flag and the related dead code

Source/WebKit/chromium/ChangeLog

 12012-08-16 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implements DeviceMotion by going through the platform layer, rather than
 9 through WebKit as is done by DeviceOrientation.
 10
 11 * public/platform/WebDeviceMotionData.h: Added.
 12 * public/platform/WebDeviceMotionDetector.h: Added.
 13 * public/platform/WebDeviceMotionDetectorClient.h: Added.
 14 * src/WebViewImpl.cpp:
 15 * src/WebViewImpl.h:
 16
1172012-08-16 Keishi Hattori <keishi@webkit.org>
218
319 DOMWindowPagePopup needs to be installed before loading the html inside the page popup

Source/Platform/Platform.gypi

5151 'chromium/public/WebCookie.h',
5252 'chromium/public/WebCookieJar.h',
5353 'chromium/public/WebData.h',
 54 'chromium/public/WebDeviceMotionData.h',
 55 'chromium/public/WebDeviceMotionDetector.h',
 56 'chromium/public/WebDeviceMotionDetectorClient.h',
5457 'chromium/public/WebDragData.h',
5558 'chromium/public/WebExternalTextureLayer.h',
5659 'chromium/public/WebExternalTextureLayerClient.h',

Source/Platform/chromium/public/Platform.h

@@class WebAudioBus;
5050class WebBlobRegistry;
5151class WebClipboard;
5252class WebCookieJar;
 53class WebDeviceMotionDetector;
5354class WebFileSystem;
5455class WebFileUtilities;
5556class WebFlingAnimator;

@@public:
9293 virtual WebClipboard* clipboard() { return 0; }
9394
9495 // Must return non-null.
 96 virtual WebDeviceMotionDetector* deviceMotionDetector() { return 0; }
 97
 98 // Must return non-null.
9599 virtual WebFileUtilities* fileUtilities() { return 0; }
96100
97101 // Must return non-null.

Source/Platform/chromium/public/WebDeviceMotionData.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionData_h
 27#define WebDeviceMotionData_h
 28
 29#include "WebPrivatePtr.h"
 30
 31namespace WTF { template <typename T> class PassRefPtr; }
 32namespace WebCore { class DeviceMotionData; }
 33
 34namespace WebKit {
 35
 36class WebDeviceMotionData {
 37public:
 38 WebDeviceMotionData();
 39 WebDeviceMotionData(const WebDeviceMotionData& other) { assign(other); }
 40 ~WebDeviceMotionData() { reset(); }
 41 WebDeviceMotionData operator=(const WebDeviceMotionData& other)
 42 {
 43 assign(other);
 44 return *this;
 45 }
 46 static WebDeviceMotionData nullMotion() { return WebDeviceMotionData(); }
 47
 48 WEBKIT_EXPORT void reset();
 49 WEBKIT_EXPORT void assign(const WebDeviceMotionData& other);
 50
 51 WEBKIT_EXPORT void initializeAcceleration(bool canProvideAccelerationX, double accelerationX, bool canProvideAccelerationY, double accelerationY, bool canProvideAccelerationZ, double accelerationZ);
 52 WEBKIT_EXPORT void initializeAccelerationIncludingGravity(bool canProvideAccelerationIncludingGravityX, double accelerationIncludingGravityX, bool canProvideAccelerationIncludingGravityY, double accelerationIncludingGravityY, bool canProvideAccelerationIncludingGravityZ, double accelerationIncludingGravityZ);
 53 WEBKIT_EXPORT void initializeRotationRate(bool canProvideRotationRateAlpha, double rotationRateAlpha, bool canProvideRotationRateBeta, double rotationRateBeta, bool canProvideRotationRateGamma, double rotationRateGamma);
 54 WEBKIT_EXPORT void initializeInterval(double interval);
 55
 56 bool isNull() const { return m_private.isNull(); }
 57
 58#if WEBKIT_IMPLEMENTATION
 59 WebDeviceMotionData(const WebCore::DeviceMotionData*);
 60 operator WTF::PassRefPtr<WebCore::DeviceMotionData>() const;
 61#endif
 62
 63private:
 64 WebPrivatePtr<WebCore::DeviceMotionData> m_private;
 65};
 66
 67} // namespace WebKit
 68
 69#endif // WebDeviceMotionData_h

Source/Platform/chromium/public/WebDeviceMotionDetector.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionDetector_h
 27#define WebDeviceMotionDetector_h
 28
 29#include "WebCommon.h"
 30#include "WebDeviceMotionData.h"
 31
 32namespace WebKit {
 33
 34class WebDeviceMotionDetectorClient;
 35
 36class WebDeviceMotionDetector {
 37public:
 38 virtual ~WebDeviceMotionDetector() { }
 39
 40 virtual void startUpdating(WebDeviceMotionDetectorClient*) { WEBKIT_ASSERT_NOT_REACHED(); }
 41 virtual void stopUpdating() { WEBKIT_ASSERT_NOT_REACHED(); }
 42
 43 virtual WebDeviceMotionData lastMotion() const
 44 {
 45 WEBKIT_ASSERT_NOT_REACHED();
 46 return WebDeviceMotionData::nullMotion();
 47 }
 48};
 49
 50} // namespace WebKit
 51
 52#endif // WebDeviceMotionDetector_h

Source/Platform/chromium/public/WebDeviceMotionDetectorClient.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionDetectorClient_h
 27#define WebDeviceMotionDetectorClient_h
 28
 29#include "WebCommon.h"
 30
 31namespace WebKit {
 32
 33class WebDeviceMotionData;
 34
 35class WebDeviceMotionDetectorClient {
 36public:
 37 virtual ~WebDeviceMotionDetectorClient() { }
 38
 39 virtual void didDetectDeviceMotion(const WebDeviceMotionData&) = 0;
 40};
 41
 42} // namespace WebKit
 43
 44#endif // WebDeviceMotionDetectorClient_h

Source/WebCore/CMakeLists.txt

@@SET(WebCore_SOURCES
10951095 dom/DataTransferItem.cpp
10961096 dom/DecodedDataDocumentParser.cpp
10971097 dom/DeviceMotionController.cpp
1098  dom/DeviceMotionData.cpp
10991098 dom/DeviceMotionEvent.cpp
11001099 dom/DeviceOrientationController.cpp
11011100 dom/DeviceOrientationData.cpp

@@SET(WebCore_SOURCES
17291728 platform/CrossThreadCopier.cpp
17301729 platform/DateComponents.cpp
17311730 platform/Decimal.cpp
 1731 platform/DeviceMotionData.cpp
17321732 platform/DragData.cpp
17331733 platform/DragImage.cpp
17341734 platform/EventTracer.cpp

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
26662666 Source/WebCore/dom/DeviceMotionClient.h \
26672667 Source/WebCore/dom/DeviceMotionController.cpp \
26682668 Source/WebCore/dom/DeviceMotionController.h \
2669  Source/WebCore/dom/DeviceMotionData.cpp \
2670  Source/WebCore/dom/DeviceMotionData.h \
26712669 Source/WebCore/dom/DeviceMotionEvent.cpp \
26722670 Source/WebCore/dom/DeviceMotionEvent.h \
26732671 Source/WebCore/dom/DeviceOrientationClient.h \

@@webcore_sources += \
41324130 Source/WebCore/platform/DateComponents.h \
41334131 Source/WebCore/platform/Decimal.cpp \
41344132 Source/WebCore/platform/Decimal.h \
 4133 Source/WebCore/platform/DeviceMotionData.cpp \
 4134 Source/WebCore/platform/DeviceMotionData.h \
41354135 Source/WebCore/platform/DragData.cpp \
41364136 Source/WebCore/platform/DragData.h \
41374137 Source/WebCore/platform/DragImage.cpp \

Source/WebCore/Target.pri

@@SOURCES += \
357357 dom/CustomEvent.cpp \
358358 dom/DecodedDataDocumentParser.cpp \
359359 dom/DeviceMotionController.cpp \
360  dom/DeviceMotionData.cpp \
361360 dom/DeviceMotionEvent.cpp \
362361 dom/DeviceOrientationController.cpp \
363362 dom/DeviceOrientationData.cpp \

@@SOURCES += \
921920 platform/CrossThreadCopier.cpp \
922921 platform/DateComponents.cpp \
923922 platform/Decimal.cpp \
 923 platform/DeviceMotionData.cpp \
924924 platform/DragData.cpp \
925925 platform/DragImage.cpp \
926926 platform/EventTracer.cpp \

@@HEADERS += \
14981498 dom/default/PlatformMessagePortChannel.h \
14991499 dom/DeviceMotionClient.h \
15001500 dom/DeviceMotionController.h \
1501  dom/DeviceMotionData.h \
15021501 dom/DeviceMotionEvent.h \
15031502 dom/DeviceOrientationClient.h \
15041503 dom/DeviceOrientationController.h \

@@HEADERS += \
20102009 platform/CrossThreadCopier.h \
20112010 platform/DateComponents.h \
20122011 platform/Decimal.h \
 2012 platform/DeviceMotionData.h \
20132013 platform/DragData.h \
20142014 platform/DragImage.h \
20152015 platform/EventTracer.h \

Source/WebCore/WebCore.gypi

277277 'platform/Cursor.h',
278278 'platform/DateComponents.h',
279279 'platform/Decimal.h',
 280 'platform/DeviceMotionData.h',
280281 'platform/DragData.h',
281282 'platform/DragImage.h',
282283 'platform/EventTracer.h',

633634 'dom/DOMImplementation.h',
634635 'dom/DOMTimeStamp.h',
635636 'dom/DeviceMotionClient.h',
636  'dom/DeviceMotionData.h',
637637 'dom/DeviceOrientationClient.h',
638638 'dom/DeviceOrientationData.h',
639639 'dom/Document.h',

32033203 'platform/Cursor.cpp',
32043204 'platform/DateComponents.cpp',
32053205 'platform/Decimal.cpp',
 3206 'platform/DeviceMotionData.cpp',
32063207 'platform/DragData.cpp',
32073208 'platform/DragImage.cpp',
32083209 'platform/EventLoop.h',

33773378 'platform/chromium/ContextMenuChromium.cpp',
33783379 'platform/chromium/ContextMenuItemChromium.cpp',
33793380 'platform/chromium/CursorChromium.cpp',
 3381 'platform/chromium/DeviceMotionDetectorInternal.cpp',
 3382 'platform/chromium/DeviceMotionDetectorInternal.h',
33803383 'platform/chromium/DragDataChromium.cpp',
33813384 'platform/chromium/DragDataRef.h',
33823385 'platform/chromium/DragImageChromiumSkia.cpp',

51465149 'dom/DeviceMotionClient.h',
51475150 'dom/DeviceMotionController.cpp',
51485151 'dom/DeviceMotionController.h',
5149  'dom/DeviceMotionData.cpp',
5150  'dom/DeviceMotionData.h',
51515152 'dom/DeviceMotionEvent.cpp',
51525153 'dom/DeviceMotionEvent.h',
51535154 'dom/DeviceOrientationController.cpp',

82328233 'platform/chromium/support/WebCompositorImpl.cpp',
82338234 'platform/chromium/support/WebCompositorImpl.h',
82348235 'platform/chromium/support/WebData.cpp',
 8236 'platform/chromium/support/WebDeviceMotionData.cpp',
82358237 'platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h',
82368238 'platform/chromium/support/WebHTTPBody.cpp',
82378239 'platform/chromium/support/WebHTTPLoadInfo.cpp',

Source/WebCore/WebCore.vcproj/WebCore.vcproj

2820728207 >
2820828208 </File>
2820928209 <File
 28210 RelativePath="..\platform\DeviceMotionData.cpp"
 28211 >
 28212 </File>
 28213 <File
 28214 RelativePath="..\platform\DeviceMotionData.h"
 28215 >
 28216 </File>
 28217 <File
2821028218 RelativePath="..\platform\DragData.cpp"
2821128219 >
2821228220 </File>

4940349411 >
4940449412 </File>
4940549413 <File
49406  RelativePath="..\dom\DeviceMotionData.cpp"
49407  >
49408  <FileConfiguration
49409  Name="Debug|Win32"
49410  ExcludedFromBuild="true"
49411  >
49412  <Tool
49413  Name="VCCLCompilerTool"
49414  />
49415  </FileConfiguration>
49416  <FileConfiguration
49417  Name="Release|Win32"
49418  ExcludedFromBuild="true"
49419  >
49420  <Tool
49421  Name="VCCLCompilerTool"
49422  />
49423  </FileConfiguration>
49424  <FileConfiguration
49425  Name="Debug_Cairo_CFLite|Win32"
49426  ExcludedFromBuild="true"
49427  >
49428  <Tool
49429  Name="VCCLCompilerTool"
49430  />
49431  </FileConfiguration>
49432  <FileConfiguration
49433  Name="Release_Cairo_CFLite|Win32"
49434  ExcludedFromBuild="true"
49435  >
49436  <Tool
49437  Name="VCCLCompilerTool"
49438  />
49439  </FileConfiguration>
49440  <FileConfiguration
49441  Name="Debug_All|Win32"
49442  ExcludedFromBuild="true"
49443  >
49444  <Tool
49445  Name="VCCLCompilerTool"
49446  />
49447  </FileConfiguration>
49448  <FileConfiguration
49449  Name="Production|Win32"
49450  ExcludedFromBuild="true"
49451  >
49452  <Tool
49453  Name="VCCLCompilerTool"
49454  />
49455  </FileConfiguration>
49456  </File>
49457  <File
49458  RelativePath="..\dom\DeviceMotionData.h"
49459  >
49460  </File>
49461  <File
4946249414 RelativePath="..\dom\DeviceMotionEvent.cpp"
4946349415 >
4946449416 <FileConfiguration

Source/WebCore/dom/DOMAllInOne.cpp

5353#include "DatasetDOMStringMap.cpp"
5454#include "DecodedDataDocumentParser.cpp"
5555#include "DeviceMotionController.cpp"
56 #include "DeviceMotionData.cpp"
5756#include "DeviceMotionEvent.cpp"
5857#include "DeviceOrientationController.cpp"
5958#include "DeviceOrientationData.cpp"

Source/WebCore/dom/DeviceMotionData.cpp

1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "DeviceMotionData.h"
28 
29 namespace WebCore {
30 
31 PassRefPtr<DeviceMotionData::Acceleration> DeviceMotionData::Acceleration::create(bool canProvideX, double x,
32  bool canProvideY, double y,
33  bool canProvideZ, double z)
34 {
35  return adoptRef(new DeviceMotionData::Acceleration(canProvideX, x, canProvideY, y, canProvideZ, z));
36 }
37 
38 DeviceMotionData::Acceleration::Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z)
39  : m_x(x)
40  , m_y(y)
41  , m_z(z)
42  , m_canProvideX(canProvideX)
43  , m_canProvideY(canProvideY)
44  , m_canProvideZ(canProvideZ)
45 
46 {
47 }
48 
49 PassRefPtr<DeviceMotionData::RotationRate> DeviceMotionData::RotationRate::create(bool canProvideAlpha, double alpha,
50  bool canProvideBeta, double beta,
51  bool canProvideGamma, double gamma)
52 {
53  return adoptRef(new DeviceMotionData::RotationRate(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma));
54 }
55 
56 DeviceMotionData::RotationRate::RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
57  : m_alpha(alpha)
58  , m_beta(beta)
59  , m_gamma(gamma)
60  , m_canProvideAlpha(canProvideAlpha)
61  , m_canProvideBeta(canProvideBeta)
62  , m_canProvideGamma(canProvideGamma)
63 {
64 }
65 
66 PassRefPtr<DeviceMotionData> DeviceMotionData::create()
67 {
68  return adoptRef(new DeviceMotionData);
69 }
70 
71 PassRefPtr<DeviceMotionData> DeviceMotionData::create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
72  PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval)
73 {
74  return adoptRef(new DeviceMotionData(acceleration, accelerationIncludingGravity, rotationRate, canProvideInterval, interval));
75 }
76 
77 DeviceMotionData::DeviceMotionData()
78  : m_canProvideInterval(false)
79  , m_interval(0)
80 {
81 }
82 
83 DeviceMotionData::DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
84  PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval)
85  : m_acceleration(acceleration)
86  , m_accelerationIncludingGravity(accelerationIncludingGravity)
87  , m_rotationRate(rotationRate)
88  , m_canProvideInterval(canProvideInterval)
89  , m_interval(interval)
90 {
91 }
92 
93 } // namespace WebCore

Source/WebCore/dom/DeviceMotionData.h

1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef DeviceMotionData_h
27 #define DeviceMotionData_h
28 
29 #include <wtf/PassRefPtr.h>
30 #include <wtf/RefCounted.h>
31 #include <wtf/RefPtr.h>
32 
33 namespace WebCore {
34 
35 class DeviceMotionData : public RefCounted<DeviceMotionData> {
36 public:
37  class Acceleration : public RefCounted<DeviceMotionData::Acceleration> {
38  public:
39  static PassRefPtr<Acceleration> create(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z);
40 
41  bool canProvideX() const { return m_canProvideX; }
42  bool canProvideY() const { return m_canProvideY; }
43  bool canProvideZ() const { return m_canProvideZ; }
44 
45  double x() const { return m_x; }
46  double y() const { return m_y; }
47  double z() const { return m_z; }
48 
49  private:
50  Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z);
51 
52  double m_x;
53  double m_y;
54  double m_z;
55 
56  bool m_canProvideX;
57  bool m_canProvideY;
58  bool m_canProvideZ;
59  };
60 
61  class RotationRate : public RefCounted<DeviceMotionData::RotationRate> {
62  public:
63  static PassRefPtr<RotationRate> create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
64 
65  bool canProvideAlpha() const { return m_canProvideAlpha; }
66  bool canProvideBeta() const { return m_canProvideBeta; }
67  bool canProvideGamma() const { return m_canProvideGamma; }
68 
69  double alpha() const { return m_alpha; }
70  double beta() const { return m_beta; }
71  double gamma() const { return m_gamma; }
72 
73  private:
74  RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
75 
76  double m_alpha;
77  double m_beta;
78  double m_gamma;
79 
80  bool m_canProvideAlpha;
81  bool m_canProvideBeta;
82  bool m_canProvideGamma;
83  };
84 
85  static PassRefPtr<DeviceMotionData> create();
86  static PassRefPtr<DeviceMotionData> create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
87  PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval);
88 
89  const Acceleration* acceleration() const { return m_acceleration.get(); }
90  const Acceleration* accelerationIncludingGravity() const { return m_accelerationIncludingGravity.get(); }
91  const RotationRate* rotationRate() const { return m_rotationRate.get(); }
92  double interval() const { return m_interval; }
93  bool canProvideInterval() const { return m_canProvideInterval; }
94 
95 private:
96  DeviceMotionData();
97  DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
98  PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval);
99 
100  RefPtr<Acceleration> m_acceleration;
101  RefPtr<Acceleration> m_accelerationIncludingGravity;
102  RefPtr<RotationRate> m_rotationRate;
103  bool m_canProvideInterval;
104  double m_interval;
105 };
106 
107 } // namespace WebCore
108 
109 #endif // DeviceMotionData_h

Source/WebCore/platform/DeviceMotionData.cpp

 1/*
 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceMotionData.h"
 28
 29namespace WebCore {
 30
 31PassRefPtr<DeviceMotionData::Acceleration> DeviceMotionData::Acceleration::create(bool canProvideX, double x,
 32 bool canProvideY, double y,
 33 bool canProvideZ, double z)
 34{
 35 return adoptRef(new DeviceMotionData::Acceleration(canProvideX, x, canProvideY, y, canProvideZ, z));
 36}
 37
 38DeviceMotionData::Acceleration::Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z)
 39 : m_x(x)
 40 , m_y(y)
 41 , m_z(z)
 42 , m_canProvideX(canProvideX)
 43 , m_canProvideY(canProvideY)
 44 , m_canProvideZ(canProvideZ)
 45
 46{
 47}
 48
 49PassRefPtr<DeviceMotionData::RotationRate> DeviceMotionData::RotationRate::create(bool canProvideAlpha, double alpha,
 50 bool canProvideBeta, double beta,
 51 bool canProvideGamma, double gamma)
 52{
 53 return adoptRef(new DeviceMotionData::RotationRate(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma));
 54}
 55
 56DeviceMotionData::RotationRate::RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
 57 : m_alpha(alpha)
 58 , m_beta(beta)
 59 , m_gamma(gamma)
 60 , m_canProvideAlpha(canProvideAlpha)
 61 , m_canProvideBeta(canProvideBeta)
 62 , m_canProvideGamma(canProvideGamma)
 63{
 64}
 65
 66PassRefPtr<DeviceMotionData> DeviceMotionData::create()
 67{
 68 return adoptRef(new DeviceMotionData);
 69}
 70
 71PassRefPtr<DeviceMotionData> DeviceMotionData::create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
 72 PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval)
 73{
 74 return adoptRef(new DeviceMotionData(acceleration, accelerationIncludingGravity, rotationRate, canProvideInterval, interval));
 75}
 76
 77DeviceMotionData::DeviceMotionData()
 78 : m_canProvideInterval(false)
 79 , m_interval(0)
 80{
 81}
 82
 83DeviceMotionData::DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,
 84 PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval)
 85 : m_acceleration(acceleration)
 86 , m_accelerationIncludingGravity(accelerationIncludingGravity)
 87 , m_rotationRate(rotationRate)
 88 , m_canProvideInterval(canProvideInterval)
 89 , m_interval(interval)
 90{
 91}
 92
 93} // namespace WebCore

Source/WebCore/platform/DeviceMotionData.h

 1/*
 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceMotionData_h
 27#define DeviceMotionData_h
 28
 29#include <wtf/PassRefPtr.h>
 30#include <wtf/RefCounted.h>
 31#include <wtf/RefPtr.h>
 32
 33namespace WebCore {
 34
 35class DeviceMotionData : public RefCounted<DeviceMotionData> {
 36public:
 37 class Acceleration : public RefCounted<DeviceMotionData::Acceleration> {
 38 public:
 39 static PassRefPtr<Acceleration> create(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z);
 40
 41 bool canProvideX() const { return m_canProvideX; }
 42 bool canProvideY() const { return m_canProvideY; }
 43 bool canProvideZ() const { return m_canProvideZ; }
 44
 45 double x() const { return m_x; }
 46 double y() const { return m_y; }
 47 double z() const { return m_z; }
 48
 49 private:
 50 Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z);
 51
 52 double m_x;
 53 double m_y;
 54 double m_z;
 55
 56 bool m_canProvideX;
 57 bool m_canProvideY;
 58 bool m_canProvideZ;
 59 };
 60
 61 class RotationRate : public RefCounted<DeviceMotionData::RotationRate> {
 62 public:
 63 static PassRefPtr<RotationRate> create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
 64
 65 bool canProvideAlpha() const { return m_canProvideAlpha; }
 66 bool canProvideBeta() const { return m_canProvideBeta; }
 67 bool canProvideGamma() const { return m_canProvideGamma; }
 68
 69 double alpha() const { return m_alpha; }
 70 double beta() const { return m_beta; }
 71 double gamma() const { return m_gamma; }
 72
 73 private:
 74 RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
 75
 76 double m_alpha;
 77 double m_beta;
 78 double m_gamma;
 79
 80 bool m_canProvideAlpha;
 81 bool m_canProvideBeta;
 82 bool m_canProvideGamma;
 83 };
 84
 85 static PassRefPtr<DeviceMotionData> create();
 86 static PassRefPtr<DeviceMotionData> create(PassRefPtr<Acceleration>, PassRefPtr<Acceleration> accelerationIncludingGravity,
 87 PassRefPtr<RotationRate>, bool canProvideInterval, double interval);
 88
 89 const Acceleration* acceleration() const { return m_acceleration.get(); }
 90 const Acceleration* accelerationIncludingGravity() const { return m_accelerationIncludingGravity.get(); }
 91 const RotationRate* rotationRate() const { return m_rotationRate.get(); }
 92 double interval() const { return m_interval; }
 93 bool canProvideInterval() const { return m_canProvideInterval; }
 94
 95 void setAcceleration(PassRefPtr<Acceleration> acceleration)
 96 {
 97 m_acceleration.clear();
 98 m_acceleration = acceleration;
 99 }
 100 void setAccelerationIncludingGravity(PassRefPtr<Acceleration> accelerationIncludingGravity)
 101 {
 102 m_accelerationIncludingGravity.clear();
 103 m_accelerationIncludingGravity = accelerationIncludingGravity;
 104 }
 105 void setRotationRate(PassRefPtr<RotationRate> rotationRate)
 106 {
 107 m_rotationRate.clear();
 108 m_rotationRate = rotationRate;
 109 }
 110 void setInterval(double interval)
 111 {
 112 m_canProvideInterval = true;
 113 m_interval = interval;
 114 }
 115
 116private:
 117 DeviceMotionData();
 118 DeviceMotionData(PassRefPtr<Acceleration>, PassRefPtr<Acceleration> accelerationIncludingGravity,
 119 PassRefPtr<RotationRate>, bool canProvideInterval, double interval);
 120
 121 RefPtr<Acceleration> m_acceleration;
 122 RefPtr<Acceleration> m_accelerationIncludingGravity;
 123 RefPtr<RotationRate> m_rotationRate;
 124 bool m_canProvideInterval;
 125 double m_interval;
 126};
 127
 128} // namespace WebCore
 129
 130#endif // DeviceMotionData_h

Source/WebCore/platform/chromium/DeviceMotionDetectorInternal.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceMotionDetectorInternal.h"
 28
 29#include "DeviceMotionController.h"
 30#include "DeviceMotionData.h"
 31#include <public/WebDeviceMotionData.h>
 32#include <public/WebDeviceMotionDetector.h>
 33#include <wtf/OwnPtr.h>
 34#include <wtf/PassRefPtr.h>
 35#include <wtf/RefPtr.h>
 36
 37namespace WebCore {
 38
 39DeviceMotionDetectorInternal::DeviceMotionDetectorInternal()
 40 : m_controller(0)
 41 , m_detector(0)
 42{
 43}
 44
 45DeviceMotionDetectorInternal::~DeviceMotionDetectorInternal()
 46{
 47}
 48
 49void DeviceMotionDetectorInternal::setController(DeviceMotionController* controller)
 50{
 51 // FIXME: allow for multiple DeviceMotionControllers or make
 52 // DeviceMotionController a singleton too
 53 if (!m_controller)
 54 m_controller = controller;
 55}
 56
 57void DeviceMotionDetectorInternal::startUpdating()
 58{
 59 m_detector = WebKit::Platform::current()->deviceMotionDetector();
 60 m_detector->startUpdating(this);
 61}
 62
 63void DeviceMotionDetectorInternal::stopUpdating()
 64{
 65 if (!m_detector)
 66 return;
 67 m_detector->stopUpdating();
 68}
 69
 70DeviceMotionData* DeviceMotionDetectorInternal::lastMotion() const
 71{
 72 if (!m_detector)
 73 return 0;
 74
 75 // Cache the DeviceMotion pointer so its reference count does not drop to zero upon return.
 76 m_lastMotion = m_detector->lastMotion();
 77
 78 return m_lastMotion.get();
 79}
 80
 81void DeviceMotionDetectorInternal::deviceMotionControllerDestroyed()
 82{
 83 // Our lifetime is bound to the WebViewImpl.
 84}
 85
 86void DeviceMotionDetectorInternal::didDetectDeviceMotion(const WebKit::WebDeviceMotionData& motion)
 87{
 88 if (m_controller) {
 89 RefPtr<DeviceMotionData> deviceMotionData = PassRefPtr<DeviceMotionData>(motion);
 90 if (!deviceMotionData)
 91 deviceMotionData = DeviceMotionData::create();
 92 m_controller->didChangeDeviceMotion(deviceMotionData.get());
 93 }
 94}
 95
 96} // namespace WebCore

Source/WebCore/platform/chromium/DeviceMotionDetectorInternal.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceMotionDetectorInternal_h
 27#define DeviceMotionDetectorInternal_h
 28
 29#include "DeviceMotionClient.h"
 30#include <public/Platform.h>
 31#include <public/WebDeviceMotionDetectorClient.h>
 32#include <wtf/OwnPtr.h>
 33#include <wtf/RefPtr.h>
 34
 35namespace WebKit {
 36class WebDeviceMotionData;
 37class WebDeviceMotionDetector;
 38};
 39
 40namespace WebCore {
 41
 42class DeviceMotionController;
 43class DeviceMotionData;
 44
 45class DeviceMotionDetectorInternal : public DeviceMotionClient, public WebKit::WebDeviceMotionDetectorClient {
 46public:
 47 DeviceMotionDetectorInternal();
 48 ~DeviceMotionDetectorInternal();
 49
 50 // DeviceMotionClient implementation.
 51 virtual void setController(DeviceMotionController*);
 52 virtual void startUpdating();
 53 virtual void stopUpdating();
 54 virtual DeviceMotionData* lastMotion() const;
 55 virtual void deviceMotionControllerDestroyed();
 56
 57 // WebKit::WebDeviceMotionDetectorClient implementation.
 58 virtual void didDetectDeviceMotion(const WebKit::WebDeviceMotionData&) OVERRIDE;
 59
 60private:
 61 DeviceMotionController* m_controller;
 62 WebKit::WebDeviceMotionDetector* m_detector;
 63 mutable RefPtr<DeviceMotionData> m_lastMotion;
 64};
 65
 66} // namespace WebCore
 67
 68#endif // DeviceMotionDetectorInternal_h

Source/WebCore/platform/chromium/support/WebDeviceMotionData.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include <public/WebDeviceMotionData.h>
 28
 29#include "DeviceMotionData.h"
 30#include <wtf/PassRefPtr.h>
 31
 32using namespace WebCore;
 33
 34namespace WebKit {
 35
 36WebDeviceMotionData::WebDeviceMotionData()
 37{
 38}
 39
 40void WebDeviceMotionData::reset()
 41{
 42 m_private.reset();
 43}
 44
 45void WebDeviceMotionData::assign(const WebDeviceMotionData& other)
 46{
 47 m_private = other.m_private;
 48}
 49
 50void WebDeviceMotionData::initializeAcceleration(bool canProvideAccelerationX, double accelerationX, bool canProvideAccelerationY, double accelerationY, bool canProvideAccelerationZ, double accelerationZ)
 51{
 52 if (m_private.isNull())
 53 m_private = DeviceMotionData::create();
 54 RefPtr<DeviceMotionData::Acceleration> acceleration = DeviceMotionData::Acceleration::create(canProvideAccelerationX, accelerationX, canProvideAccelerationY, accelerationY, canProvideAccelerationZ, accelerationZ);
 55 m_private->setAcceleration(acceleration.release());
 56}
 57
 58void WebDeviceMotionData::initializeAccelerationIncludingGravity(bool canProvideAccelerationIncludingGravityX, double accelerationIncludingGravityX, bool canProvideAccelerationIncludingGravityY, double accelerationIncludingGravityY, bool canProvideAccelerationIncludingGravityZ, double accelerationIncludingGravityZ)
 59{
 60 if (m_private.isNull())
 61 m_private = DeviceMotionData::create();
 62 RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = DeviceMotionData::Acceleration::create(canProvideAccelerationIncludingGravityX, accelerationIncludingGravityX, canProvideAccelerationIncludingGravityY, accelerationIncludingGravityY, canProvideAccelerationIncludingGravityZ, accelerationIncludingGravityZ);
 63 m_private->setAccelerationIncludingGravity(accelerationIncludingGravity.release());
 64}
 65
 66void WebDeviceMotionData::initializeRotationRate(bool canProvideRotationRateAlpha, double rotationRateAlpha, bool canProvideRotationRateBeta, double rotationRateBeta, bool canProvideRotationRateGamma, double rotationRateGamma)
 67{
 68 if (m_private.isNull())
 69 m_private = DeviceMotionData::create();
 70 RefPtr<DeviceMotionData::RotationRate> rotationRate = DeviceMotionData::RotationRate::create(canProvideRotationRateAlpha, rotationRateAlpha, canProvideRotationRateBeta, rotationRateBeta, canProvideRotationRateGamma, rotationRateGamma);
 71 m_private->setRotationRate(rotationRate.release());
 72}
 73
 74void WebDeviceMotionData::initializeInterval(double interval)
 75{
 76 if (m_private.isNull())
 77 m_private = DeviceMotionData::create();
 78 m_private->setInterval(interval);
 79}
 80
 81WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>() const
 82{
 83 return m_private.get();
 84}
 85
 86} // namespace WebKit

Source/WebKit/chromium/public/platform/WebDeviceMotionData.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "../../../../Platform/chromium/public/WebDeviceMotionData.h"

Source/WebKit/chromium/public/platform/WebDeviceMotionDetector.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "../../../../Platform/chromium/public/WebDeviceMotionDetector.h"

Source/WebKit/chromium/public/platform/WebDeviceMotionDetectorClient.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "../../../../Platform/chromium/public/WebDeviceMotionDetectorClient.h"

Source/WebKit/chromium/src/WebViewImpl.cpp

4949#include "ContextMenuItem.h"
5050#include "Cursor.h"
5151#include "DOMUtilitiesPrivate.h"
 52#include "DeviceMotionDetectorInternal.h"
5253#include "DeviceOrientationClientProxy.h"
5354#include "Document.h"
5455#include "DocumentLoader.h"

@@WebViewImpl::WebViewImpl(WebViewClient* client)
423424#if ENABLE(SCRIPTED_SPEECH)
424425 , m_speechRecognitionClient(SpeechRecognitionClientProxy::create(client ? client->speechRecognizer() : 0))
425426#endif
 427 , m_deviceMotionDetectorInternal(adoptPtr(new WebCore::DeviceMotionDetectorInternal()))
426428 , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
427429 , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
428430#if ENABLE(BATTERY_STATUS)

@@WebViewImpl::WebViewImpl(WebViewClient* client)
469471#endif
470472
471473 provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get());
 474 provideDeviceMotionTo(m_page.get(), m_deviceMotionDetectorInternal.get());
472475 provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
473476 provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get());
474477 m_geolocationClientProxy->setController(GeolocationController::from(m_page.get()));

Source/WebKit/chromium/src/WebViewImpl.h

@@namespace WebCore {
6565class ActivePlatformGestureAnimation;
6666class ChromiumDataObject;
6767class Color;
 68class DeviceMotionDetectorInternal;
6869class DocumentLoader;
6970class Frame;
7071class GraphicsContext3D;

@@private:
832833 OwnPtr<SpeechRecognitionClientProxy> m_speechRecognitionClient;
833834#endif
834835
 836
 837 // If we attempt to fetch the on-screen GraphicsContext3D before
 838 // the compositor has been turned on, we need to instantiate it
 839 // early. This member holds on to the GC3D in this case.
 840 OwnPtr<WebGraphicsContext3D> m_temporaryOnscreenGraphicsContext3D;
 841 OwnPtr<WebCore::DeviceMotionDetectorInternal> m_deviceMotionDetectorInternal;
835842 OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
836843 OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
837844#if ENABLE(BATTERY_STATUS)

Tools/ChangeLog

 12012-08-16 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Adds functionality for testing DeviceMotion using WebDeviceMotionClientMock.
 9
 10 * DumpRenderTree/DumpRenderTree.gypi:
 11 * DumpRenderTree/chromium/DRTTestRunner.cpp:
 12 * DumpRenderTree/chromium/DRTTestRunner.h:
 13 * DumpRenderTree/chromium/DumpRenderTree.cpp:
 14 * DumpRenderTree/chromium/MockWebDeviceMotionDetector.cpp: Added.
 15 * DumpRenderTree/chromium/MockWebDeviceMotionDetector.h: Added.
 16 * DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp:
 17 * DumpRenderTree/chromium/MockWebKitPlatformSupport.h:
 18 * DumpRenderTree/chromium/TestShell.h:
 19
1202012-08-16 Pierre Rossi <pierre.rossi@gmail.com>
221
322 [Qt] Remove FontQt4, HAVE_QRAWFONT flag and the related dead code

Tools/DumpRenderTree/DumpRenderTree.gypi

1212 'chromium/MockGrammarCheck.h',
1313 'chromium/MockSpellCheck.cpp',
1414 'chromium/MockSpellCheck.h',
 15 'chromium/MockWebDeviceMotionDetector.cpp',
 16 'chromium/MockWebDeviceMotionDetector.h',
1517 'chromium/MockWebKitPlatformSupport.cpp',
1618 'chromium/MockWebKitPlatformSupport.h',
1719 'chromium/MockWebMediaStreamCenter.cpp',

Tools/DumpRenderTree/chromium/DRTTestRunner.cpp

3333#include "DRTTestRunner.h"
3434
3535#include "DRTDevToolsAgent.h"
 36#include "MockWebDeviceMotionDetector.h"
3637#include "MockWebSpeechInputController.h"
3738#include "MockWebSpeechRecognizer.h"
3839#include "TestShell.h"

6263#include "WebViewHost.h"
6364#include "WebWorkerInfo.h"
6465#include "platform/WebData.h"
 66#include "platform/WebDeviceMotionData.h"
6567#include "platform/WebSerializedScriptValue.h"
6668#include "platform/WebSize.h"
6769#include "platform/WebURL.h"

@@DRTTestRunner::DRTTestRunner(TestShell* shell)
203205 bindMethod("setIconDatabaseEnabled", &DRTTestRunner::setIconDatabaseEnabled);
204206 bindMethod("setJavaScriptCanAccessClipboard", &DRTTestRunner::setJavaScriptCanAccessClipboard);
205207 bindMethod("setMinimumTimerInterval", &DRTTestRunner::setMinimumTimerInterval);
 208 bindMethod("setMockDeviceMotion", &DRTTestRunner::setMockDeviceMotion);
206209 bindMethod("setMockDeviceOrientation", &DRTTestRunner::setMockDeviceOrientation);
207210 bindMethod("setMockGeolocationError", &DRTTestRunner::setMockGeolocationError);
208211 bindMethod("setMockGeolocationPosition", &DRTTestRunner::setMockGeolocationPosition);

@@void DRTTestRunner::addUserStyleSheet(const CppArgumentList& arguments, CppVaria
18471850 WebView::UserStyleInjectInExistingDocuments);
18481851}
18491852
 1853void DRTTestRunner::setMockDeviceMotion(const CppArgumentList& arguments, CppVariant* result)
 1854{
 1855 result->setNull();
 1856 if (arguments.size() < 20 || !arguments[0].isBool() || !arguments[1].isNumber() || !arguments[2].isBool() || !arguments[3].isNumber() || !arguments[4].isBool() || !arguments[5].isNumber() || !arguments[6].isBool() || !arguments[7].isNumber() || !arguments[8].isBool() || !arguments[9].isNumber() || !arguments[10].isBool() || !arguments[11].isNumber() || !arguments[12].isBool() || !arguments[13].isNumber() || !arguments[14].isBool() || !arguments[15].isNumber() || !arguments[16].isBool() || !arguments[17].isNumber() || !arguments[18].isBool() || !arguments[19].isNumber())
 1857 return;
 1858
 1859 WebDeviceMotionData motion;
 1860 // Initialize each of acceleration, accelerationIncludingGravity, and
 1861 // rotationRate iff at least one of their members can be provided.
 1862 if (arguments[0].toBoolean() || arguments[2].toBoolean() || arguments[4].toBoolean())
 1863 motion.initializeAcceleration(arguments[0].toBoolean(), arguments[1].toDouble(), arguments[2].toBoolean(), arguments[3].toDouble(), arguments[4].toBoolean(), arguments[5].toDouble());
 1864
 1865 if (arguments[6].toBoolean() || arguments[8].toBoolean() || arguments[10].toBoolean())
 1866 motion.initializeAccelerationIncludingGravity(arguments[6].toBoolean(), arguments[7].toDouble(), arguments[8].toBoolean(), arguments[9].toDouble(), arguments[10].toBoolean(), arguments[11].toDouble());
 1867
 1868 if (arguments[12].toBoolean() || arguments[14].toBoolean() || arguments[16].toBoolean())
 1869 motion.initializeRotationRate(arguments[12].toBoolean(), arguments[13].toDouble(), arguments[14].toBoolean(), arguments[15].toDouble(), arguments[16].toBoolean(), arguments[17].toDouble());
 1870
 1871 if (arguments[18].toBoolean())
 1872 motion.initializeInterval(arguments[19].toDouble());
 1873
 1874 m_shell->deviceMotionDetectorMock()->setMotion(motion);
 1875}
 1876
18501877void DRTTestRunner::setMockDeviceOrientation(const CppArgumentList& arguments, CppVariant* result)
18511878{
18521879 result->setNull();

Tools/DumpRenderTree/chromium/DRTTestRunner.h

@@public:
338338 void addUserStyleSheet(const CppArgumentList&, CppVariant*);
339339
340340 // DeviceOrientation related functions
 341 void setMockDeviceMotion(const CppArgumentList&, CppVariant*);
341342 void setMockDeviceOrientation(const CppArgumentList&, CppVariant*);
342343
343344 // Geolocation related functions.

Tools/DumpRenderTree/chromium/DumpRenderTree.cpp

4040#include <wtf/OwnPtr.h>
4141#include <wtf/Vector.h>
4242
 43class MockWebDeviceMotionDetector;
 44
4345using namespace std;
4446
4547static const char optionComplexText[] = "--complex-text";

@@public:
8183 {
8284 webkit_support::TearDownTestEnvironment();
8385 }
 86 MockWebDeviceMotionDetector* mockDeviceMotionDetector()
 87 {
 88 return m_mockPlatform->mockDeviceMotionDetector();
 89 }
8490private:
8591 OwnPtr<MockWebKitPlatformSupport> m_mockPlatform;
8692};

@@int main(int argc, char* argv[])
205211
206212 { // Explicit scope for the TestShell instance.
207213 TestShell shell;
 214 shell.setMockDeviceMotionDetector(testEnvironment.mockDeviceMotionDetector());
208215 shell.setAllowExternalPages(allowExternalPages);
209216 shell.setAcceleratedCompositingForVideoEnabled(acceleratedCompositingForVideoEnabled);
210217 shell.setThreadedCompositingEnabled(threadedCompositingEnabled);

Tools/DumpRenderTree/chromium/MockWebDeviceMotionDetector.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "MockWebDeviceMotionDetector.h"
 28
 29#include "platform/WebDeviceMotionData.h"
 30#include "platform/WebDeviceMotionDetectorClient.h"
 31
 32using namespace WebKit;
 33
 34namespace {
 35
 36// Task for delivering a motion event.
 37class MotionTask : public MockWebDeviceMotionDetector::Task {
 38public:
 39 MotionTask(MockWebDeviceMotionDetector* mock, const WebKit::WebDeviceMotionData& motion)
 40 : MockWebDeviceMotionDetector::Task(mock)
 41 , m_motion(motion)
 42 {
 43 }
 44
 45 virtual void run() OVERRIDE
 46 {
 47 if (m_detector->isUpdating())
 48 m_detector->client()->didDetectDeviceMotion(m_motion);
 49 }
 50
 51private:
 52 WebKit::WebDeviceMotionData m_motion;
 53};
 54
 55} // namespace
 56
 57
 58PassOwnPtr<MockWebDeviceMotionDetector> MockWebDeviceMotionDetector::create()
 59{
 60 return adoptPtr(new MockWebDeviceMotionDetector());
 61}
 62
 63void MockWebDeviceMotionDetector::startUpdating(WebDeviceMotionDetectorClient* client)
 64{
 65 m_client = client;
 66 m_isUpdating = true;
 67 startTaskQueue();
 68}
 69
 70void MockWebDeviceMotionDetector::stopUpdating()
 71{
 72 m_isUpdating = false;
 73 clearTaskQueue();
 74}
 75
 76WebKit::WebDeviceMotionData MockWebDeviceMotionDetector::lastMotion() const
 77{
 78 return m_lastMotion;
 79}
 80
 81void MockWebDeviceMotionDetector::setMotion(WebKit::WebDeviceMotionData& motion)
 82{
 83 m_lastMotion = motion;
 84 m_taskQueue.append(adoptPtr(new MotionTask(this, motion)));
 85}
 86
 87MockWebDeviceMotionDetector::MockWebDeviceMotionDetector()
 88 : m_isUpdating(false)
 89 , m_taskQueueRunning(false)
 90{
 91}
 92
 93MockWebDeviceMotionDetector::~MockWebDeviceMotionDetector()
 94{
 95}
 96
 97void MockWebDeviceMotionDetector::startTaskQueue()
 98{
 99 if (m_taskQueueRunning)
 100 return;
 101 postTask(new StepTask(this));
 102 m_taskQueueRunning = true;
 103}
 104
 105void MockWebDeviceMotionDetector::clearTaskQueue()
 106{
 107 m_taskQueue.clear();
 108 m_taskQueueRunning = false;
 109}
 110
 111void MockWebDeviceMotionDetector::StepTask::runIfValid()
 112{
 113 if (m_object->m_taskQueue.isEmpty()) {
 114 m_object->m_taskQueueRunning = false;
 115 return;
 116 }
 117
 118 OwnPtr<Task> task = m_object->m_taskQueue[0].release();
 119 m_object->m_taskQueue.remove(0);
 120 task->run();
 121
 122 if (m_object->m_taskQueue.isEmpty()) {
 123 m_object->m_taskQueueRunning = false;
 124 return;
 125 }
 126
 127 postTask(new StepTask(m_object));
 128}
 129

Tools/DumpRenderTree/chromium/MockWebDeviceMotionDetector.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef MockWebDeviceMotionDetector_h
 27#define MockWebDeviceMotionDetector_h
 28
 29#include "Task.h"
 30#include "platform/WebDeviceMotionDetector.h"
 31#include <wtf/PassOwnPtr.h>
 32
 33namespace WebKit {
 34class WebDeviceMotionDetectorClient;
 35}
 36
 37class MockWebDeviceMotionDetector : public WebKit::WebDeviceMotionDetector {
 38public:
 39 static PassOwnPtr<MockWebDeviceMotionDetector> create();
 40 ~MockWebDeviceMotionDetector();
 41
 42 // WebDeviceMotionDetector implementation:
 43 virtual void startUpdating(WebKit::WebDeviceMotionDetectorClient*) OVERRIDE;
 44 virtual void stopUpdating() OVERRIDE;
 45 virtual WebKit::WebDeviceMotionData lastMotion() const OVERRIDE;
 46
 47 // Method accessed by layout tests:
 48 void setMotion(WebKit::WebDeviceMotionData&);
 49
 50 // Methods accessed from Task objects:
 51 WebKit::WebDeviceMotionDetectorClient* client() { return m_client; }
 52 bool isUpdating() { return m_isUpdating; }
 53 TaskList* taskList() { return &m_taskList; }
 54
 55 class Task {
 56 public:
 57 Task(MockWebDeviceMotionDetector* detector) : m_detector(detector) { }
 58 virtual ~Task() { }
 59 virtual void run() = 0;
 60 protected:
 61 MockWebDeviceMotionDetector* m_detector;
 62 };
 63
 64private:
 65 MockWebDeviceMotionDetector();
 66 void startTaskQueue();
 67 void clearTaskQueue();
 68
 69 TaskList m_taskList;
 70 WebKit::WebDeviceMotionData m_lastMotion;
 71 WebKit::WebDeviceMotionDetectorClient* m_client;
 72 bool m_isUpdating;
 73
 74 // Queue of tasks to be run.
 75 Vector<OwnPtr<Task> > m_taskQueue;
 76 bool m_taskQueueRunning;
 77
 78 // Task for stepping the queue.
 79 class StepTask : public MethodTask<MockWebDeviceMotionDetector> {
 80 public:
 81 StepTask(MockWebDeviceMotionDetector* object) : MethodTask<MockWebDeviceMotionDetector>(object) { }
 82 virtual void runIfValid() OVERRIDE;
 83 };
 84};
 85
 86#endif // MockWebDeviceMotionDetector_h

Tools/DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp

@@MockWebKitPlatformSupport::~MockWebKitPlatformSupport()
5050{
5151}
5252
 53WebKit::WebDeviceMotionDetector* MockWebKitPlatformSupport::deviceMotionDetector()
 54{
 55 return mockDeviceMotionDetector();
 56}
 57
5358void MockWebKitPlatformSupport::cryptographicallyRandomValues(unsigned char*, size_t)
5459{
5560 CRASH();

@@WebMediaStreamCenter* MockWebKitPlatformSupport::createMediaStreamCenter(WebMedi
6368
6469 return m_mockMediaStreamCenter.get();
6570}
 71
 72MockWebDeviceMotionDetector* MockWebKitPlatformSupport::mockDeviceMotionDetector()
 73{
 74 if (!m_mockDeviceMotionDetector)
 75 m_mockDeviceMotionDetector = MockWebDeviceMotionDetector::create();
 76 return m_mockDeviceMotionDetector.get();
 77}
6678#endif // ENABLE(MEDIA_STREAM)

Tools/DumpRenderTree/chromium/MockWebKitPlatformSupport.h

3131#ifndef MockWebKitPlatformSupport_h
3232#define MockWebKitPlatformSupport_h
3333
 34#include "MockWebDeviceMotionDetector.h"
3435#include <public/Platform.h>
3536#include <wtf/OwnPtr.h>
3637#include <wtf/PassOwnPtr.h>

@@public:
4041 static PassOwnPtr<MockWebKitPlatformSupport> create();
4142 ~MockWebKitPlatformSupport();
4243
 44 // Implements WebKit::Platform.
 45 virtual WebKit::WebDeviceMotionDetector* deviceMotionDetector() OVERRIDE;
4346 virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) OVERRIDE;
4447
4548#if ENABLE(MEDIA_STREAM)
4649 virtual WebKit::WebMediaStreamCenter* createMediaStreamCenter(WebKit::WebMediaStreamCenterClient*) OVERRIDE;
4750#endif // ENABLE(MEDIA_STREAM)
4851
 52 MockWebDeviceMotionDetector* mockDeviceMotionDetector();
 53
4954private:
5055 MockWebKitPlatformSupport();
5156
 57 OwnPtr<MockWebDeviceMotionDetector> m_mockDeviceMotionDetector;
5258#if ENABLE(MEDIA_STREAM)
5359 OwnPtr<WebKit::WebMediaStreamCenter> m_mockMediaStreamCenter;
5460#endif // ENABLE(MEDIA_STREAM)

Tools/DumpRenderTree/chromium/TestShell.h

@@class WebURL;
5858class DRTDevToolsAgent;
5959class DRTDevToolsCallArgs;
6060class DRTDevToolsClient;
 61class MockWebDeviceMotionDetector;
6162class MockWebPrerenderingSupport;
6263class WebPermissions;
6364

@@public:
126127 // the test results.
127128 void testTimedOut();
128129
 130 MockWebDeviceMotionDetector* deviceMotionDetectorMock() const { return m_motionDetector; }
 131 void setMockDeviceMotionDetector(MockWebDeviceMotionDetector* detector) { m_motionDetector = detector; }
129132 bool allowExternalPages() const { return m_allowExternalPages; }
130133 void setAllowExternalPages(bool allowExternalPages) { m_allowExternalPages = allowExternalPages; }
131134

@@private:
224227 TestParams m_params;
225228 bool m_dumpPixelsForCurrentTest;
226229 int m_timeout; // timeout value in millisecond
 230 MockWebDeviceMotionDetector* m_motionDetector; // weak pointer
227231 bool m_allowExternalPages;
228232 bool m_acceleratedCompositingForVideoEnabled;
229233 bool m_threadedCompositingEnabled;

LayoutTests/ChangeLog

 12012-08-16 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Adds seven new tests for DeviceMotion.
 9 Each test corresponds to a similar existing test for DeviceOrientation, since they are part of the same spec and work very similarly.
 10
 11 * fast/dom/DeviceMotion/add-listener-from-callback-expected.txt: Added.
 12 * fast/dom/DeviceMotion/add-listener-from-callback.html: Added.
 13 * fast/dom/DeviceMotion/basic-operation-expected.txt: Added.
 14 * fast/dom/DeviceMotion/basic-operation.html: Added.
 15 * fast/dom/DeviceMotion/event-after-navigation-expected.txt: Added.
 16 * fast/dom/DeviceMotion/event-after-navigation.html: Added.
 17 * fast/dom/DeviceMotion/multiple-frames-expected.txt: Added.
 18 * fast/dom/DeviceMotion/multiple-frames.html: Added.
 19 * fast/dom/DeviceMotion/no-synchronous-events-expected.txt: Added.
 20 * fast/dom/DeviceMotion/no-synchronous-events.html: Added.
 21 * fast/dom/DeviceMotion/null-values-expected.txt: Added.
 22 * fast/dom/DeviceMotion/null-values.html: Added.
 23 * fast/dom/DeviceMotion/resources/event-after-navigation-new.html: Added.
 24 * fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js: Added.
 25 (checkMotion):
 26 (firstListener):
 27 (secondListener):
 28 (maybeFinishTest):
 29 * fast/dom/DeviceMotion/script-tests/basic-operation.js: Added.
 30 * fast/dom/DeviceMotion/script-tests/event-after-navigation.js: Added.
 31 * fast/dom/DeviceMotion/script-tests/multiple-frames.js: Added.
 32 (checkMotion):
 33 (mainFrameListener):
 34 (childFrameListener):
 35 (maybeFinishTest):
 36 * fast/dom/DeviceMotion/script-tests/no-synchronous-events.js: Added.
 37 * fast/dom/DeviceMotion/script-tests/null-values.js: Added.
 38 (setMockMotion):
 39 (checkMotion):
 40 (firstListener):
 41 (secondListener):
 42 (thirdListener):
 43 (fourthListener):
 44 (fifthListener):
 45 (sixthListener):
 46 (seventhListener):
 47 (eighthListener):
 48 (ninthListener):
 49 (tenthListener):
 50 (eleventhListener):
 51 * fast/dom/DeviceMotion/script-tests/updates.js: Added.
 52 (setMockMotion):
 53 (checkMotion):
 54 (firstListener):
 55 (updateListener):
 56 * fast/dom/DeviceMotion/updates-expected.txt: Added.
 57 * fast/dom/DeviceMotion/updates.html: Added.
 58
1592012-08-16 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
260
361 [EFL] Gardening after r125592, r125635

LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback-expected.txt

 1Tests that adding a new event listener from a callback works as expected.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 7PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 8PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 15PASS deviceMotionEvent.interval is mockInterval
 16PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 17PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 18PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 25PASS deviceMotionEvent.interval is mockInterval
 26PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 27PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 28PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 29PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 30PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 31PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 32PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 33PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 34PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 35PASS deviceMotionEvent.interval is mockInterval
 36PASS successfullyParsed is true
 37
 38TEST COMPLETE
 39

LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/add-listener-from-callback.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/basic-operation-expected.txt

 1Tests the basic operation of DeviceMotion using the mock.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 7PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 8PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 15PASS deviceMotionEvent.interval is mockInterval
 16PASS successfullyParsed is true
 17
 18TEST COMPLETE
 19

LayoutTests/fast/dom/DeviceMotion/basic-operation.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/basic-operation.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/event-after-navigation-expected.txt

 1Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.
 2
 3SUCCESS

LayoutTests/fast/dom/DeviceMotion/event-after-navigation.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/event-after-navigation.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/multiple-frames-expected.txt

 1Tests using DeviceMotion from multiple frames.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 7PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 8PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 15PASS deviceMotionEvent.interval is mockEvent.interval
 16PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 17PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 18PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 25PASS deviceMotionEvent.interval is mockEvent.interval
 26PASS successfullyParsed is true
 27
 28TEST COMPLETE
 29

LayoutTests/fast/dom/DeviceMotion/multiple-frames.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/multiple-frames.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/no-synchronous-events-expected.txt

 1Tests that events are never fired synchronously from a call to window.addEventListener().
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS hasAddEventListenerReturned is true
 7PASS successfullyParsed is true
 8
 9TEST COMPLETE
 10

LayoutTests/fast/dom/DeviceMotion/no-synchronous-events.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/no-synchronous-events.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/null-values-expected.txt

 1Tests using null values for some of the event properties.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 7PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 8PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 9PASS deviceMotionEvent.interval is mockEvent.interval
 10PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 11PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 12PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 13PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 14PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 15PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 16PASS deviceMotionEvent.interval is mockEvent.interval
 17PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 18PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 19PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 20PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 21PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 22PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 23PASS deviceMotionEvent.interval is mockEvent.interval
 24PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 25PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 26PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 27PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 28PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 29PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 30PASS deviceMotionEvent.interval is mockEvent.interval
 31PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 32PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 33PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 34PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 35PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 36PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 37PASS deviceMotionEvent.interval is mockEvent.interval
 38PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 39PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 40PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 41PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 42PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 43PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 44PASS deviceMotionEvent.interval is mockEvent.interval
 45PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 46PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 47PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 48PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 49PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 50PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 51PASS deviceMotionEvent.interval is mockEvent.interval
 52PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 53PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 54PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 55PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 56PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 57PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 58PASS deviceMotionEvent.interval is mockEvent.interval
 59PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 60PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 61PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 62PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 63PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 64PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 65PASS deviceMotionEvent.interval is mockEvent.interval
 66PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 67PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 68PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 69PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 70PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 71PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 72PASS deviceMotionEvent.interval is mockEvent.interval
 73PASS !deviceMotionEvent.acceleration is !mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ
 74PASS !deviceMotionEvent.accelerationIncludingGravity is !mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ
 75PASS !deviceMotionEvent.rotationRate is !mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma
 76PASS deviceMotionEvent.interval is mockEvent.interval
 77PASS successfullyParsed is true
 78
 79TEST COMPLETE
 80

LayoutTests/fast/dom/DeviceMotion/null-values.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/null-values.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/resources/event-after-navigation-new.html

 1<html>
 2 <head>
 3 </head>
 4 <body>
 5 Tests for a crash where an event is fired after the page has been navigated
 6 away when the original page is in the page cache.<br><br>
 7 SUCCESS
 8 <script>
 9 if (window.testRunner) {
 10 testRunner.setMockDeviceMotion(true, 1.01, true, 2.02, true, 3.03, true, 4.04, true, 5.05, true, 6.06, true, 7.07, true, 8.08, true, 9.09, true, 10.10);
 11 testRunner.notifyDone();
 12 }
 13 </script>
 14 </body>
 15</html>

LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js

 1description('Tests that adding a new event listener from a callback works as expected.');
 2
 3var mockAccelerationX = 1.01;
 4var mockAccelerationY = 2.02;
 5var mockAccelerationZ = 3.03;
 6
 7var mockAccelerationIncludingGravityX = 4.04;
 8var mockAccelerationIncludingGravityY = 5.05;
 9var mockAccelerationIncludingGravityZ = 6.06;
 10
 11var mockRotationRateAlpha = 7.07;
 12var mockRotationRateBeta = 8.08;
 13var mockRotationRateGamma = 9.09;
 14
 15var mockInterval = 10.10;
 16
 17if (window.testRunner) {
 18 testRunner.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ, true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ, true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma, true, mockInterval);
 19} else
 20 debug('This test can not be run without the TestRunner');
 21
 22var deviceMotionEvent;
 23function checkMotion(event) {
 24 deviceMotionEvent = event;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockInterval');
 35}
 36
 37var firstListenerEvents = 0;
 38function firstListener(event) {
 39 checkMotion(event);
 40 if (++firstListenerEvents == 1)
 41 window.addEventListener('devicemotion', secondListener);
 42 else if (firstListenerEvents > 2)
 43 testFailed('Too many events for first listener.');
 44 maybeFinishTest();
 45}
 46
 47var secondListenerEvents = 0;
 48function secondListener(event) {
 49 checkMotion(event);
 50 if (++secondListenerEvents > 1)
 51 testFailed('Too many events for second listener.');
 52 maybeFinishTest();
 53}
 54
 55function maybeFinishTest() {
 56 if (firstListenerEvents == 2 && secondListenerEvents == 1)
 57 finishJSTest();
 58}
 59
 60window.addEventListener('devicemotion', firstListener);
 61
 62window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/basic-operation.js

 1description('Tests the basic operation of DeviceMotion using the mock.');
 2
 3var mockAccelerationX = 1.01;
 4var mockAccelerationY = 2.02;
 5var mockAccelerationZ = 3.03;
 6
 7var mockAccelerationIncludingGravityX = 4.04;
 8var mockAccelerationIncludingGravityY = 5.05;
 9var mockAccelerationIncludingGravityZ = 6.06;
 10
 11var mockRotationRateAlpha = 7.07;
 12var mockRotationRateBeta = 8.08;
 13var mockRotationRateGamma = 9.09;
 14
 15var mockInterval = 10.10;
 16
 17if (window.testRunner) {
 18 testRunner.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ, true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ, true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma, true, mockInterval);
 19} else
 20 debug('This test can not be run without the TestRunner');
 21
 22var deviceMotionEvent;
 23window.addEventListener('devicemotion', function(e) {
 24 deviceMotionEvent = e;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockInterval');
 35 finishJSTest();
 36});
 37
 38window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/event-after-navigation.js

 1description('Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.');
 2
 3if (window.testRunner)
 4 testRunner.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
 5else
 6 debug('This test can not be run without the TestRunner');
 7
 8document.body.onload = function() {
 9 window.addEventListener('devicemotion', function() { } );
 10 window.location = "resources/event-after-navigation-new.html";
 11}
 12
 13window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/multiple-frames.js

 1description('Tests using DeviceMotion from multiple frames.');
 2
 3var deviceMotionEvent;
 4function checkMotion(event) {
 5 deviceMotionEvent = event;
 6 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
 7 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
 8 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
 9 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
 10 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
 11 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
 12 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
 13 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
 14 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
 15 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
 16}
 17
 18var hasMainFrameEventFired = false;
 19function mainFrameListener(event) {
 20 checkMotion(event);
 21 hasMainFrameEventFired = true;
 22 maybeFinishTest();
 23}
 24
 25var hasChildFrameEventFired = false;
 26function childFrameListener(event) {
 27 checkMotion(event);
 28 hasChildFrameEventFired = true;
 29 maybeFinishTest();
 30}
 31
 32function maybeFinishTest() {
 33 if (hasMainFrameEventFired && hasChildFrameEventFired)
 34 finishJSTest();
 35}
 36
 37var mockEvent = {accelerationX: 1.01, accelerationY: 2.02, accelerationZ: 3.03, accelerationIncludingGravityX: 4.04, accelerationIncludingGravityY: 5.05, accelerationIncludingGravityZ: 6.06, rotationRateAlpha: 7.07, rotationRateBeta: 8.08, rotationRateGamma: 9.09, interval: 10.10};
 38if (window.testRunner)
 39 testRunner.setMockDeviceMotion(true, mockEvent.accelerationX, true, mockEvent.accelerationY, true, mockEvent.accelerationZ, true, mockEvent.accelerationIncludingGravityX, true, mockEvent.accelerationIncludingGravityY, true, mockEvent.accelerationIncludingGravityZ, true, mockEvent.rotationRateAlpha, true, mockEvent.rotationRateBeta, true, mockEvent.rotationRateGamma, true, mockEvent.interval);
 40else
 41 debug('This test can not be run without the TestRunner');
 42
 43var childFrame = document.createElement('iframe');
 44document.body.appendChild(childFrame);
 45childFrame.contentWindow.addEventListener('devicemotion', childFrameListener);
 46
 47window.addEventListener('devicemotion', mainFrameListener);
 48
 49window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/no-synchronous-events.js

 1description('Tests that events are never fired synchronously from a call to window.addEventListener().');
 2
 3if (window.testRunner)
 4 testRunner.setMockDeviceMotion(true, 1.01, true, 2.02, true, 3.03, true, 4.04, true, 5.05, true, 6.06, true, 7.07, true, 8.08, true, 9.09, true, 10.10, true);
 5else
 6 debug('This test can not be run without the TestRunner');
 7
 8var hasAddEventListenerReturned = false;
 9window.addEventListener('devicemotion', function() {
 10 shouldBeTrue('hasAddEventListenerReturned');
 11 finishJSTest();
 12});
 13hasAddEventListenerReturned = true;
 14
 15window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/null-values.js

 1description('Tests using null values for some of the event properties.');
 2
 3var mockEvent;
 4function setMockMotion(accelerationX, accelerationY, accelerationZ, accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ, rotationRateAlpha, rotationRateBeta, rotationRateGamma, interval) {
 5 mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ, accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ, rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma, interval: interval};
 6 if (window.testRunner)
 7 testRunner.setMockDeviceMotion(
 8 null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX,
 9 null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY,
 10 null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ,
 11 null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX,
 12 null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY,
 13 null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ,
 14 null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha,
 15 null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta,
 16 null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma,
 17 null != mockEvent.interval, null == mockEvent.interval ? 0 : mockEvent.interval);
 18 else
 19 debug('This test can not be run without the TestRunner');
 20}
 21
 22var deviceMotionEvent;
 23function checkMotion(event) {
 24 deviceMotionEvent = event;
 25 shouldBe('!deviceMotionEvent.acceleration', '!mockEvent.accelerationX && !mockEvent.accelerationY && !mockEvent.accelerationZ');
 26 if (deviceMotionEvent.acceleration) {
 27 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
 28 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
 29 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
 30 }
 31 shouldBe('!deviceMotionEvent.accelerationIncludingGravity', '!mockEvent.accelerationIncludingGravityX && !mockEvent.accelerationIncludingGravityY && !mockEvent.accelerationIncludingGravityZ');
 32 if (deviceMotionEvent.accelerationIncludingGravity) {
 33 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
 34 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
 35 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
 36 }
 37 shouldBe('!deviceMotionEvent.rotationRate', '!mockEvent.rotationRateAlpha && !mockEvent.rotationRateBeta && !mockEvent.rotationRateGamma');
 38 if (deviceMotionEvent.rotationRate) {
 39 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
 40 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
 41 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
 42 }
 43 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
 44}
 45
 46function firstListener(event) {
 47 checkMotion(event);
 48 window.removeEventListener('devicemotion', firstListener);
 49
 50 setMockMotion(1.01, null, null, null, null, null, null, null, null, null);
 51 window.addEventListener('devicemotion', secondListener);
 52}
 53
 54function secondListener(event) {
 55 checkMotion(event);
 56 window.removeEventListener('devicemotion', secondListener);
 57
 58 setMockMotion(null, 2.02, null, null, null, null, null, null, null, null);
 59 window.addEventListener('devicemotion', thirdListener);
 60}
 61
 62function thirdListener(event) {
 63 checkMotion(event);
 64 window.removeEventListener('devicemotion', thirdListener);
 65
 66 setMockMotion(null, null, 3.03, null, null, null, null, null, null, null);
 67 window.addEventListener('devicemotion', fourthListener);
 68}
 69
 70function fourthListener(event) {
 71 checkMotion(event);
 72 window.removeEventListener('devicemotion', fourthListener);
 73
 74 setMockMotion(null, null, null, 4.04, null, null, null, null, null, null);
 75 window.addEventListener('devicemotion', fifthListener);
 76}
 77
 78function fifthListener(event) {
 79 checkMotion(event);
 80 window.removeEventListener('devicemotion', fifthListener);
 81
 82 setMockMotion(null, null, null, null, 5.05, null, null, null, null, null);
 83 window.addEventListener('devicemotion', sixthListener);
 84}
 85
 86function sixthListener(event) {
 87 checkMotion(event);
 88 window.removeEventListener('devicemotion', sixthListener);
 89
 90 setMockMotion(null, null, null, null, null, 6.06, null, null, null, null);
 91 window.addEventListener('devicemotion', seventhListener);
 92}
 93
 94function seventhListener(event) {
 95 checkMotion(event);
 96 window.removeEventListener('devicemotion', seventhListener);
 97
 98 setMockMotion(null, null, null, null, null, null, 7.07, null, null, null);
 99 window.addEventListener('devicemotion', eighthListener);
 100}
 101
 102function eighthListener(event) {
 103 checkMotion(event);
 104 window.removeEventListener('devicemotion', eighthListener);
 105
 106 setMockMotion(null, null, null, null, null, null, null, 8.08, null, null);
 107 window.addEventListener('devicemotion', ninthListener);
 108}
 109
 110function ninthListener(event) {
 111 checkMotion(event);
 112 window.removeEventListener('devicemotion', ninthListener);
 113
 114 setMockMotion(null, null, null, null, null, null, null, null, 9.09, null);
 115 window.addEventListener('devicemotion', tenthListener);
 116}
 117
 118function tenthListener(event) {
 119 checkMotion(event);
 120 window.removeEventListener('devicemotion', tenthListener);
 121
 122 setMockMotion(null, null, null, null, null, null, null, null, null, 10.10);
 123 window.addEventListener('devicemotion', eleventhListener);
 124}
 125
 126function eleventhListener(event) {
 127 checkMotion(event);
 128 finishJSTest();
 129}
 130
 131setMockMotion(null, null, null, null, null, null, null, null, null, null);
 132window.addEventListener('devicemotion', firstListener);
 133
 134window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/updates.js

 1description('Tests that updates to the motion causes new events to fire.');
 2
 3var mockEvent;
 4function setMockMotion(accelerationX, accelerationY, accelerationZ, accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ, rotationRateAlpha, rotationRateBeta, rotationRateGamma, interval) {
 5 mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ, accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ, rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma, interval: interval};
 6 if (window.testRunner)
 7 testRunner.setMockDeviceMotion(
 8 null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX,
 9 null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY,
 10 null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ,
 11 null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX,
 12 null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY,
 13 null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ,
 14 null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha,
 15 null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta,
 16 null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma,
 17 null != mockEvent.interval, null == mockEvent.interval ? 0 : mockEvent.interval);
 18 else
 19 debug('This test can not be run without the TestRunner');
 20}
 21
 22var deviceMotionEvent;
 23function checkMotion(event) {
 24 deviceMotionEvent = event;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
 35}
 36
 37function firstListener(event) {
 38 checkMotion(event);
 39 window.removeEventListener('devicemotion', firstListener);
 40
 41 setMockMotion(11.01, 22.02, 33.03, 44.04, 55.05, 66.06, 77.07, 88.08, 99.09, 110.10);
 42 window.addEventListener('devicemotion', updateListener);
 43}
 44
 45function updateListener(event) {
 46 checkMotion(event);
 47 finishJSTest();
 48}
 49
 50setMockMotion(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10);
 51window.addEventListener('devicemotion', firstListener);
 52
 53window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/updates-expected.txt

 1Tests that updates to the motion causes new events to fire.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 7PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 8PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 15PASS deviceMotionEvent.interval is mockEvent.interval
 16PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 17PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 18PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 25PASS deviceMotionEvent.interval is mockEvent.interval
 26PASS successfullyParsed is true
 27
 28TEST COMPLETE
 29

LayoutTests/fast/dom/DeviceMotion/updates.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/updates.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>