~ubuntu-branches/ubuntu/precise/enigmail/precise-updates

« back to all changes in this revision

Viewing changes to ipc/tests/unit/testframework.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2015-08-26 20:08:27 UTC
  • mfrom: (0.12.19)
  • Revision ID: package-import@ubuntu.com-20150826200827-hcdgxjl17bc6gwu1
Tags: 2:1.8.2-0ubuntu0.12.04.1
* New upstream release v1.8.2 to support Thunderbird 38
  - Fixes LP: #1489103 - Per-account settings missing after Thunderbird
    update

* Depend on gnupg2 instead of gnupg. Whilst this enigmail version still
  works with gnupg 1.4.*, it pops up an alert warning that it will be the
  last version to do so
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 *  Helper framework if tests should be performed within a running app
3
 
 */
4
 
var gTestError=0;
5
 
var gTestPending=0;
6
 
 
7
 
function dumperr(str) {
8
 
  gTestError = 1;
9
 
  var consoleSvc = Components.classes["@mozilla.org/consoleservice;1"].
10
 
      getService(Components.interfaces.nsIConsoleService);
11
 
  consoleSvc.logStringMessage("IPC-Pipe Test: "+str);
12
 
}
13
 
 
14
 
function do_check_true(boolValue)
15
 
{
16
 
  if (! boolValue)
17
 
    dumperr("ERROR: found not true value");
18
 
}
19
 
 
20
 
function do_check_false(boolValue)
21
 
{
22
 
  if (boolValue)
23
 
    dumperr("ERROR: found true value");
24
 
}
25
 
 
26
 
function do_check_eq(a, b)
27
 
{
28
 
  if (! (a == b))
29
 
    dumperr("ERROR: found: '"+a+"' != '"+b+"'");
30
 
}
31
 
 
32
 
function do_check_neq(a, b)
33
 
{
34
 
  if (a == b)
35
 
    dumperr("ERROR: found: '"+a+"' == '"+b+"'");
36
 
}
37
 
 
38
 
function do_throw(txt) {
39
 
  dumperr(txt);
40
 
}
41
 
 
42
 
 
43
 
function do_get_cwd() {
44
 
  var fn="/Users/pbr/enigmail/tmp";
45
 
 
46
 
  var localfile = Components.classes["@mozilla.org/file/local;1"].createInstance(
47
 
        Components.interfaces.nsIFile);
48
 
  localfile.initWithPath(fn);
49
 
 
50
 
  return localfile;
51
 
}
52
 
 
53
 
function do_get_file(testdirRelativePath, allowNonexistent)
54
 
{
55
 
 
56
 
  var isLinux = ("@mozilla.org/gnome-gconf-service;1" in Components.classes);
57
 
  var fn="";
58
 
 
59
 
  if (isLinux)
60
 
    fn="/home/enigmail/tmp/"+testdirRelativePath;
61
 
  else
62
 
    fn="/Users/pbr/enigmail/tmp/"+testdirRelativePath;
63
 
 
64
 
 
65
 
 
66
 
  var localfile = Components.classes["@mozilla.org/file/local;1"].createInstance(
67
 
        Components.interfaces.nsILocalFile);
68
 
  localfile.initWithPath(fn);
69
 
 
70
 
  if (! (allowNonexistent || localfile.exists())) {
71
 
    dumperr("ERROR: file '"+fn+"' not found");
72
 
    return null;
73
 
  }
74
 
  return localfile;
75
 
}
76
 
 
77
 
function do_test_pending() {
78
 
  gTestPending=1;
79
 
  window.setTimeout(checkStillPending, 300);
80
 
}
81
 
 
82
 
function checkStillPending() {
83
 
  if (gTestPending)
84
 
    window.setTimeout(checkStillPending, 300);
85
 
}
86
 
 
87
 
function do_test_finished() {
88
 
  gTestPending = 0;
89
 
 
90
 
  if (gTestError == 0)
91
 
    alert("all tests succeeded OK");
92
 
  else
93
 
    alert("Test terminated with error");
94
 
}
95
 
 
96
 
function run_test_wrapper() {
97
 
  gTestError=0;
98
 
 
99
 
  try {
100
 
    run_test();
101
 
    if (! gTestPending) do_test_finished();
102
 
  }
103
 
  catch (ex) {
104
 
    dumperr(ex.toString());
105
 
    alert("Test created exception");
106
 
  }
107
 
  //dumperr("---- end -----");
108
 
}
109
 
 
110