OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import org.chromium.base.ActivityStatus; | 7 import org.chromium.base.ActivityStatus; |
8 import org.chromium.base.test.util.Feature; | 8 import org.chromium.base.test.util.Feature; |
9 import org.chromium.content.app.LibraryLoader; | 9 import org.chromium.content.app.LibraryLoader; |
10 import org.chromium.content.common.CommandLine; | 10 import org.chromium.content.common.CommandLine; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 assertTrue(start); | 51 assertTrue(start); |
52 assertTrue("should contain all motion sensors", | 52 assertTrue("should contain all motion sensors", |
53 mDeviceMotionAndOrientation.mActiveSensors.containsAll( | 53 mDeviceMotionAndOrientation.mActiveSensors.containsAll( |
54 DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS)); | 54 DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS)); |
55 assertTrue(mDeviceMotionAndOrientation.mDeviceMotionIsActive); | 55 assertTrue(mDeviceMotionAndOrientation.mDeviceMotionIsActive); |
56 assertFalse(mDeviceMotionAndOrientation.mDeviceOrientationIsActive); | 56 assertFalse(mDeviceMotionAndOrientation.mDeviceOrientationIsActive); |
57 | 57 |
58 assertEquals(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS.size(), | 58 assertEquals(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS.size(), |
59 mMockSensorManager.numRegistered); | 59 mMockSensorManager.numRegistered); |
60 assertEquals(0, mMockSensorManager.numUnRegistered); | 60 assertEquals(0, mMockSensorManager.numUnRegistered); |
| 61 assertEquals(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS.size(), |
| 62 mDeviceMotionAndOrientation.getNumberActiveDeviceMotionSensors()
); |
61 } | 63 } |
62 | 64 |
63 @SmallTest | 65 @SmallTest |
64 public void testRegisterSensorsDeviceOrientation() { | 66 public void testRegisterSensorsDeviceOrientation() { |
65 boolean start = mDeviceMotionAndOrientation.start(0, | 67 boolean start = mDeviceMotionAndOrientation.start(0, |
66 DeviceMotionAndOrientation.DEVICE_ORIENTATION, 100); | 68 DeviceMotionAndOrientation.DEVICE_ORIENTATION, 100); |
67 | 69 |
68 assertTrue(start); | 70 assertTrue(start); |
69 assertTrue("should contain all orientation sensors", | 71 assertTrue("should contain all orientation sensors", |
70 mDeviceMotionAndOrientation.mActiveSensors.containsAll( | 72 mDeviceMotionAndOrientation.mActiveSensors.containsAll( |
(...skipping 23 matching lines...) Expand all Loading... |
94 DeviceMotionAndOrientation.DEVICE_ORIENTATION_SENSORS)); | 96 DeviceMotionAndOrientation.DEVICE_ORIENTATION_SENSORS)); |
95 | 97 |
96 Set<Integer> union = Sets.newHashSet(DeviceMotionAndOrientation.DEVICE_O
RIENTATION_SENSORS); | 98 Set<Integer> union = Sets.newHashSet(DeviceMotionAndOrientation.DEVICE_O
RIENTATION_SENSORS); |
97 union.addAll(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS); | 99 union.addAll(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS); |
98 | 100 |
99 assertEquals(union.size(), mDeviceMotionAndOrientation.mActiveSensors.si
ze()); | 101 assertEquals(union.size(), mDeviceMotionAndOrientation.mActiveSensors.si
ze()); |
100 assertTrue(mDeviceMotionAndOrientation.mDeviceMotionIsActive); | 102 assertTrue(mDeviceMotionAndOrientation.mDeviceMotionIsActive); |
101 assertTrue(mDeviceMotionAndOrientation.mDeviceOrientationIsActive); | 103 assertTrue(mDeviceMotionAndOrientation.mDeviceOrientationIsActive); |
102 assertEquals(union.size(), mMockSensorManager.numRegistered); | 104 assertEquals(union.size(), mMockSensorManager.numRegistered); |
103 assertEquals(0, mMockSensorManager.numUnRegistered); | 105 assertEquals(0, mMockSensorManager.numUnRegistered); |
| 106 assertEquals(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS.size(), |
| 107 mDeviceMotionAndOrientation.getNumberActiveDeviceMotionSensors()
); |
104 } | 108 } |
105 | 109 |
106 @SmallTest | 110 @SmallTest |
107 public void testUnregisterSensorsDeviceMotion() { | 111 public void testUnregisterSensorsDeviceMotion() { |
108 mDeviceMotionAndOrientation.start(0, DeviceMotionAndOrientation.DEVICE_M
OTION, 100); | 112 mDeviceMotionAndOrientation.start(0, DeviceMotionAndOrientation.DEVICE_M
OTION, 100); |
109 mDeviceMotionAndOrientation.stop(DeviceMotionAndOrientation.DEVICE_MOTIO
N); | 113 mDeviceMotionAndOrientation.stop(DeviceMotionAndOrientation.DEVICE_MOTIO
N); |
110 | 114 |
111 assertTrue("should contain no sensors", | 115 assertTrue("should contain no sensors", |
112 mDeviceMotionAndOrientation.mActiveSensors.isEmpty()); | 116 mDeviceMotionAndOrientation.mActiveSensors.isEmpty()); |
113 assertFalse(mDeviceMotionAndOrientation.mDeviceMotionIsActive); | 117 assertFalse(mDeviceMotionAndOrientation.mDeviceMotionIsActive); |
114 assertFalse(mDeviceMotionAndOrientation.mDeviceOrientationIsActive); | 118 assertFalse(mDeviceMotionAndOrientation.mDeviceOrientationIsActive); |
115 assertEquals(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS.size(), | 119 assertEquals(DeviceMotionAndOrientation.DEVICE_MOTION_SENSORS.size(), |
116 mMockSensorManager.numUnRegistered); | 120 mMockSensorManager.numUnRegistered); |
| 121 assertEquals(0, mDeviceMotionAndOrientation.getNumberActiveDeviceMotionS
ensors()); |
117 } | 122 } |
118 | 123 |
119 @SmallTest | 124 @SmallTest |
120 public void testUnregisterSensorsDeviceOrientation() { | 125 public void testUnregisterSensorsDeviceOrientation() { |
121 mDeviceMotionAndOrientation.start(0, DeviceMotionAndOrientation.DEVICE_O
RIENTATION, 100); | 126 mDeviceMotionAndOrientation.start(0, DeviceMotionAndOrientation.DEVICE_O
RIENTATION, 100); |
122 mDeviceMotionAndOrientation.stop(DeviceMotionAndOrientation.DEVICE_ORIEN
TATION); | 127 mDeviceMotionAndOrientation.stop(DeviceMotionAndOrientation.DEVICE_ORIEN
TATION); |
123 | 128 |
124 assertTrue("should contain no sensors", | 129 assertTrue("should contain no sensors", |
125 mDeviceMotionAndOrientation.mActiveSensors.isEmpty()); | 130 mDeviceMotionAndOrientation.mActiveSensors.isEmpty()); |
126 assertFalse(mDeviceMotionAndOrientation.mDeviceMotionIsActive); | 131 assertFalse(mDeviceMotionAndOrientation.mDeviceMotionIsActive); |
(...skipping 16 matching lines...) Expand all Loading... |
143 diff.removeAll(DeviceMotionAndOrientation.DEVICE_ORIENTATION_SENSORS); | 148 diff.removeAll(DeviceMotionAndOrientation.DEVICE_ORIENTATION_SENSORS); |
144 | 149 |
145 assertEquals(diff.size(), mMockSensorManager.numUnRegistered); | 150 assertEquals(diff.size(), mMockSensorManager.numUnRegistered); |
146 | 151 |
147 mDeviceMotionAndOrientation.stop(DeviceMotionAndOrientation.DEVICE_ORIEN
TATION); | 152 mDeviceMotionAndOrientation.stop(DeviceMotionAndOrientation.DEVICE_ORIEN
TATION); |
148 | 153 |
149 assertTrue("should contain no sensors", | 154 assertTrue("should contain no sensors", |
150 mDeviceMotionAndOrientation.mActiveSensors.isEmpty()); | 155 mDeviceMotionAndOrientation.mActiveSensors.isEmpty()); |
151 assertEquals(diff.size() + DeviceMotionAndOrientation.DEVICE_ORIENTATION
_SENSORS.size(), | 156 assertEquals(diff.size() + DeviceMotionAndOrientation.DEVICE_ORIENTATION
_SENSORS.size(), |
152 mMockSensorManager.numUnRegistered); | 157 mMockSensorManager.numUnRegistered); |
| 158 assertEquals(0, mDeviceMotionAndOrientation.getNumberActiveDeviceMotionS
ensors()); |
153 } | 159 } |
154 | 160 |
155 @SmallTest | 161 @SmallTest |
156 public void testSensorChangedgotAccelerationAndOrientation() { | 162 public void testSensorChangedgotAccelerationAndOrientation() { |
157 boolean startOrientation = mDeviceMotionAndOrientation.start(0, | 163 boolean startOrientation = mDeviceMotionAndOrientation.start(0, |
158 DeviceMotionAndOrientation.DEVICE_ORIENTATION, 100); | 164 DeviceMotionAndOrientation.DEVICE_ORIENTATION, 100); |
159 boolean startMotion = mDeviceMotionAndOrientation.start(0, | 165 boolean startMotion = mDeviceMotionAndOrientation.start(0, |
160 DeviceMotionAndOrientation.DEVICE_MOTION, 100); | 166 DeviceMotionAndOrientation.DEVICE_MOTION, 100); |
161 | 167 |
162 assertTrue(startOrientation); | 168 assertTrue(startOrientation); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 numRegistered++; | 296 numRegistered++; |
291 return true; | 297 return true; |
292 } | 298 } |
293 | 299 |
294 @Override | 300 @Override |
295 public void unregisterListener(SensorEventListener listener, int sensorT
ype) { | 301 public void unregisterListener(SensorEventListener listener, int sensorT
ype) { |
296 numUnRegistered++; | 302 numUnRegistered++; |
297 } | 303 } |
298 } | 304 } |
299 } | 305 } |
OLD | NEW |