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

Side by Side Diff: chrome/test/data/extensions/api_test/filebrowser_mount/test.js

Issue 10231010: gdata: Apply correct mount label when mounting archives in GData (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 7 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
« no previous file with comments | « chrome/common/extensions/api/fileBrowserPrivate.json ('k') | chromeos/dbus/cros_disks_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // These have to be sync'd with file_browser_private_apitest.cc 5 // These have to be sync'd with file_browser_private_apitest.cc
6 var expectedVolume1 = { 6 var expectedVolume1 = {
7 devicePath: 'device_path1', 7 devicePath: 'device_path1',
8 mountPath: 'removable/mount_path1', 8 mountPath: 'removable/mount_path1',
9 systemPath: 'system_path1', 9 systemPath: 'system_path1',
10 filePath: 'file_path1', 10 filePath: 'file_path1',
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 driveLabel: 'drive_label3', 42 driveLabel: 'drive_label3',
43 deviceType: 'optical', 43 deviceType: 'optical',
44 totalSize: 0, 44 totalSize: 0,
45 isParent: true, 45 isParent: true,
46 isReadOnly: false, 46 isReadOnly: false,
47 hasMedia: false, 47 hasMedia: false,
48 isOnBootDevice: true 48 isOnBootDevice: true
49 }; 49 };
50 50
51 // List of expected mount points. 51 // List of expected mount points.
52 // We have to treat archives specially because their sourceUrl is set to
53 // filesystem url. To make it easier to define expectation for archives,
54 // instead of sourceUrl, we set sourcePath that will be converted to filesystem
55 // url when received mountPoint is verified.
56 // NOTE: this has to be synced with values in file_browser_private_apitest.cc 52 // NOTE: this has to be synced with values in file_browser_private_apitest.cc
57 // and values sorted by mountPath. 53 // and values sorted by mountPath.
58 var expectedMountPoints = [ 54 var expectedMountPoints = [
59 { 55 {
60 sourcePath: 'removable/archive_path', 56 sourcePath: '/media/removable/archive_path',
61 mountPath: 'archive/archive_mount_path', 57 mountPath: 'archive/archive_mount_path',
62 mountType: 'file', 58 mountType: 'file',
63 mountCondition: '' 59 mountCondition: ''
64 }, 60 },
65 { 61 {
66 sourceUrl: 'device_path1', 62 sourcePath: 'device_path1',
67 mountPath: 'removable/mount_path1', 63 mountPath: 'removable/mount_path1',
68 mountType: 'device', 64 mountType: 'device',
69 mountCondition: '' 65 mountCondition: ''
70 }, 66 },
71 { 67 {
72 sourceUrl: 'device_path2', 68 sourcePath: 'device_path2',
73 mountPath: 'removable/mount_path2', 69 mountPath: 'removable/mount_path2',
74 mountType: 'device', 70 mountType: 'device',
75 mountCondition: '' 71 mountCondition: ''
76 }, 72 },
77 { 73 {
78 sourceUrl: 'device_path3', 74 sourcePath: 'device_path3',
79 mountPath: 'removable/mount_path3', 75 mountPath: 'removable/mount_path3',
80 mountType: 'device', 76 mountType: 'device',
81 mountCondition: '' 77 mountCondition: ''
82 } 78 }
83 ]; 79 ];
84 80
85 function treatMountPointException(received, expected, key) { 81 function validateObject(received, expected, name) {
86 if (key != 'sourcePath')
87 return { wasValidated: false, success: false };
88 var expectedSourceUrl = createFileUrl(expected[key]);
89 var success = (expectedSourceUrl == received['sourceUrl']);
90 if (!success)
91 console.warn("Expected mount point's sourceUrl to be '" +
92 expectedSourceUrl + "' but got '" + received['sourceUrl'] +
93 "' instead.");
94 return { wasValidated: true, success: success };
95 }
96
97 function validateObject(received, expected, name, treatException) {
98 for (var key in expected) { 82 for (var key in expected) {
99 var validated = treatException &&
100 treatException(received, expected, key);
101 if (validated && validated.wasValidated) {
102 if (validated.success) {
103 continue;
104 } else {
105 return false;
106 }
107 }
108 if (received[key] != expected[key]) { 83 if (received[key] != expected[key]) {
109 console.warn('Expected "' + key + '" ' + name + ' property to be: "' + 84 console.warn('Expected "' + key + '" ' + name + ' property to be: "' +
110 expected[key] + '"' + ', but got: "' + received[key] + 85 expected[key] + '"' + ', but got: "' + received[key] +
111 '" instead.'); 86 '" instead.');
112 return false; 87 return false;
113 } 88 }
114 } 89 }
115 if (Object.keys(expected).length != Object.keys(received).length) { 90 if (Object.keys(expected).length != Object.keys(received).length) {
116 console.warn('Unexpected property found in returned volume'); 91 console.warn('Unexpected property found in returned volume');
117 return false; 92 return false;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 chrome.test.callbackFail('Invalid mount path.')); 166 chrome.test.callbackFail('Invalid mount path.'));
192 }, 167 },
193 168
194 function getMountPointsTest() { 169 function getMountPointsTest() {
195 chrome.fileBrowserPrivate.getMountPoints( 170 chrome.fileBrowserPrivate.getMountPoints(
196 chrome.test.callbackPass(function(result) { 171 chrome.test.callbackPass(function(result) {
197 chrome.test.assertEq(result.length, expectedMountPoints.length, 172 chrome.test.assertEq(result.length, expectedMountPoints.length,
198 'getMountPoints returned wrong number of mount points.'); 173 'getMountPoints returned wrong number of mount points.');
199 for (var i = 0; i < expectedMountPoints.length; i++) { 174 for (var i = 0; i < expectedMountPoints.length; i++) {
200 chrome.test.assertTrue( 175 chrome.test.assertTrue(
201 validateObject(result[i], expectedMountPoints[i], 'mountPoint', 176 validateObject(result[i], expectedMountPoints[i], 'mountPoint'),
202 treatMountPointException),
203 'getMountPoints result[' + i + '] not as expected'); 177 'getMountPoints result[' + i + '] not as expected');
204 } 178 }
205 })); 179 }));
206 } 180 }
207 ]); 181 ]);
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/fileBrowserPrivate.json ('k') | chromeos/dbus/cros_disks_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698