Skip to content

Commit

Permalink
Save bluetooth state to user pref in settings page
Browse files Browse the repository at this point in the history
Note: This is a reland of http://crrev.com/6e30800 with the fix for the
test breakage.

BUG=741962
TBR=sonnysasaka@chromium.org

(cherry picked from commit 1acacb7)

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Iec33e451a6068bf03a6871570c4b2c66919887af
Reviewed-on: https://chromium-review.googlesource.com/651268
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#499798}
Reviewed-on: https://chromium-review.googlesource.com/663790
Reviewed-by: Jacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/branch-heads/3202@{crosswalk-project#182}
Cr-Branched-From: fa6a5d8-refs/heads/master@{#499098}
  • Loading branch information
jacobdufault-google authored and Jacob Dufault committed Sep 12, 2017
1 parent bb7bd71 commit 7250b35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../icons.html">
<link rel="import" href="../prefs/prefs.html">
<link rel="import" href="../prefs/prefs_behavior.html">
<link rel="import" href="../settings_page/settings_animated_pages.html">
<link rel="import" href="../settings_page/settings_subpage.html">
<link rel="import" href="../settings_shared_css.html">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var bluetoothApis = bluetoothApis || {
Polymer({
is: 'settings-bluetooth-page',

behaviors: [PrefsBehavior],

properties: {
/** Preferences state. */
prefs: {
Expand Down Expand Up @@ -166,6 +168,7 @@ Polymer({
this.adapterState_ = state;
this.bluetoothToggleState_ = state.powered;
this.bluetoothToggleDisabled_ = !state.available;
this.setPrefValue('ash.user.bluetooth.adapter_enabled', state.powered);
},

/** @private */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'target_name': 'bluetooth_page',
'dependencies': [
'../compiled_resources2.gyp:route',
'../prefs/compiled_resources2.gyp:prefs_behavior',
'../settings_page/compiled_resources2.gyp:settings_animated_pages',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
Expand Down
17 changes: 17 additions & 0 deletions chrome/test/data/webui/settings/bluetooth_page_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

function getFakePrefs() {
return {
ash: {
user: {
bluetooth: {
adapter_enabled: {
key: 'ash.user.bluetooth.adapter_enabled',
type: chrome.settingsPrivate.PrefType.BOOLEAN,
value: false,
}
}
}
}
};
}

suite('Bluetooth', function() {
var bluetoothPage = null;

Expand Down Expand Up @@ -60,6 +76,7 @@ suite('Bluetooth', function() {
setup(function() {
PolymerTest.clearBody();
bluetoothPage = document.createElement('settings-bluetooth-page');
bluetoothPage.prefs = getFakePrefs();
assertTrue(!!bluetoothPage);

bluetoothApi_.setDevicesForTest([]);
Expand Down

0 comments on commit 7250b35

Please sign in to comment.