~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/tutorial/tutorial.js

  • Committer: stevenbird
  • Date: 2008-02-20 00:16:56 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:518
Cleaned up display of test results:
* use different icons for test_case_parts (check and cross)
* don't print Pass/Fail tags or return string for test_case_parts

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
    {
108
108
        /* Only one error - and it's bad.
109
109
         * Just print and stop */
110
 
        ul.appendChild(create_response_item("critical",
 
110
        ul.appendChild(create_response_item("critical", 0,
111
111
            testresponse.critical_error.name,
112
112
            testresponse.critical_error.detail));
113
113
        return;
119
119
        if ("exception" in testcase)
120
120
        {
121
121
            /* User's code threw an exception */
122
 
            fail_li = create_response_item("fail", testcase.name);
 
122
            fail_li = create_response_item("fail", 0, testcase.name);
123
123
            ul.appendChild(fail_li);
124
124
            /* Create a sub-ul to display the failing cases. */
125
125
            case_ul = document.createElement("ul");
126
126
            fail_li.appendChild(case_ul);
127
 
            case_ul.appendChild(create_response_item("exception",
 
127
            case_ul.appendChild(create_response_item("exception", 0,
128
128
                testcase.exception.name, testcase.exception.detail));
129
129
        }
130
130
        else if (testcase.passed)
131
131
        {
132
132
            /* All parts of the test case passed. Just report the overall case
133
133
             * passing. */
134
 
            ul.appendChild(create_response_item("pass", testcase.name));
 
134
            ul.appendChild(create_response_item("pass", 0, testcase.name));
135
135
        }
136
136
        else
137
137
        {
138
 
            var fail_li = create_response_item("fail", testcase.name);
 
138
            var fail_li = create_response_item("fail", 0, testcase.name);
139
139
            ul.appendChild(fail_li);
140
140
            /* Create a sub-ul to display the failing cases. */
141
141
            case_ul = document.createElement("ul");
146
146
                var part = testcase.parts[j];
147
147
                if (part.passed)
148
148
                {
149
 
                    case_ul.appendChild(create_response_item("pass",
 
149
                    case_ul.appendChild(create_response_item("pass", 1,
150
150
                        part.description));
151
151
                }
152
152
                else
153
153
                {
154
 
                    case_ul.appendChild(create_response_item("fail",
155
 
                        part.description, part.error_message));
 
154
                    case_ul.appendChild(create_response_item("fail", 1,
 
155
                        part.description /*, part.error_message */));
156
156
                }
157
157
            }
158
158
        }
163
163
 
164
164
/** Create a <li> element for the result of a test case.
165
165
 * type: "pass", "fail", "exception" or "critical"
166
 
 * detail should be null for passing cases.
 
166
 * level is 0 for outer, and 1 for inner
167
167
 * For exceptions and crits, "desc" is the exception name,
168
 
 * detail is the message.
 
168
 * detail is the message; detail should be null for passing cases.
169
169
 */
170
 
function create_response_item(type, desc, detail)
 
170
function create_response_item(type, level, desc, detail)
171
171
{
172
172
    var crit = false;
173
173
    if (type == "critical")
177
177
        type = "exception";
178
178
    }
179
179
    var li = document.createElement("li");
180
 
    li.setAttribute("class", type);
181
 
    var b = document.createElement("b");
182
 
    var text = type[0].toUpperCase() + type.substr(1) + ":";
183
 
    b.appendChild(document.createTextNode(text));
184
 
    li.appendChild(b);
 
180
    if (level == 0)
 
181
    {
 
182
        li.setAttribute("class", type);
 
183
    }
 
184
    else
 
185
    {
 
186
        if (type == "pass") { li.setAttribute("class", "check") }
 
187
        else { li.setAttribute("class", "cross") }
 
188
    }
 
189
 
 
190
    if (level == 0) /* print Pass/Fail tag at outer level only */
 
191
    {
 
192
        var b = document.createElement("b");
 
193
        var text = type[0].toUpperCase() + type.substr(1) + ":";
 
194
        b.appendChild(document.createTextNode(text));
 
195
        li.appendChild(b);
 
196
    }
 
197
 
185
198
    if (type == "pass")
186
199
        text = desc;
187
200
    else if (type == "fail")