Project: titanium
Issue TIMOB-12233: BlackBerry: Implement important Titanium.Accelerometer functionality
h3. Acceptance Test {code} var win = Ti.UI.createWindow({ layout: 'vertical' }); var enableAccelerometer = Ti.UI.createButton({ title: 'Toggle Accelerometer' }); win.add(enableAccelerometer); var labels = ['x', 'y', 'z'].map(function(coord) { var label = Ti.UI.createLabel({text: coord + ': N/A'}); win.add(label); return label; }); function onUpdate(e) { labels[0].text = e.x; labels[1].text = e.y; labels[2].text = e.z; } var accelerometerEnabled = false; enableAccelerometer.addEventListener('click', function() { accelerometerEnabled ? Ti.Accelerometer.removeEventListener('update', onUpdate) : Ti.Accelerometer.addEventListener('update', onUpdate); accelerometerEnabled = !accelerometerEnabled; }); win.open(); {code} # Try moving the device around. No updates should be displayed. # Click "Toggle Accelerometer". Move device and you should now see updates (x, y, z values). # Click the toggle button again and the updates should stop. Repeat and verify.
Story points: 15