1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // system.storage api test
6 // extensions_browsertests --gtest_filter=SystemStorageApiTest.Storage
8 // Testing data should be the same as |kTestingData| in
9 // system_storage_apitest.cc.
11 { id:"", name: "0xbeaf", type: "removable", capacity: 4098,
12 availableCapacity: 1},
13 { id:"", name: "/home", type: "fixed", capacity: 4098,
14 availableCapacity: 2},
15 { id:"", name: "/data", type: "fixed", capacity: 10000,
19 chrome.test.runTests([
20 function testGetInfo() {
21 chrome.system.storage.getInfo(chrome.test.callbackPass(function(units) {
22 chrome.test.assertTrue(units.length == 3);
23 for (var i = 0; i < units.length; ++i) {
24 chrome.test.sendMessage(units[i].id);
25 chrome.test.assertEq(testData[i].name, units[i].name);
26 chrome.test.assertEq(testData[i].type, units[i].type);
27 chrome.test.assertEq(testData[i].capacity, units[i].capacity);
31 function testGetAvailableCapacity() {
32 chrome.system.storage.getInfo(chrome.test.callbackPass(function(units) {
33 chrome.test.assertTrue(units.length == 3);
34 // Record all storage devices' |id| in testData.
35 for (var i = 0; i < units.length; ++i)
36 testData[i].id = units[i].id;
37 for (var i = 0; i < units.length; ++i) {
38 chrome.system.storage.getAvailableCapacity(units[i].id, function(info) {
39 for (var j = 0; j < units.length; ++j) {
40 if (info.id == testData[j].id) {
41 chrome.test.assertEq(testData[j].availableCapacity,
42 info.availableCapacity);