Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2802)

Unified Diff: chrome/test/data/extensions/api_test/image_writer_private/list_devices/test.js

Issue 266363006: Adds API tests for listRemovableStorageDevices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleans up a few minor issues. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/image_writer_private/list_devices/test.js
diff --git a/chrome/test/data/extensions/api_test/image_writer_private/list_devices/test.js b/chrome/test/data/extensions/api_test/image_writer_private/list_devices/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..20687a96fe9d9862e0a4d60e56f219afb2585d2c
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/image_writer_private/list_devices/test.js
@@ -0,0 +1,45 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var expectedDevices = [{
+ 'vendor': 'Vendor 1',
+ 'model': 'Model 1',
+ 'capacity': 1 << 20,
+ 'storageUnitId': '/test/id/1',
+ }, {
+ 'vendor': 'Vendor 2',
+ 'model': 'Model 2',
+ 'capacity': 1 << 22,
+ 'storageUnitId': '/test/id/2',
+ }];
+
+
+function testDeviceList() {
+ chrome.imageWriterPrivate.
+ listRemovableStorageDevices(listRemovableDevicesCallback);
+}
+
+function listRemovableDevicesCallback(deviceList) {
+ deviceList.sort(function (a, b) {
+ if (a.storageUnitId > b.storageUnitId) return 1;
+ if (a.storageUnitId < b.storageUnitId) return -1;
+ return 0;
+ });
+
+ if (deviceList.length == 2) {
+ deviceList.forEach(function (dev, i) {
+ var expected = expectedDevices[i];
+ chrome.test.assertEq(expected.vendor, dev.vendor);
+ chrome.test.assertEq(expected.model, dev.model);
+ chrome.test.assertEq(expected.capacity, dev.capacity);
+ chrome.test.assertEq(expected.storageUnitId, dev.storageUnitId);
+ });
+ chrome.test.succeed();
+ return;
+ }
+
+ chrome.test.fail();
+}
+
+chrome.test.runTests([testDeviceList])
asargent_no_longer_on_chrome 2014/05/07 21:31:40 FYI, I think your test is in danger of completing
Drew Haven 2014/05/08 00:14:34 Yeah, I had trouble understanding the framework an

Powered by Google App Engine
This is Rietveld 408576698