Commit d1833116 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Apps] Improve MusicManagerPrivate test

The MusicManagerPrivate test to exercise getDeviceId() needs to
accommodate an empty device ID; however, this can (and did) mask other
errors that should be caught.

Improve the test by expecting a specific error if the device ID is
empty.

Bug: 923599
Change-Id: I545d36ab87ad263d8d725eeb5a94608dc0381b1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601739Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658254}
parent f95a65c2
......@@ -2,26 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function runTests() {
chrome.test.runTests([
function test() {
chrome.musicManagerPrivate.getDeviceId(function(id) {
console.log('Device ID=' + id);
if (id) {
// This block is not entered in VMs (e.g. the bots) which return
// dummy MACs.
chrome.test.assertEq('string', typeof id);
chrome.test.assertTrue(id.length >= 8);
}
chrome.test.succeed();
});
}
]);
}
window.onload = function() {
chrome.test.getConfig(function(config) {
console.log('customArg=' + config.customArg);
runTests();
});
}
chrome.test.runTests([
function getDeviceIdTest() {
chrome.musicManagerPrivate.getDeviceId(function(id) {
if (id !== undefined) {
chrome.test.assertNoLastError();
chrome.test.assertEq('string', typeof id);
chrome.test.assertTrue(id.length >= 8);
} else {
// Bots may not support device ID. In this case, we still check that the
// error message is what we expect.
chrome.test.assertLastError(
'Device ID API is not supported on this platform.');
}
chrome.test.succeed();
});
}
]);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment