Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / base / unittest / test_case.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7 <link rel="import" href="/base/guid.html">
8 <link rel="import" href="/base/unittest/constants.html">
9 <script>
10 'use strict';
11
12 tv.exportTo('tv.unittest', function() {
13   var TestTypes = tv.unittest.TestTypes;
14
15   function TestCase(suite, testType, name, test, options) {
16     this.guid_ = tv.GUID.allocate();
17     this.suite_ = suite;
18     this.testType_ = testType;
19     this.name_ = name;
20
21     this.options_ = options;
22
23     this.test_ = test;
24   }
25
26   TestCase.parseFullyQualifiedName = function(fqn) {
27     var i = fqn.lastIndexOf('.');
28     if (i == -1)
29       throw new Error('FullyQualifiedNames must have a period in them');
30     return {
31       suiteName: fqn.substr(0, i),
32       testCaseName: fqn.substr(i + 1)
33     };
34   };
35
36   TestCase.prototype = {
37     __proto__: Object.prototype,
38
39     get guid() {
40       return this.guid;
41     },
42
43     get suite() {
44       return this.suite_;
45     },
46
47     get testType() {
48       return this.testType_;
49     },
50
51     get name() {
52       return this.name_;
53     },
54
55     get fullyQualifiedName() {
56       return this.suite_.name + '.' + this.name_;
57     },
58
59     get options() {
60       return this.options_;
61     },
62
63     run: function(htmlHook) {
64       return this.test_();
65     },
66
67     // TODO(nduca): The routing of this is a bit awkward. Probably better
68     // to install a global function.
69     addHTMLOutput: function(element) {
70       tv.unittest.addHTMLOutputForCurrentTest(element);
71     }
72   };
73
74   function PerfTestCase(suite, name, test, options) {
75     TestCase.call(this, suite, TestTypes.PERFTEST, name, test, options);
76   }
77
78   PerfTestCase.prototype = {
79     __proto__: TestCase.prototype
80   };
81
82   return {
83     TestCase: TestCase,
84     PerfTestCase: PerfTestCase
85   };
86 });
87 </script>