Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1142254 - close turn bluetooth on confirmation dialog while bluet…
Browse files Browse the repository at this point in the history
…ooth state is off to on, r=arthur
  • Loading branch information
ian-liu authored and rvandermeulen committed Mar 19, 2015
1 parent 3684a82 commit 57a208c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/bluetooth/js/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ navigator.mozL10n.once(function showPanel() {
activity.source.name == 'share-via-bluetooth-only') &&
(activity.source.data.blobs &&
activity.source.data.blobs.length > 0)) {
observeOnadapteradded();
observeBluetoothEnabled();
isBluetoothEnabled();
} else {
Expand All @@ -45,6 +46,12 @@ navigator.mozL10n.once(function showPanel() {
console.log('[Bluetooth APP Send File]: ' + msg);
}

function observeOnadapteradded() {
bluetooth.onadapteradded = function bt_adapterAdded() {
initialDefaultAdapter();
};
}

function observeBluetoothEnabled() {
// enable Bluetooth if the related settings says so
// register an observer to monitor bluetooth.enabled changes
Expand All @@ -68,6 +75,8 @@ navigator.mozL10n.once(function showPanel() {
debug(msg);
confirmTurnBluetoothOn();
}
} else {
dialogConfirmBluetooth.hidden = true;
}
});
}
Expand Down Expand Up @@ -100,9 +109,6 @@ navigator.mozL10n.once(function showPanel() {
}

dialogConfirmBluetooth.hidden = true;
bluetooth.onadapteradded = function bt_adapterAdded() {
initialDefaultAdapter();
};
settings.createLock().set({'bluetooth.enabled': true});
}

Expand Down
7 changes: 7 additions & 0 deletions apps/bluetooth/test/unit/transfer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,12 @@ suite('Bluetooth app > transfer ', function() {
{settingValue: false});
assert.isFalse(dialogConfirmBluetooth.hidden);
});

test('confirme dialog is closed after Bluetooth is enabled', function() {
dialogConfirmBluetooth.hidden = false;
MockNavigatorSettings.mTriggerObservers(bluetoothKey,
{settingValue: true});
assert.isTrue(dialogConfirmBluetooth.hidden);
});
});
});

0 comments on commit 57a208c

Please sign in to comment.