| OLD | NEW |
| 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 chrome.app.runtime.onLaunched.addListener(function (launchData) { | 5 chrome.app.runtime.onLaunched.addListener(function (launchData) { |
| 6 // Test that the id and items fields in FileEntry can be read. | 6 // Test that the id and items fields in FileEntry can be read. |
| 7 chrome.test.runTests([ | 7 chrome.test.runTests([ |
| 8 function testFileHandler() { | 8 function testFileHandler() { |
| 9 chrome.test.assertFalse(!launchData, "No launchData"); | 9 chrome.test.assertFalse(!launchData, "No launchData"); |
| 10 chrome.test.assertEq(launchData.id, "text", | 10 chrome.test.assertEq(launchData.id, "text", |
| 11 "launchData.id incorrect"); | 11 "launchData.id incorrect"); |
| 12 chrome.test.assertEq(launchData.items.length, 1); | 12 chrome.test.assertEq(launchData.items.length, 1); |
| 13 chrome.test.assertTrue( | 13 chrome.test.assertTrue( |
| 14 chrome.fileSystem.getEntryId(launchData.items[0].entry) != null); | 14 chrome.fileSystem.retainEntry(launchData.items[0].entry) != null); |
| 15 | 15 |
| 16 launchData.items[0].entry.file(function(file) { | 16 launchData.items[0].entry.file(function(file) { |
| 17 var reader = new FileReader(); | 17 var reader = new FileReader(); |
| 18 reader.onloadend = function(e) { | 18 reader.onloadend = function(e) { |
| 19 chrome.test.assertEq( | 19 chrome.test.assertEq( |
| 20 reader.result.indexOf("This is a test. Word."), 0); | 20 reader.result.indexOf("This is a test. Word."), 0); |
| 21 chrome.test.succeed(); | 21 chrome.test.succeed(); |
| 22 }; | 22 }; |
| 23 reader.onerror = function(e) { | 23 reader.onerror = function(e) { |
| 24 chrome.test.fail("Error reading file contents."); | 24 chrome.test.fail("Error reading file contents."); |
| 25 }; | 25 }; |
| 26 reader.readAsText(file); | 26 reader.readAsText(file); |
| 27 }); | 27 }); |
| 28 } | 28 } |
| 29 ]); | 29 ]); |
| 30 }); | 30 }); |
| OLD | NEW |