~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to mailnews/extensions/enigmail/ipc/tests/unit/testframework.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

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