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

Side by Side Diff: chrome/test/data/extensions/api_test/file_browser/retain_entry/background.js

Issue 656733002: Fix filesystem.retainEntry API to handle non-native directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
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 /**
6 * Retains a test directory.
7 * @return {Promise} Promise fulflled/rejected depending on the test result.
8 */
9 function retainDirectory() {
10 return new Promise(function(fulfill) {
11
mtomasz 2014/10/14 06:08:50 nit: This \n looks strange here.
hirono 2014/10/14 09:22:10 Yes, mixed it in unintentionally.
12 chrome.app.window.create('window.html', fulfill);
13 }).then(function(appWindow) {
14 return new Promise(function(fulfill) {
mtomasz 2014/10/14 06:08:50 nit: AFAIK we require two arguments here for the c
hirono 2014/10/14 09:22:10 Done.
15 appWindow.contentWindow.chrome.fileSystem.chooseEntry(
16 {type: "openDirectory"},
17 fulfill);
18 });
19 }).then(function(selected) {
20 chrome.test.assertTrue(selected.isDirectory);
21 var id = chrome.fileSystem.retainEntry(selected);
22 chrome.test.assertTrue(!!id);
23 return new Promise(function(fulfill) {
24 chrome.fileSystem.isRestorable(id, fulfill);
25 }).then(function(restorable) {
26 chrome.test.assertTrue(restorable);
27 return new Promise(function(fulfill) {
28 chrome.storage.local.set({id: id}, fulfill);
29 });
30 });
31 }).then(function() {
32 chrome.runtime.reload();
33 });
34 }
35
36 /**
37 * Restores a test directory.
38 * @param {string} id ID of the test directory.
39 * @return {Promise} Promise fulflled/rejected depending on the test result.
40 */
41 function restoreDirectory(id) {
42 return new Promise(function(fulfill) {
43 chrome.fileSystem.isRestorable(id, fulfill);
44 }).then(function(restorable) {
45 chrome.test.assertTrue(restorable);
46 return new Promise(function(fulfill) {
47 chrome.fileSystem.restoreEntry(id, fulfill);
48 });
49 }).then(function(directory) {
50 chrome.test.assertTrue(!!directory);
51 chrome.test.assertTrue(!!directory.isDirectory);
52 });
53 }
54
55 /**
56 * Tests to retain and to restore directory on the drive.
57 */
58 function testRetainEntry() {
59 new Promise(function(fulfill) {
60 chrome.storage.local.get('id', fulfill);
61 }).then(function(obj) {
mtomasz 2014/10/14 06:08:50 nit: obj -> values?
hirono 2014/10/14 09:22:10 Done.
62 if (!obj.id)
63 return retainDirectory();
64 else
65 return restoreDirectory(obj.id).then(chrome.test.callbackPass());
66 }).catch(function(error) {
67 chrome.test.fail(error.stack || error);
68 window.onerror();
mtomasz 2014/10/14 06:08:50 Is window.onerror() necessary?
hirono 2014/10/14 09:22:10 Removed.
69 });
70 }
71
72 chrome.test.runTests([testRetainEntry]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698