soda 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/Soda.rb +83 -0
  2. data/lib/SodaElements.xml +12 -1
  3. metadata +4 -4
data/lib/Soda.rb CHANGED
@@ -1632,6 +1632,86 @@ class Soda
1632
1632
  end
1633
1633
  end
1634
1634
 
1635
+ ###############################################################################
1636
+ ###############################################################################
1637
+ def eventDialog(event)
1638
+ win_handle = nil
1639
+
1640
+ if (@current_os !~ /windows/i)
1641
+ @rep.ReportFailure("Using SODA dialog command on unsupported os:"+
1642
+ " '#{@current_os}'!\n")
1643
+ return -1
1644
+ end
1645
+
1646
+ if (!event.key?('title'))
1647
+ @rep.ReportFailure("SODA: dialog command is missing the 'title' "+
1648
+ "attribute!\n")
1649
+ return -1
1650
+ end
1651
+
1652
+ PrintDebug("Trying to connect to dialog: title => '#{event['title']}'.\n")
1653
+ for i in 0..10 do
1654
+ win_handle = @autoit.WinGetHandle(event['title'])
1655
+ if (win_handle.empty? || win_handle.length < 1)
1656
+ win_handle = nil
1657
+ sleep(1)
1658
+ else
1659
+ PrintDebug("Found dialog window handle: '#{win_handle}'.\n")
1660
+ break
1661
+ end
1662
+ end
1663
+
1664
+ if (win_handle == nil)
1665
+ @rep.ReportFailure("Failed to find dialog by title => "+
1666
+ "'#{event['title']}'!\n")
1667
+ return -1
1668
+ end
1669
+
1670
+ if (!event.key?('children'))
1671
+ return 0
1672
+ end
1673
+
1674
+ event['children'].each do |child|
1675
+ case (child['do'])
1676
+ when "sendkey"
1677
+ @autoit.WinActivate(event['title'], nil)
1678
+ sleep(1)
1679
+ @autoit.Send(child['key'])
1680
+ when "assert"
1681
+ sleep(1)
1682
+ @autoit.WinActivate(event['title'], nil)
1683
+ sleep(1)
1684
+ @autoit.Send("^a")
1685
+ sleep(1)
1686
+ @autoit.Send("^c")
1687
+ sleep(1)
1688
+ tmp = @autoit.ClipGet()
1689
+ if (tmp.empty? || tmp.length < 1)
1690
+ @rep.ReportFailure("Failed to get text from dialog!\n")
1691
+ next
1692
+ end
1693
+
1694
+ if (SodaUtils.isRegex(child['value']))
1695
+ child['value'] = stringToRegex(child['value'])
1696
+ match = child['value'].match(tmp)
1697
+ if (match == nil)
1698
+ @rep.ReportFailure("Falied to match regex: "+
1699
+ "'#{child['value']}' to dialog text '#{tmp}'"+
1700
+ "!\n")
1701
+ next
1702
+ else
1703
+ @rep.Assert(true, "Matched Regex: '#{child['value']}'"+
1704
+ " to dialog text.\n")
1705
+ end
1706
+ else
1707
+ @rep.Assert(child['value'] == tmp, "Checking that dialog"+
1708
+ " matches value: '#{child['value']}'.\n")
1709
+ end
1710
+ end
1711
+ end
1712
+ end
1713
+
1714
+
1635
1715
  ###############################################################################
1636
1716
  ###############################################################################
1637
1717
  def eventRuby(event)
@@ -2321,6 +2401,9 @@ JSCode
2321
2401
  when "breakexit"
2322
2402
  @breakExit = true
2323
2403
  next
2404
+ when "dialog"
2405
+ eventDialog(event)
2406
+ next
2324
2407
  when "whitelist"
2325
2408
  eventWhiteList(event)
2326
2409
  next
data/lib/SodaElements.xml CHANGED
@@ -694,7 +694,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
694
694
  <soda_attributes>
695
695
  <accessor type="boolen">alwaysrun</accessor>
696
696
  </soda_attributes>
697
-
698
697
  </exception>
698
+
699
+ <dialog>
700
+ <soda_attributes>
701
+ <accessor type="string">title</accessor>
702
+ </soda_attributes>
703
+ </dialog>
704
+
705
+ <assert>
706
+ <soda_attributes>
707
+ <accessor type="string">assert</accessor>
708
+ </soda_attributes>
709
+ </assert>
699
710
  </soda>
700
711
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soda
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Trampus Richmond
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-05 00:00:00 -07:00
18
+ date: 2010-11-09 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency