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

Unified Diff: chrome/test/data/extensions/api_test/system/storage/test_storage_api.js

Issue 18578008: [SystemInfo API] Move Storage API out of experimental namespace and rename to the "system" namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to the "system" namespace. Created 7 years, 5 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/system/storage/test_storage_api.js
diff --git a/chrome/test/data/extensions/api_test/system/storage/test_storage_api.js b/chrome/test/data/extensions/api_test/system/storage/test_storage_api.js
new file mode 100644
index 0000000000000000000000000000000000000000..7a3866196f41e1f498c0dbd643e572d22f461de7
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/system/storage/test_storage_api.js
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 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.
+
+// system.storage api test
+// browser_tests --gtest_filter=SystemStorageApiTest.Storage
+
+// Testing data should be the same as that in system_storage_apitest.cc
+var testData = [
not at google - send to devlin 2013/07/18 17:06:18 same deal with move detection
Haojian Wu 2013/07/19 08:47:12 Done.
+ { id:"transient:0004", name: "0xbeaf", type: "unknown", capacity: 4098,
+ availableCapacity: 1000, step: 0 },
+ { id:"transient:002", name: "/home", type: "fixed", capacity: 4098,
+ availableCapacity: 1000, step: 10 },
+ { id:"transient:003", name: "/data", type: "fixed", capacity: 10000,
+ availableCapacity: 1000, step: 4097 }
+];
+
+chrome.test.runTests([
+ function testGet() {
+ chrome.system.storage.get(chrome.test.callbackPass(function(units) {
+ chrome.test.assertTrue(units.length == 3);
+ for (var i = 0; i < units.length; ++i) {
+ chrome.test.assertEq(testData[i].id, units[i].id);
+ chrome.test.assertEq(testData[i].name, units[i].name);
+ chrome.test.assertEq(testData[i].type, units[i].type);
+ chrome.test.assertEq(testData[i].capacity, units[i].capacity);
+ }
+ }));
+ },
+ function testChangedEvent() {
+ var numOfChangedEvent = 0;
+ var callbackCompleted = chrome.test.callbackAdded();
+ chrome.system.storage.onAvailableCapacityChanged.
+ addListener(function listener(changeInfo) {
+ for (var i = 0; i < testData.length; ++i) {
+ if (changeInfo.id == testData[i].id) {
+ chrome.test.assertEq(testData[i].availableCapacity,
+ changeInfo.availableCapacity);
+ // Increase its availableCapacity since it will be queried
+ // before triggering onChanged event.
+ testData[i].availableCapacity += testData[i].step;
+ break;
+ }
+ }
+
+ if (i >= testData.length)
+ chrome.test.fail("No matched storage id is found!");
+
+ if (++numOfChangedEvent > 10) {
+ chrome.system.storage.onAvailableCapacityChanged.
+ removeListener(listener);
+ setTimeout(callbackCompleted, 0);
+ }
+ });
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698