testability-driver 0.9.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +11 -7
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +8 -0
- data/lib/tdriver/base/behaviour/factory.rb +229 -209
- data/lib/tdriver/base/errors.rb +3 -0
- data/lib/tdriver/base/state_object.rb +11 -20
- data/lib/tdriver/base/sut/controller.rb +4 -4
- data/lib/tdriver/base/sut/factory.rb +205 -170
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +256 -174
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +17 -11
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +57 -66
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +578 -497
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +41 -15
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +48 -19
- data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +25 -13
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +16 -10
- data/lib/tdriver/base/sut/generic/plugin.rb +9 -3
- data/lib/tdriver/base/sut/sut.rb +41 -33
- data/lib/tdriver/base/test_object/abstract.rb +26 -3
- data/lib/tdriver/base/test_object/adapter.rb +399 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +56 -14
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +663 -197
- data/lib/tdriver/base/test_object/cache.rb +132 -0
- data/lib/tdriver/base/test_object/factory.rb +677 -426
- data/lib/tdriver/base/test_object/factory_new.rb +202 -0
- data/lib/tdriver/base/test_object/identificator.rb +24 -17
- data/lib/tdriver/base/test_object/loader.rb +9 -3
- data/lib/tdriver/base/test_object/verification.rb +181 -0
- data/lib/tdriver/loader.rb +1 -1
- data/lib/tdriver/report/report.rb +2 -0
- data/lib/tdriver/report/report_api.rb +4 -4
- data/lib/tdriver/report/report_creator.rb +29 -3
- data/lib/tdriver/report/report_data_presentation.rb +7 -3
- data/lib/tdriver/report/report_execution_statistics.rb +80 -21
- data/lib/tdriver/report/report_javascript.rb +192 -0
- data/lib/tdriver/report/report_test_case_run.rb +22 -0
- data/lib/tdriver/report/report_test_run.rb +62 -55
- data/lib/tdriver/report/report_writer.rb +57 -56
- data/lib/tdriver/tdriver.rb +14 -41
- data/lib/tdriver/util/common/error.rb +1 -0
- data/lib/tdriver/util/common/exceptions.rb +12 -0
- data/lib/tdriver/util/common/file.rb +12 -6
- data/lib/tdriver/util/common/gem.rb +2 -1
- data/lib/tdriver/util/common/hash.rb +152 -0
- data/lib/tdriver/util/common/kernel.rb +49 -34
- data/lib/tdriver/util/common/loader.rb +21 -17
- data/lib/tdriver/util/common/numeric.rb +39 -0
- data/lib/tdriver/util/common/object.rb +115 -0
- data/lib/tdriver/util/common/string.rb +55 -2
- data/lib/tdriver/util/dbaccess/dbaccess.rb +194 -161
- data/lib/tdriver/util/dynamic_attribute_filter.rb +6 -0
- data/lib/tdriver/util/hooking.rb +2 -2
- data/lib/tdriver/util/loader.rb +2 -2
- data/lib/tdriver/util/localisation/localisation.rb +277 -18
- data/lib/tdriver/util/logger.rb +142 -13
- data/lib/tdriver/util/parameter/parameter_hash.rb +8 -5
- data/lib/tdriver/util/parameter/parameter_xml.rb +18 -2
- data/lib/tdriver/util/recorder.rb +17 -12
- data/lib/tdriver/util/user_data/user_data.rb +3 -2
- data/lib/tdriver/util/{video_rec.rb → video_utils.rb} +136 -16
- data/lib/tdriver/util/xml/abstraction.rb +7 -0
- data/lib/tdriver/util/xml/attribute.rb +32 -0
- data/lib/tdriver/util/xml/loader.rb +8 -2
- data/lib/tdriver/util/xml/nil_node.rb +95 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +46 -7
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +19 -9
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +1 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +13 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +6 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +27 -15
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +57 -0
- data/lib/tdriver/util/xml/text.rb +32 -0
- data/lib/tdriver/util/xml/xml.rb +35 -22
- data/lib/tdriver/version.rb +1 -1
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +41 -34
- data/lib/tdriver-devtools/doc/generate.rb +31 -6
- data/lib/tdriver-devtools/doc/xslt/template.xsl +46 -25
- data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +1 -1
- data/lib/tdriver.rb +0 -3
- data/xml/behaviours/generic.xml +1 -1
- data/xml/defaults/generic.xml +4 -90
- data/xml/templates/generic.xml +33 -25
- metadata +21 -29
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +0 -245
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +0 -964
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +0 -68
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +0 -1865
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +0 -12
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +0 -5
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +0 -2
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +0 -7
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +0 -14
- data/lib/tdriver-devtools/behaviour/xml_generator/update +0 -3
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +0 -233
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +0 -194
data/lib/tdriver/loader.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
require 'singleton'
|
22
22
|
require 'set'
|
23
23
|
|
24
|
-
# load native extensions
|
24
|
+
# load native extensions if available
|
25
25
|
begin; require File.expand_path( File.join( File.dirname( __FILE__ ), 'native_extensions' ) ); rescue LoadError; end
|
26
26
|
|
27
27
|
# generic utility modules
|
@@ -22,6 +22,7 @@ require File.expand_path( File.join( File.dirname( __FILE__ ), 'error_recovery/t
|
|
22
22
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'error_recovery/tdriver_custom_error_recovery' ) )
|
23
23
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_file_capture' ) )
|
24
24
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_crash_file_capture' ) )
|
25
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_javascript' ) )
|
25
26
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_writer' ) )
|
26
27
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_combine' ) )
|
27
28
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_data_table' ) )
|
@@ -39,6 +40,7 @@ require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_grouping'
|
|
39
40
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_execution_statistics' ) )
|
40
41
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'report_data_presentation' ) )
|
41
42
|
|
43
|
+
|
42
44
|
if MobyUtil::Parameter[ :custom_error_recovery_module, nil ]!=nil
|
43
45
|
require MobyUtil::Parameter[ :custom_error_recovery_module ]
|
44
46
|
end
|
@@ -21,7 +21,7 @@
|
|
21
21
|
module TDriverReportAPI
|
22
22
|
|
23
23
|
def tdriver_log_data(data)
|
24
|
-
Kernel::raise
|
24
|
+
Kernel::raise TypeError.new("Argument to method cannot be nil.") if data.nil?
|
25
25
|
if $tdriver_reporter!=nil
|
26
26
|
$tdriver_reporter.set_user_data(data)
|
27
27
|
end
|
@@ -34,21 +34,21 @@ module TDriverReportAPI
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def tdriver_log_data_in_total_run_table(column_name,value)
|
37
|
-
Kernel::raise
|
37
|
+
Kernel::raise TypeError.new("Argument to method cannot be nil.") if column_name.nil? || value.nil?
|
38
38
|
if $tdriver_reporter!=nil
|
39
39
|
$tdriver_reporter.set_user_table_data(column_name,value)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def tdriver_report_log(message)
|
44
|
-
Kernel::raise
|
44
|
+
Kernel::raise TypeError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
45
45
|
if $tdriver_reporter
|
46
46
|
$new_test_case.set_test_case_execution_log(message) if $new_test_case
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
def tdriver_report_set_test_case_status(status)
|
51
|
-
Kernel::raise
|
51
|
+
Kernel::raise TypeError.new("Argument status was not a String.") unless status.nil? or status.kind_of?(String)
|
52
52
|
if $tdriver_reporter!=nil
|
53
53
|
$tdriver_reporter.set_test_case_user_defined_status(status)
|
54
54
|
end
|
@@ -475,7 +475,10 @@ module TDriverReportCreator
|
|
475
475
|
status='failed' if MobyUtil::Parameter[:report_fail_test_if_files_found]=='true'
|
476
476
|
end
|
477
477
|
end
|
478
|
-
|
478
|
+
|
479
|
+
temp_rec = $new_test_case.video_recording?
|
480
|
+
|
481
|
+
if temp_rec
|
479
482
|
$new_test_case.stop_video_recording
|
480
483
|
end
|
481
484
|
if $tdriver_reporter.test_case_user_defined_status!=nil
|
@@ -490,8 +493,31 @@ module TDriverReportCreator
|
|
490
493
|
end
|
491
494
|
end
|
492
495
|
if(status=='passed')
|
493
|
-
|
494
|
-
|
496
|
+
|
497
|
+
no_activity_videos = ""
|
498
|
+
if MobyUtil::Parameter[:report_check_device_active, 'false']=='true'
|
499
|
+
if temp_rec
|
500
|
+
no_activity_videos = $new_test_case.target_video_alive
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
if no_activity_videos == ""
|
505
|
+
$new_test_case.set_test_case_status($tdriver_reporter.pass_statuses.first)
|
506
|
+
create_test_case_folder($tdriver_reporter.pass_statuses.first)
|
507
|
+
else
|
508
|
+
# switch case to failed status
|
509
|
+
status='failed'
|
510
|
+
$new_test_case.copy_video_capture
|
511
|
+
$new_test_case.update_test_case "The case failed due to video analysis (#{no_activity_videos}) indicating that the target is no longer responding."
|
512
|
+
|
513
|
+
$new_test_case.set_test_case_status($tdriver_reporter.fail_statuses.first)
|
514
|
+
create_test_case_folder($tdriver_reporter.fail_statuses.first)
|
515
|
+
if found_crash_files.to_i > 0
|
516
|
+
$new_test_case.capture_crash_files()
|
517
|
+
end
|
518
|
+
|
519
|
+
end
|
520
|
+
|
495
521
|
end
|
496
522
|
if(status!='passed' && status!='failed')
|
497
523
|
$new_test_case.set_test_case_status($tdriver_reporter.not_run_statuses.first)
|
@@ -39,9 +39,13 @@ module TDriverReportDataPresentation
|
|
39
39
|
puts e.inspect
|
40
40
|
end
|
41
41
|
begin
|
42
|
-
|
42
|
+
|
43
|
+
raise TypeError, "ERROR create_graph_image: Data argument is either nil or not a Hash" if ( data.nil? or !data.kind_of? Hash )
|
44
|
+
|
43
45
|
raise ArgumentError, "ERROR create_graph_image: Values of the data Hash need to be arrays of minimum length 2" if ( !data.values[0].kind_of? Array or data.values[0].length < 2 )
|
44
|
-
|
46
|
+
|
47
|
+
raise TypeError, "ERROR create_graph_image: Filename argument is either missing or not a String" if ( filename.nil? or !filename.kind_of? String )
|
48
|
+
|
45
49
|
g = Gruff::Line.new
|
46
50
|
g.title = title unless title.nil?
|
47
51
|
data.each_key do |signal|
|
@@ -149,4 +153,4 @@ module TDriverReportDataPresentation
|
|
149
153
|
</style>
|
150
154
|
'
|
151
155
|
end
|
152
|
-
end
|
156
|
+
end
|
@@ -49,7 +49,11 @@ class ReportingStatistics
|
|
49
49
|
@total_statistics_arr << ["reboots",0]
|
50
50
|
@total_statistics_arr << ["crashes",0]
|
51
51
|
@total_statistics_arr << ["duration",0]
|
52
|
-
@
|
52
|
+
@total_statistics_arr << ["dump count",0]
|
53
|
+
@total_statistics_arr << ["sent bytes",0]
|
54
|
+
@total_statistics_arr << ["received bytes",0]
|
55
|
+
@total_statistics_arr << ["used mem difference",0]
|
56
|
+
@all_statuses << "reboots" << "crashes" << "duration" << "dump count" << "sent bytes" << "received bytes" << "used mem difference"
|
53
57
|
end
|
54
58
|
|
55
59
|
def generate_statistics_headers()
|
@@ -66,27 +70,16 @@ class ReportingStatistics
|
|
66
70
|
status_heads << "<td><b>Reboots</b></td>"
|
67
71
|
status_heads << "<td><b>Crashes</b></td>"
|
68
72
|
status_heads << "<td><b>Duration</b></td>"
|
73
|
+
status_heads << "<td><b>Dump count</b></td>"
|
74
|
+
status_heads << "<td><b>Sent bytes</b></td>"
|
75
|
+
status_heads << "<td><b>Received bytes</b></td>"
|
76
|
+
status_heads << "<td><b>Used mem</b></td>"
|
69
77
|
status_heads
|
70
78
|
end
|
71
79
|
|
72
|
-
def
|
73
|
-
|
74
|
-
@
|
75
|
-
tc_status=test_case[7]
|
76
|
-
tc_name=test_case[0].to_s.gsub('_',' ')
|
77
|
-
tc_execution=test_case[8].to_i
|
78
|
-
reboots=test_case[2]
|
79
|
-
crashes=test_case[3]
|
80
|
-
tc_link=test_case[11]
|
81
|
-
current_index=0
|
82
|
-
|
83
|
-
duration=test_case[5].to_f
|
84
|
-
total_duration = total_duration + duration
|
85
|
-
|
86
|
-
b_test_in_statistics=false
|
87
|
-
|
88
|
-
current_index=0
|
89
|
-
@total_statistics_arr.each do |total_status|
|
80
|
+
def update_total_execution_statistics(tc_status,reboots,crashes,dump_count,sent_bytes,received_bytes,memory_usage)
|
81
|
+
current_index=0
|
82
|
+
@total_statistics_arr.each do |total_status|
|
90
83
|
if tc_status==total_status[0]
|
91
84
|
@total_statistics_arr[current_index]=[tc_status,total_status[1].to_i+1]
|
92
85
|
end
|
@@ -102,10 +95,26 @@ class ReportingStatistics
|
|
102
95
|
if total_status[0]=="duration"
|
103
96
|
@total_statistics_arr[current_index]=["duration",""]
|
104
97
|
end
|
98
|
+
if total_status[0]=="dump count"
|
99
|
+
@total_statistics_arr[current_index]=["dump count",total_status[1].to_i+dump_count.to_i]
|
100
|
+
end
|
101
|
+
if total_status[0]=="sent bytes"
|
102
|
+
@total_statistics_arr[current_index]=["sent bytes",total_status[1].to_i+sent_bytes.to_i]
|
103
|
+
end
|
104
|
+
if total_status[0]=="received bytes"
|
105
|
+
@total_statistics_arr[current_index]=["received bytes",total_status[1].to_i+received_bytes.to_i]
|
106
|
+
end
|
107
|
+
if total_status[0]=="used mem difference"
|
108
|
+
@total_statistics_arr[current_index]=["used mem difference",""]
|
109
|
+
end
|
105
110
|
current_index+=1
|
106
111
|
end
|
107
|
-
|
108
|
-
|
112
|
+
end
|
113
|
+
|
114
|
+
def update_test_case_execution_statistics(tc_name,tc_status,tc_execution,duration,tc_link,reboots,crashes,dump_count,sent_bytes,received_bytes,memory_usage)
|
115
|
+
b_test_in_statistics=false
|
116
|
+
current_index=0
|
117
|
+
@statistics_arr.each do |total_status|
|
109
118
|
if total_status[1]==tc_status && total_status[0]==tc_name
|
110
119
|
b_test_in_statistics=true
|
111
120
|
@statistics_arr[current_index]=[tc_name,tc_status,total_status[2].to_i+1,tc_execution,tc_link]
|
@@ -126,8 +135,50 @@ class ReportingStatistics
|
|
126
135
|
b_test_in_statistics=true
|
127
136
|
@statistics_arr[current_index]=[tc_name,"duration",duration,tc_execution,tc_link]
|
128
137
|
end
|
138
|
+
if total_status[1]=="dump count" && total_status[0]==tc_name
|
139
|
+
b_test_in_statistics=true
|
140
|
+
@statistics_arr[current_index]=[tc_name,"dump count",total_status[2].to_i+dump_count.to_i,tc_execution,tc_link]
|
141
|
+
end
|
142
|
+
if total_status[1]=="sent bytes" && total_status[0]==tc_name
|
143
|
+
b_test_in_statistics=true
|
144
|
+
@statistics_arr[current_index]=[tc_name,"sent bytes",total_status[2].to_i+sent_bytes.to_i,tc_execution,tc_link]
|
145
|
+
end
|
146
|
+
if total_status[1]=="received bytes" && total_status[0]==tc_name
|
147
|
+
b_test_in_statistics=true
|
148
|
+
@statistics_arr[current_index]=[tc_name,"received bytes",total_status[2].to_i+received_bytes.to_i,tc_execution,tc_link]
|
149
|
+
end
|
150
|
+
if total_status[1]=="used mem difference" && total_status[0]==tc_name
|
151
|
+
b_test_in_statistics=true
|
152
|
+
@statistics_arr[current_index]=[tc_name,"used mem difference",total_status[2].to_i,tc_execution,tc_link]
|
153
|
+
end
|
129
154
|
current_index+=1
|
130
155
|
end
|
156
|
+
b_test_in_statistics
|
157
|
+
end
|
158
|
+
|
159
|
+
def collect_test_case_statistics()
|
160
|
+
total_duration = 0.0
|
161
|
+
@group_test_case_arr.each do |test_case|
|
162
|
+
tc_status=test_case[7]
|
163
|
+
tc_name=test_case[0].to_s.gsub('_',' ')
|
164
|
+
tc_execution=test_case[8].to_i
|
165
|
+
reboots=test_case[2]
|
166
|
+
crashes=test_case[3]
|
167
|
+
tc_link=test_case[11]
|
168
|
+
dump_count=test_case[13].to_i
|
169
|
+
sent_bytes=test_case[14].to_i
|
170
|
+
received_bytes=test_case[15].to_i
|
171
|
+
memory_usage=test_case[6].to_i
|
172
|
+
|
173
|
+
duration=test_case[5].to_f
|
174
|
+
total_duration = total_duration + duration
|
175
|
+
b_test_in_statistics=false
|
176
|
+
|
177
|
+
#Update total statistics
|
178
|
+
update_total_execution_statistics(tc_status,reboots,crashes,dump_count,sent_bytes,received_bytes,memory_usage)
|
179
|
+
|
180
|
+
#Update current test case total statistics
|
181
|
+
b_test_in_statistics=update_test_case_execution_statistics(tc_name,tc_status,tc_execution,duration,tc_link,reboots,crashes,dump_count,sent_bytes,received_bytes,memory_usage)
|
131
182
|
|
132
183
|
if b_test_in_statistics==false
|
133
184
|
@all_statuses.each do |status|
|
@@ -141,6 +192,14 @@ class ReportingStatistics
|
|
141
192
|
@statistics_arr << [tc_name,"total",1,tc_execution,tc_link]
|
142
193
|
elsif status=="duration"
|
143
194
|
@statistics_arr << [tc_name,"duration",duration,tc_execution,tc_link]
|
195
|
+
elsif status=="dump count"
|
196
|
+
@statistics_arr << [tc_name,"dump count",dump_count,tc_execution,tc_link]
|
197
|
+
elsif status=="sent bytes"
|
198
|
+
@statistics_arr << [tc_name,"sent bytes",sent_bytes,tc_execution,tc_link]
|
199
|
+
elsif status=="received bytes"
|
200
|
+
@statistics_arr << [tc_name,"received bytes",received_bytes,tc_execution,tc_link]
|
201
|
+
elsif status=="used mem difference"
|
202
|
+
@statistics_arr << [tc_name,"used mem difference",memory_usage,tc_execution,tc_link]
|
144
203
|
else
|
145
204
|
@statistics_arr << [tc_name,status,0,tc_execution,tc_link]
|
146
205
|
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
|
21
|
+
module TDriverReportJavascript
|
22
|
+
|
23
|
+
def get_expand_collapse_java_script()
|
24
|
+
java_script='<script type="text/javascript">'<<
|
25
|
+
'/* Only set closed if JS-enabled */'<<
|
26
|
+
"document.getElementsByTagName('html')[0].className = 'isJS';"<<
|
27
|
+
'function tog(dt)'<<
|
28
|
+
'{'<<
|
29
|
+
'var display, dd=dt;'<<
|
30
|
+
'/* get dd */'<<
|
31
|
+
"do{ dd = dd.nextSibling } while(dd.tagName!='DD');"<<
|
32
|
+
'toOpen =!dd.style.display;'<<
|
33
|
+
"dd.style.display = toOpen? 'block':'';"<<
|
34
|
+
"dt.getElementsByTagName('span')[0].innerHTML"<<
|
35
|
+
"= toOpen? '<input id=\"Button1\" type=\"button\" value=\"Close\" class=\"btn\" style=\"background-color: #FFFFFF\" />':'<input id=\"Button1\" type=\"button\" value=\"Open\" class=\"btn\" />' ;"<<
|
36
|
+
'}'<<
|
37
|
+
'</script>'
|
38
|
+
java_script
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_table_sorting_java_script()
|
42
|
+
java_script="
|
43
|
+
function TSorter(){
|
44
|
+
var table = Object;
|
45
|
+
var trs = Array;
|
46
|
+
var ths = Array;
|
47
|
+
var curSortCol = Object;
|
48
|
+
var prevSortCol = '3';
|
49
|
+
var sortType = Object;
|
50
|
+
|
51
|
+
function get(){}
|
52
|
+
|
53
|
+
function getCell(index){
|
54
|
+
return trs[index].cells[curSortCol]
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
this.init = function(tableName)
|
59
|
+
{
|
60
|
+
table = document.getElementById(tableName);
|
61
|
+
ths = table.getElementsByTagName(\"th\");
|
62
|
+
for(var i = 0; i < ths.length ; i++)
|
63
|
+
{
|
64
|
+
ths[i].onclick = function()
|
65
|
+
{
|
66
|
+
sort(this);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
return true;
|
70
|
+
};
|
71
|
+
|
72
|
+
|
73
|
+
function sort(oTH)
|
74
|
+
{
|
75
|
+
curSortCol = oTH.cellIndex;
|
76
|
+
sortType = oTH.abbr;
|
77
|
+
trs = table.tBodies[0].getElementsByTagName(\"tr\");
|
78
|
+
|
79
|
+
|
80
|
+
setGet(sortType)
|
81
|
+
|
82
|
+
|
83
|
+
for(var j=0; j<trs.length; j++)
|
84
|
+
{
|
85
|
+
if(trs[j].className == 'detail_row')
|
86
|
+
{
|
87
|
+
closeDetails(j+2);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
// if already sorted just reverse
|
92
|
+
if(prevSortCol == curSortCol)
|
93
|
+
{
|
94
|
+
oTH.className = (oTH.className != 'ascend' ? 'ascend' : 'descend' );
|
95
|
+
reverseTable();
|
96
|
+
}
|
97
|
+
// not sorted - call quicksort
|
98
|
+
else
|
99
|
+
{
|
100
|
+
oTH.className = 'ascend';
|
101
|
+
if(ths[prevSortCol].className != 'exc_cell'){ths[prevSortCol].className = '';}
|
102
|
+
quicksort(0, trs.length);
|
103
|
+
}
|
104
|
+
prevSortCol = curSortCol;
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
function setGet(sortType)
|
109
|
+
{
|
110
|
+
switch(sortType)
|
111
|
+
{
|
112
|
+
case \"link_column\":
|
113
|
+
get = function(index){
|
114
|
+
return getCell(index).firstChild.firstChild.nodeValue;
|
115
|
+
};
|
116
|
+
break;
|
117
|
+
default:
|
118
|
+
get = function(index){ return getCell(index).firstChild.nodeValue;};
|
119
|
+
break;
|
120
|
+
};
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
function exchange(i, j)
|
125
|
+
{
|
126
|
+
if(i == j+1) {
|
127
|
+
table.tBodies[0].insertBefore(trs[i], trs[j]);
|
128
|
+
} else if(j == i+1) {
|
129
|
+
table.tBodies[0].insertBefore(trs[j], trs[i]);
|
130
|
+
} else {
|
131
|
+
var tmpNode = table.tBodies[0].replaceChild(trs[i], trs[j]);
|
132
|
+
if(typeof(trs[i]) == \"undefined\") {
|
133
|
+
table.appendChild(tmpNode);
|
134
|
+
} else {
|
135
|
+
table.tBodies[0].insertBefore(tmpNode, trs[i]);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
function reverseTable()
|
142
|
+
{
|
143
|
+
for(var i = 1; i<trs.length; i++)
|
144
|
+
{
|
145
|
+
table.tBodies[0].insertBefore(trs[i], trs[0]);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
function quicksort(lo, hi)
|
150
|
+
{
|
151
|
+
if(hi <= lo+1) return;
|
152
|
+
|
153
|
+
if((hi - lo) == 2) {
|
154
|
+
if(get(hi-1) > get(lo)) exchange(hi-1, lo);
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
|
158
|
+
var i = lo + 1;
|
159
|
+
var j = hi - 1;
|
160
|
+
|
161
|
+
if(get(lo) > get(i)) exchange(i, lo);
|
162
|
+
if(get(j) > get(lo)) exchange(lo, j);
|
163
|
+
if(get(lo) > get(i)) exchange(i, lo);
|
164
|
+
|
165
|
+
var pivot = get(lo);
|
166
|
+
|
167
|
+
while(true) {
|
168
|
+
j--;
|
169
|
+
while(pivot > get(j)) j--;
|
170
|
+
i++;
|
171
|
+
while(get(i) > pivot) i++;
|
172
|
+
if(j <= i) break;
|
173
|
+
exchange(i, j);
|
174
|
+
}
|
175
|
+
exchange(lo, j);
|
176
|
+
|
177
|
+
if((j-lo) < (hi-j)) {
|
178
|
+
quicksort(lo, j);
|
179
|
+
quicksort(j+1, hi);
|
180
|
+
} else {
|
181
|
+
quicksort(j+1, hi);
|
182
|
+
quicksort(lo, j);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}"
|
186
|
+
java_script
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
|