Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / file_system_provider / get_all / test.js
1 // Copyright 2014 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.
4
5 'use strict';
6
7 /**
8  * Runs all of the test cases, one by one.
9  */
10 chrome.test.runTests([
11   // Verifies if getAll() returns the mounted file system.
12   function mountSuccess() {
13     chrome.fileSystemProvider.mount(
14         {
15           fileSystemId: test_util.FILE_SYSTEM_ID,
16           displayName: test_util.FILE_SYSTEM_NAME
17         },
18         chrome.test.callbackPass(function() {
19           chrome.fileSystemProvider.getAll(chrome.test.callbackPass(
20               function(fileSystems) {
21                 chrome.test.assertEq(1, fileSystems.length);
22                 chrome.test.assertEq(
23                     test_util.FILE_SYSTEM_ID, fileSystems[0].fileSystemId);
24                 chrome.test.assertEq(
25                     test_util.FILE_SYSTEM_NAME, fileSystems[0].displayName);
26                 chrome.test.assertFalse(fileSystems[0].writable);
27               }));
28         }));
29   },
30
31   // Verifies that after unmounting, the file system is not available in
32   // getAll() list.
33   function unmountSuccess() {
34     chrome.fileSystemProvider.unmount(
35         {fileSystemId: test_util.FILE_SYSTEM_ID},
36         chrome.test.callbackPass(function() {
37           chrome.fileSystemProvider.getAll(chrome.test.callbackPass(
38               function(fileSystems) {
39                 chrome.test.assertEq(0, fileSystems.length);
40               }));
41         }));
42   },
43
44   // Verifies that if mounting fails, then the file system is not added to the
45   // getAll() list.
46   function mountError() {
47     chrome.fileSystemProvider.mount(
48         {fileSystemId: '', displayName: ''},
49         chrome.test.callbackFail('SECURITY', function() {
50           chrome.fileSystemProvider.getAll(chrome.test.callbackPass(
51               function(fileSystems) {
52                 chrome.test.assertEq(0, fileSystems.length);
53               }));
54         }));
55   }
56 ]);