]> git.proxmox.com Git - extjs.git/blob - extjs/packages/soap/.sencha/test/Ext.cmd.api.adapter.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / soap / .sencha / test / Ext.cmd.api.adapter.js
1 Ext.cmd.api.adapter = {
2
3 testResults: [],
4 isRunning: false,
5 resultBufferSize: 100,
6 api: Ext.cmd.api,
7
8 setCurrentScript: function(name) {
9 // no-op, managed by Ext.Boot.currentFile
10 },
11
12 getCurrentScript: function() {
13 return this.api.getCurrentScript(Ext.Boot.currentFile);
14 },
15
16 getSpecStructure: function(spec) {
17 var structure = {
18 hash: '' + spec.id,
19 fileName: spec.fileName,
20 description: spec.description
21 };
22 return structure;
23 },
24
25 getSuiteStructure: function(suite) {
26 var structure = {
27 hash: '' + suite.id,
28 fileName: suite.fileName,
29 suites: [],
30 specs: [],
31 description: suite.description
32 },
33 specs = suite.specs_,
34 spLen = specs.length, spec, sp,
35 suites = suite.suites_,
36 suLen = suites.length, suite, su;
37
38 for(su = 0; su < suLen; su++) {
39 suite = suites[su];
40 structure.suites.push(this.getSuiteStructure(suite));
41 }
42
43 for(sp = 0; sp < spLen; sp++) {
44 spec = specs[sp];
45 structure.specs.push(this.getSpecStructure(spec));
46 }
47
48 return structure;
49 },
50
51 reportTestStructure: function() {
52 var runner = jasmine.getEnv().currentRunner_,
53 suites = runner.topLevelSuites(),
54 slen = suites.length, suite, s,
55 structure = [];
56
57 for(s = 0; s < slen; s++) {
58 suite = suites[s];
59 structure.push(this.getSuiteStructure(suite));
60 }
61 this.api.addTestSuites(structure);
62 },
63
64 executeTests: function() {
65 this.isRunning = true;
66 jasmine.setOptions(this.api.jsonOptions);
67 jasmine.initDebug();
68 jasmine.getEnv().addReporter(new SenchaTestRunner.Reporter());
69 jasmine.getEnv().execute();
70 },
71
72 flushTestResults: function() {
73 if(this.testResults.length > 0) {
74 var results = this.testResults;
75 this.testResults = [];
76 this.api.reportTestResults(results);
77 }
78 },
79
80 onTestResult: function(result) {
81 this.testResults.push(result);
82 if(this.testResults.length >= this.resultBufferSize) {
83 this.flushTestResults();
84 }
85 },
86
87 captureCoverage: function() {
88 var coverageObj = window['__coverage__'];
89 if(coverageObj) {
90 this.api.addTestCoverage(coverageObj);
91 }
92 },
93
94 onTestsDone: function(success) {
95 var me = this;
96 me.isRunning = false;
97 if(success === undefined) {
98 me.success = true;
99 } else {
100 me.success = success;
101 }
102 me.flushTestResults();
103 me.captureCoverage();
104 this.api.stopWorkItem(me.success);
105 }
106 };