dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_getters.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=2 sts=2 et filetype=javascript
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 ///////////////////////////////////////////////////////////////////////////////
     8 // Test Purpose:
     9 //   To verify that the properties of BluetoothAdapter can be updated and
    10 //   retrieved correctly. Use B2G emulator commands to set properties for this
    11 //   test case.
    12 //
    13 // Test Coverage:
    14 //   - BluetoothAdapter.name
    15 //   - BluetoothAdapter.address
    16 //   - BluetoothAdapter.class
    17 //   - BluetoothAdapter.discoverable
    18 //   - BluetoothAdapter.discovering
    19 //   ( P.S. Don't include [BluetoothAdapter.uuids], [BluetoothAdapter.devices] )
    20 //
    21 ///////////////////////////////////////////////////////////////////////////////
    23 MARIONETTE_TIMEOUT = 60000;
    24 MARIONETTE_HEAD_JS = 'head.js';
    26 function testAdapterGetter(aAdapter, aPropertyName, aParamName, aExpected) {
    27   let cmd = "bt property " + BDADDR_LOCAL + " " + aParamName;
    28   return runEmulatorCmdSafe(cmd)
    29     .then(function(aResults) {
    30       is(aResults[1], "OK", "The status report from emulator command.");
    31       log("  Got adapter " + aResults[0]);
    32       is(aResults[0], aParamName + ": " + aExpected, "BluetoothAdapter." + aPropertyName);
    33     });
    34 }
    36 startBluetoothTest(true, function testCaseMain(aAdapter) {
    37   log("Checking the correctness of BluetoothAdapter properties ...");
    39   return Promise.resolve()
    40     .then(() => testAdapterGetter(aAdapter, "name",         "name",         aAdapter.name))
    41     .then(() => testAdapterGetter(aAdapter, "address",      "address",      aAdapter.address))
    42     .then(() => testAdapterGetter(aAdapter, "class",        "cod",          "0x" + aAdapter.class.toString(16)))
    43     .then(() => testAdapterGetter(aAdapter, "discoverable", "discoverable", aAdapter.discoverable.toString()))
    44     .then(() => testAdapterGetter(aAdapter, "discovering",  "discovering",  aAdapter.discovering.toString()));
    45 });

mercurial