OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 'use strict'; | 4 'use strict'; |
5 | 5 |
6 /** | 6 /** |
7 * Mock of chrome.runtime. | 7 * Mock of chrome.runtime. |
8 * @type {Object} | 8 * @type {Object} |
9 * @const | 9 * @const |
10 */ | 10 */ |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 }; | 212 }; |
213 | 213 |
214 // Observing manager's events. | 214 // Observing manager's events. |
215 var eventsPromise = new Promise(function(fulfill) { | 215 var eventsPromise = new Promise(function(fulfill) { |
216 var events = []; | 216 var events = []; |
217 fileOperationManager.addEventListener('copy-progress', function(event) { | 217 fileOperationManager.addEventListener('copy-progress', function(event) { |
218 events.push(event); | 218 events.push(event); |
219 if (event.reason === 'SUCCESS') | 219 if (event.reason === 'SUCCESS') |
220 fulfill(events); | 220 fulfill(events); |
221 }); | 221 }); |
222 fileOperationManager.addEventListener('entry-changed', function(event) { | 222 fileOperationManager.addEventListener('entries-changed', function(event) { |
223 events.push(event); | 223 events.push(event); |
224 }); | 224 }); |
225 }); | 225 }); |
226 | 226 |
227 // Verify the events. | 227 // Verify the events. |
228 reportPromise(eventsPromise.then(function(events) { | 228 reportPromise(eventsPromise.then(function(events) { |
229 var firstEvent = events[0]; | 229 var firstEvent = events[0]; |
230 assertEquals('BEGIN', firstEvent.reason); | 230 assertEquals('BEGIN', firstEvent.reason); |
231 assertEquals(1, firstEvent.status.numRemainingItems); | 231 assertEquals(1, firstEvent.status.numRemainingItems); |
232 assertEquals(0, firstEvent.status.processedBytes); | 232 assertEquals(0, firstEvent.status.processedBytes); |
233 assertEquals(1, firstEvent.status.totalBytes); | 233 assertEquals(1, firstEvent.status.totalBytes); |
234 | 234 |
235 var lastEvent = events[events.length - 1]; | 235 var lastEvent = events[events.length - 1]; |
236 assertEquals('SUCCESS', lastEvent.reason); | 236 assertEquals('SUCCESS', lastEvent.reason); |
237 assertEquals(0, lastEvent.status.numRemainingItems); | 237 assertEquals(0, lastEvent.status.numRemainingItems); |
238 assertEquals(10, lastEvent.status.processedBytes); | 238 assertEquals(10, lastEvent.status.processedBytes); |
239 assertEquals(10, lastEvent.status.totalBytes); | 239 assertEquals(10, lastEvent.status.totalBytes); |
240 | 240 |
241 assertTrue(events.some(function(event) { | 241 assertTrue(events.some(function(event) { |
242 return event.type === 'entry-changed' && | 242 return event.type === 'entries-changed' && |
hirono
2014/08/15 09:13:59
Sorry I added more tests here.
Could you rebase it
fukino
2014/08/15 10:22:27
Done.
| |
243 event.entry === targetEntry; | 243 event.entries[0] === targetEntry; |
244 })); | 244 })); |
245 }), callback); | 245 }), callback); |
246 | 246 |
247 fileOperationManager.paste(sourceEntries, targetEntry, false); | 247 fileOperationManager.paste(sourceEntries, targetEntry, false); |
248 } | 248 } |
OLD | NEW |