testability-driver 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -290,12 +290,15 @@ module MobyBehaviour
290
290
  # TODO: merge TestObject#child and SUT#child
291
291
  # == description
292
292
  # Creates a child test object from this SUT. SUT object will be associated as child test objects parent.\n
293
- #
293
+ # \n
294
294
  # [b]NOTE:[/b] Subsequent calls to TestObject#child( rule ) always returns reference to same Testobject:\n
295
295
  # [code]a = sut.child( :type => 'Button', :text => '1' )
296
296
  # b = sut.child( :type => 'Button', :text => '1' )
297
297
  # a.eql?( b ) # => true[/code]
298
- #
298
+ # \n
299
+ # [b]NOTE:[/b] If the parameter 'use_find_object' in tdriver_parameters.xml is true (default), objects with visibleOnScreen value 'false' might be
300
+ # optimized out and not appear in the results.
301
+ # \n
299
302
  # == arguments
300
303
  # attributes
301
304
  # Hash
@@ -1603,7 +1606,8 @@ module MobyBehaviour
1603
1606
  :application_uid => refresh_args[ :id ],
1604
1607
  :sut => self,
1605
1608
  :refresh_arguments => refresh_args,
1606
- :checksum => xml_data_checksum
1609
+ :checksum => xml_data_checksum,
1610
+ :flags => {:useViewCrop=>sut_parameters[ :use_view_crop, 'false' ]}
1607
1611
  }
1608
1612
  )
1609
1613
 
@@ -46,6 +46,7 @@ module MobyBehaviour
46
46
 
47
47
  # == description
48
48
  # Checks if a child test object matching the given criteria can be found, under this application object or test object.
49
+ # NOTE: This won't work with the visibleOnScreen attribute unless you disable the sut parameter use_find_object.
49
50
  #
50
51
  # == arguments
51
52
  # *attributes
@@ -452,6 +452,10 @@ module MobyBehaviour
452
452
  # [code]a = to.child( :type => 'Button', :text => '1' )
453
453
  # b = to.child( :type => 'Button', :text => '1' )
454
454
  # a.eql?( b ) # => true[/code]
455
+ # \n
456
+ # [b]NOTE:[/b] If the parameter 'use_find_object' in tdriver_parameters.xml is true (default), objects with visibleOnScreen value 'false' might be
457
+ # optimized out and not appear in the results.
458
+ # \n
455
459
  # == arguments
456
460
  # attributes
457
461
  # Hash
@@ -501,7 +505,10 @@ module MobyBehaviour
501
505
  end
502
506
 
503
507
  # == description
504
- # Function similar to child, but returns an array of children test objects that meet the given criteria
508
+ # Function similar to child, but returns an array of children test objects that meet the given criteria.
509
+ # \n\n
510
+ # [b]NOTE:[/b] If the parameter 'use_find_object' in tdriver_parameters.xml is true (default), objects with visibleOnScreen value 'false' might be
511
+ # optimized out and not appear in the results.
505
512
  #
506
513
  # == arguments
507
514
  # attributes
@@ -378,6 +378,7 @@ module TDriver
378
378
  def self.parent_test_object_element( test_object )
379
379
 
380
380
  # retrieve parent of current xml element; obj/..
381
+ test_object.refresh #Refresh the test object for identification
381
382
  test_object.xml_data.parent #.parent
382
383
 
383
384
  end
@@ -111,7 +111,11 @@ module MobyUtil
111
111
 
112
112
  begin
113
113
  query_result = @@_connections[ host + db_type + database_name ].dbh.query( query_string ) # identical?
114
- rescue
114
+ rescue
115
+ if @@_mysql
116
+ @@_mysql.close
117
+ @@_mysql=nil
118
+ end
115
119
  #Possible timeout in query attempt to recreate the connection and redo the query
116
120
  dbc.dbh = connect_db( db_type, host, username, password, database_name )
117
121
  @@_connections[ host + db_type + database_name ] = dbc
@@ -187,13 +191,25 @@ module MobyUtil
187
191
  return result
188
192
  end
189
193
 
194
+ # == description
195
+ # Function closes MySQL connection
196
+ #
197
+ def close_db()
198
+
199
+ if @@_mysql
200
+ @@_mysql.close
201
+ @@_mysql=nil
202
+ end
203
+
204
+ end
205
+
190
206
  private
191
207
 
192
208
  # == description
193
209
  # Function establishes a new connection to as sql server and returns it's handle
194
210
  #
195
- def self.connect_db( db_type, host, username, password, database_name )
196
-
211
+ def self.connect_db( db_type, host, username, password, database_name )
212
+
197
213
  # if mysql API and connection are not initialized, then initialize the mysql API
198
214
  if ( db_type == DB_TYPE_MYSQL ) && ( @@_mysql.nil? )
