PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/libjar/test/unit/test_umlaute.js

http://github.com/zpao/v8monkey
JavaScript | 40 lines | 27 code | 13 blank | 0 comment | 2 complexity | 8ba3e47788bb88d4090f9f38f34f8fea MD5 | raw file
 1
 2const Cc = Components.classes;
 3const Ci = Components.interfaces;
 4
 5function run_test() {
 6  var dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); 
 7  var tmpDir = dirService.get("TmpD", Ci.nsIFile); 
 8
 9  var zipfile = do_get_file("data/test_umlaute.zip");
10
11  var testFile = tmpDir.clone();
12  testFile.append("test_\u00FC.txt");
13  if (testFile.exists()) {
14    testFile.remove(false);
15  }
16
17  var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(Ci.nsIZipReader);
18  zipreader.open(zipfile);
19
20  var entries = zipreader.findEntries(null);
21  do_check_true(entries.hasMore()); 
22
23  var entryName = entries.getNext();
24  do_check_eq(entryName, "test_\u00FC.txt");
25
26  do_check_true(zipreader.hasEntry(entryName));
27
28  var target = tmpDir.clone();
29  target.append(entryName);
30  target.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0640);
31
32  zipreader.extract(entryName, target);
33
34  var entry = zipreader.getEntry(entryName);
35  do_check_true(entry != null);
36
37  zipreader.test(entryName);
38
39  zipreader.close();
40}