OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // systemInfo.storage api test | 5 // systemInfo.storage api test |
6 // browser_tests --gtest_filter=SystemInfoStorageApiTest.Storage | 6 // browser_tests --gtest_filter=SystemInfoStorageApiTest.Storage |
7 chrome.systemInfo = chrome.experimental.systemInfo; | 7 chrome.systemInfo = chrome.experimental.systemInfo; |
8 | 8 |
9 // Testing data should be the same as that in system_info_storage_apitest.cc | 9 // Testing data should be the same as that in system_info_storage_apitest.cc |
10 var testData = [ | 10 var testData = [ |
11 { id: "0xbeaf", type: "unknown", capacity: 4098, | 11 { id: "0xbeaf", type: "unknown", capacity: 4098, |
12 availableCapacity: 1000, step: 0 }, | 12 availableCapacity: 1000, step: 0 }, |
13 { id: "/home", type: "harddisk", capacity: 4098, | 13 { id: "/home", type: "fixed", capacity: 4098, |
14 availableCapacity: 1000, step: 10 }, | 14 availableCapacity: 1000, step: 10 }, |
15 { id: "/data", type: "harddisk", capacity: 10000, | 15 { id: "/data", type: "fixed", capacity: 10000, |
16 availableCapacity: 1000, step: 4097 } | 16 availableCapacity: 1000, step: 4097 } |
17 ]; | 17 ]; |
18 | 18 |
19 chrome.test.runTests([ | 19 chrome.test.runTests([ |
20 function testGet() { | 20 function testGet() { |
21 chrome.systemInfo.storage.get(chrome.test.callbackPass(function(units) { | 21 chrome.systemInfo.storage.get(chrome.test.callbackPass(function(units) { |
22 chrome.test.assertTrue(units.length == 3); | 22 chrome.test.assertTrue(units.length == 3); |
23 for (var i = 0; i < units.length; ++i) { | 23 for (var i = 0; i < units.length; ++i) { |
24 chrome.test.assertEq(testData[i].id, units[i].id); | 24 chrome.test.assertEq(testData[i].id, units[i].id); |
25 chrome.test.assertEq(testData[i].type, units[i].type); | 25 chrome.test.assertEq(testData[i].type, units[i].type); |
(...skipping 24 matching lines...) Expand all Loading... |
50 chrome.test.fail("No matched storage id is found!"); | 50 chrome.test.fail("No matched storage id is found!"); |
51 | 51 |
52 if (++numOfChangedEvent > 10) { | 52 if (++numOfChangedEvent > 10) { |
53 chrome.systemInfo.storage.onAvailableCapacityChanged.removeListener( | 53 chrome.systemInfo.storage.onAvailableCapacityChanged.removeListener( |
54 listener); | 54 listener); |
55 setTimeout(callbackCompleted, 0); | 55 setTimeout(callbackCompleted, 0); |
56 } | 56 } |
57 }); | 57 }); |
58 } | 58 } |
59 ]); | 59 ]); |
OLD | NEW |