199
215
  require 'mysql'
@@ -201,7 +217,7 @@ module MobyUtil
201
217
  elsif db_type == DB_TYPE_SQLITE
202
218
  require 'sqlite3'
203
219
  end
204
-
220
+
205
221
  begin
206
222
  dbh = @@_mysql.connect( host, username, password, database_name) if db_type == DB_TYPE_MYSQL
207
223
  dbh.query 'SET NAMES utf8' if db_type == DB_TYPE_MYSQL # set the utf8 encoding
@@ -211,8 +227,8 @@ module MobyUtil
211
227
  end
212
228
 
213
229
  return dbh
214
-
215
- end
230
+
231
+ end
216
232
 
217
233
  # enable hoo./base/test_object/factory.rb:king for performance measurement & debug logging
218
234
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
@@ -220,3 +236,5 @@ module MobyUtil
220
236
  end # DBAccess
221
237
 
222
238
  end # MobyUtil
239
+
240
+ at_exit{MobyUtil::DBAccess.instance.close_db}
@@ -479,7 +479,8 @@ module MobyUtil
479
479
  #
480
480
  # == throws
481
481
  #
482
- def self.parse_ts_file(file, column_names_map = {} )
482
+
483
+ def self.parse_ts_file(file, column_names_map = {} )
483
484
  # Read TS file
484
485
  open_file = File.new( file )
485
486
  doc = Nokogiri.XML( open_file )
@@ -500,7 +501,7 @@ module MobyUtil
500
501
  begin
501
502
  nodeId = ""
502
503
  nodeTranslation = ""
503
- nodePlurality = ""
504
+ nodePlurality = "NULL"
504
505
  nodeLengthVar = ""
505
506
  # set nodeId
506
507
  #raise Exception if node.xpath('@id').inner_text() == ""
@@ -512,7 +513,8 @@ module MobyUtil
512
513
  # Parse Numerus(LengthVar), or Numerus or LengthVar or translation direclty
513
514
  if ! node.xpath('.//translation/numerusform').empty?
514
515
  # puts ">>> Numerusform"
515
- plurality = 1
516
+ priority = 1
517
+ plurality = 'NULL'
516
518
  node.xpath('.//translation/numerusform').each do |numerus|
517
519
  nodePlurality = numerus.xpath('@plurality').inner_text()
518
520
  nodePlurality = plurality.to_s if nodePlurality.empty?
@@ -521,15 +523,15 @@ module MobyUtil
521
523
  priority = 1
522
524
  numerus.xpath('.//lengthvariant').each do |lenghtvar|
523
525
  nodeLengthVar = lenghtvar.xpath('@priority').inner_text()
524
- nodeLengthVar = priority.to_s if nodeLengthVar.empty?
526
+ nodeLengthVar = priority.to_s if nodeLengthVar.empty?
525
527
  nodeTranslation = lenghtvar.inner_text()
526
528
  data << [ fname, nodeId, nodeTranslation, nodePlurality, nodeLengthVar ]
527
529
  priority += 1
528
530
  end
529
531
  else
530
532
  nodeTranslation = numerus.inner_text()
531
- data << [ fname, nodeId, nodeTranslation, nodePlurality, nodeLengthVar ]
532
- plurality += 1
533
+ data << [ fname, nodeId, nodeTranslation, nodePlurality, nodeLengthVar = '1' ]
534
+ priority += 1
533
535
  end
534
536
  end
535
537
  elsif ! node.xpath('.//translation/lengthvariant').empty?
@@ -537,7 +539,7 @@ module MobyUtil
537
539
  priority = 1
538
540
  node.xpath('.//translation/lengthvariant').each do |lenghtvar|
539
541
  nodeLengthVar = lenghtvar.xpath('@priority').inner_text()
540
- nodeLengthVar = priority.to_s if nodeLengthVar.empty?
542
+ nodeLengthVar = priority.to_s if nodeLengthVar.empty?
541
543
  nodeTranslation = lenghtvar.inner_text()
542
544
  data << [ fname, nodeId, nodeTranslation, nodePlurality, nodeLengthVar ]
543
545
  priority += 1
@@ -554,7 +556,7 @@ module MobyUtil
554
556
  open_file.close
555
557
  return language, data
556
558
  end
557
-
559
+
558
560
  #
559
561
  # Note: for .loc files the colum mapping is done with the Language code number on the filenames
560
562
  #
@@ -661,26 +663,35 @@ module MobyUtil
661
663
  end
662
664
  # INSERT new data
663
665
  case db_connection.db_type
664
- when "mysql"
665
- begin
666
- # Formatting (seems like there is no length limit for the insert string)
667
- insert_values = ""
668
- data.each do |fname, source, translation, plurality, lengthvar|
669
- # Escape ` and ' and " and other restricted characters in SQL (prevent SQL injections
670
- source = source.gsub(/([\'\"\`\;\&])/){|s| "\\" + s}
671
- translation = (translation != nil) ? translation.gsub(/([\'\"\`\;\&])/){|s| "\\" + s} : ""
672
- insert_values += "('" + fname + "', '" + source + "', '" + translation + "', '" + plurality + "', '" + lengthvar + "'), "
673
- end
674
- insert_values[-2] = ' ' unless insert_values == "" # replace last ',' with ';'
675
- # INSERT Query
676
- query_string = "INSERT INTO `" + table_name + "` (FNAME, LNAME, `" + language + "`, `PLURALITY`, `LENGTHVAR`) VALUES " + insert_values +
677
- "ON DUPLICATE KEY UPDATE fname = VALUES(fname), lname = VALUES(lname), `" + language + "` = VALUES(`" + language + "`) ;"
678
- MobyUtil::DBAccess.query( db_connection, query_string )
679
- sql_file.write( query_string + "\n" ) if record_sql
680
- rescue Exception => e
681
- puts e.inspect
682
- puts e.backtrace.join("\n")
683
- end
666
+ when "mysql"
667
+ insert_values = ""
668
+
669
+ begin
670
+ # Formatting (seems like there is no length limit for the insert string)
671
+ data.each do |fname, source, translation, plurality, lengthvar|
672
+ # Escape ` and ' and " and other restricted characters in SQL (prevent SQL injections
673
+ source = source.gsub(/([\'\"\`\;\&])/){|s| "\\" + s}
674
+ translation = (translation != nil) ? translation.gsub(/([\'\"\`\;\&])/){|s| "\\" + s} : ""
675
+ if plurality=='NULL'
676
+ insert_values += "('" + fname + "', '" + source + "', '" + translation + "', NULL, '" + lengthvar + "'), "
677
+ else
678
+ insert_values += "('" + fname + "', '" + source + "', '" + translation + "', '" + plurality + "', '" + lengthvar + "'), "
679
+ end
680
+ end
681
+ insert_values[-2] = ' ' unless insert_values == "" # replace last ',' with ';'
682
+ # INSERT Query
683
+ query_string = "INSERT INTO `" + table_name + "` (FNAME, LNAME, `" + language + "`, `PLURALITY`, `LENGTHVAR`) VALUES " + insert_values +
684
+ "ON DUPLICATE KEY UPDATE fname = VALUES(fname), lname = VALUES(lname), `" + language + "` = VALUES(`" + language + "`) ;"
685
+ MobyUtil::DBAccess.query( db_connection, query_string )
686
+ sql_file.write( query_string + "\n" ) if record_sql
687
+
688
+ rescue Exception => e
689
+ puts e.message
690
+ puts e.backtrace
691
+ puts ''
692
+ sql_file.write( "Error: #{e.message}: #{query_string}" + "\n" ) if record_sql
693
+ end
694
+
684
695
  when "sqlite"
685
696
  begin
686
697
  # Formatting (limit on the length of the Insert String! So multiple Insets
@@ -724,7 +735,7 @@ module MobyUtil
724
735
  # Used only on .ts files
725
736
  def self.parseFName(file)
726
737
  #(wordlist matching)
727
- words = ["ar", "bg", "ca", "cs", "da", "de", "el", "en", "english-gb", "(apac)", "(apaccn)", "(apachk)", "(apactw)", "japanese", "thai", "us", "es", "419", "et", "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "mr", "ms", "nb", "nl", "pl", "pt", "br", "ro", "ru", "sk", "sl", "sr", "sv", "th", "tl", "tr", "uk", "ur", "us", "vi", "zh", "hk", "tw", "no", "gb", "cn"]
738
+ words = ["ar", "bg", "ca", "cs", "da", "de", "el", "en", "english-gb", "(apac)", "(apaccn)", "(apachk)", "(apactw)", "japanese", "thai", "us", "es", "419", "et", "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "mr", "ms", "nb", "nl", "pl", "pt", "br", "ro", "ru", "sk", "sl", "sr", "sv", "th", "tl", "tr", "uk", "ur", "us", "vi", "zh", "hk", "tw", "no", "gb", "cn", "kk"]
728
739
 
729
740
  fname = file.split('/').last
730
741
  fname.gsub!(".ts"){|s| ""}
@@ -18,4 +18,4 @@
18
18
  ############################################################################
19
19
 
20
20
 
21
- ENV['TDRIVER_VERSION'] = '1.4.0'
21
+ ENV['TDRIVER_VERSION'] = '1.4.1'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testability-driver
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 0
10
- version: 1.4.0
9
+ - 1
10
+ version: 1.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Testability Driver team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin/
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-11 00:00:00 +02:00
18
+ date: 2011-12-02 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency