sikuli 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -21,12 +21,15 @@ Usage
21
21
  require 'java'
22
22
  require 'sikuli'
23
23
 
24
+ Sikuli.addImagePath("#{Dir.pwd}/images/")
25
+
24
26
  screen = Sikuli::Screen.new
25
27
  screen.click(10, 10) # should open your apple menu
26
28
 
27
29
  app = Sikuli::App.new("iPhone Simulator")
28
- app.window.click('ui_element.png')
30
+ app.window.click('ui_element.png') if app.window.exists?('ui_element.png')
29
31
 
30
- if !app.window.exists?('other_ui_element.png')
31
- raise "Error!"
32
- end
32
+ Examples
33
+ --------
34
+
35
+ * [Cucumber Suite](https://github.com/chaslemley/cucumber_sikuli)
@@ -4,8 +4,11 @@ require "sikuli/version"
4
4
  require "sikuli/app"
5
5
  require "sikuli/region"
6
6
  require "sikuli/screen"
7
+ require "sikuli/key_code"
7
8
 
8
9
  module Sikuli
10
+ include KeyCode
11
+
9
12
  def self.getImagePath
10
13
  paths = java.lang.System.getProperty("SIKULI_IMAGE_PATH") || ""
11
14
  paths.split(":")
@@ -0,0 +1,14 @@
1
+ module KeyCode
2
+ KEY_CMD = java.awt.event.InputEvent::META_MASK
3
+ KEY_SHIFT = java.awt.event.InputEvent::SHIFT_MASK
4
+ KEY_CTRL = java.awt.event.InputEvent::CTRL_MASK
5
+ KEY_ALT = java.awt.event.InputEvent::ALT_MASK
6
+
7
+ KEY_BACKSPACE = "\u0008"
8
+ KEY_RETURN = "\n"
9
+
10
+ UP_ARROW = nil
11
+ LEFT_ARROW = "\ue003"
12
+ DOWN_ARROW = nil
13
+ RIGHT_ARROW = nil
14
+ end
@@ -1,7 +1,7 @@
1
1
  module Sikuli
2
2
  module Typeable
3
- def type(text)
4
- @java_obj.type(nil, text, 0)
3
+ def type(text, modifier = 0)
4
+ @java_obj.type(nil, text, modifier)
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module Sikuli
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sikuli::Region, "#Clickable" do
4
+ before(:all) do
5
+ #open the file 'test_area.jpg' in Preview at zoom level 0
6
+ @region = setup_test_area
7
+ end
8
+
9
+ it "should perform a click at 10, 10" do
10
+ lambda { @region.click(12, 12) }.should_not raise_error
11
+ end
12
+
13
+ it "should perform a double click 10, 1040" do
14
+ lambda { @region.doubleClick(12, 491) }.should_not raise_error
15
+ end
16
+
17
+ it "should perform a double click on an image" do
18
+ lambda { @region.doubleClick("smiley_face.png") }.should_not raise_error
19
+ end
20
+
21
+ it "should perform a drag and drop" do
22
+ lambda { @region.dragDrop(12, 12, 491, 491) }.should_not raise_error
23
+ end
24
+
25
+ it "should perform a click on an image" do
26
+ lambda { @region.click("smiley_face.png") }.should_not raise_error
27
+ end
28
+
29
+ it "should not perform a click on an image that is outside of the region" do
30
+ lambda { @region.click("apple.png")}.should raise_error
31
+ end
32
+ end
@@ -14,62 +14,4 @@ describe Sikuli::Region, 'when initialzed with a sikuli region' do
14
14
  its(:y) { should == 16 }
15
15
  its(:width) { should == 251 }
16
16
  its(:height) { should == 401 }
17
- end
18
-
19
- describe Sikuli::Region, "#Clickable" do
20
- before(:all) do
21
- #open the file 'test_area.jpg' in Preview at zoom level 0
22
- @region = setup_test_area
23
- end
24
-
25
- it "should perform a click at 10, 10" do
26
- lambda { @region.click(12, 12) }.should_not raise_error
27
- end
28
-
29
- it "should perform a double click 10, 1040" do
30
- lambda { @region.doubleClick(12, 491) }.should_not raise_error
31
- end
32
-
33
- it "should perform a double click on an image" do
34
- lambda { @region.doubleClick("smiley_face.png") }.should_not raise_error
35
- end
36
-
37
- it "should perform a drag and drop" do
38
- lambda { @region.dragDrop(12, 12, 491, 491) }.should_not raise_error
39
- end
40
-
41
- it "should perform a click on an image" do
42
- lambda { @region.click("smiley_face.png") }.should_not raise_error
43
- end
44
-
45
- it "should not perform a click on an image that is outside of the region" do
46
- lambda { @region.click("apple.png")}.should raise_error
47
- end
48
- end
49
-
50
- describe Sikuli::Region, "#Searchable" do
51
- before(:all) do
52
- #open the file 'test_area.jpg' in Preview at zoom level 0
53
- @region = setup_test_area
54
- end
55
-
56
- it "should find an image within the region" do
57
- @region.find("smiley_face.png").should_not be_nil
58
- end
59
-
60
- it "should return a region containing the found image" do
61
- @region.find("smiley_face.png").should be_an_instance_of Sikuli::Region
62
- end
63
-
64
- it "should not find an image that is not in the region" do
65
- lambda { @region.find("apple.png") }.should raise_error
66
- end
67
-
68
- it "should return true if the image is found" do
69
- @region.exists?("smiley_face.png").should be_true
70
- end
71
-
72
- it "should return false if the image is not found" do
73
- @region.exists?("apple.png").should be_false
74
- end
75
17
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sikuli::Region, "#Searchable" do
4
+ before(:all) do
5
+ #open the file 'test_area.jpg' in Preview at zoom level 0
6
+ @region = setup_test_area
7
+ end
8
+
9
+ it "should find an image within the region" do
10
+ @region.find("smiley_face.png").should_not be_nil
11
+ end
12
+
13
+ it "should return a region containing the found image" do
14
+ @region.find("smiley_face.png").should be_an_instance_of Sikuli::Region
15
+ end
16
+
17
+ it "should not find an image that is not in the region" do
18
+ lambda { @region.find("apple.png") }.should raise_error
19
+ end
20
+
21
+ it "should return true if the image is found" do
22
+ @region.exists?("smiley_face.png").should be_true
23
+ end
24
+
25
+ it "should return false if the image is not found" do
26
+ @region.exists?("apple.png").should be_false
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sikuli::Region, "#Typeable" do
4
+ before(:all) do
5
+ app = Sikuli::App.new("TextMate")
6
+ app.focus
7
+ @region = app.window
8
+ end
9
+
10
+ context "modifying text input with" do
11
+ it "apple key" do
12
+ @region.type("n", Sikuli::KEY_CMD)
13
+ end
14
+
15
+ it "shift key" do
16
+ @region.type("this should be lower case")
17
+ @region.type("this should be upper case", Sikuli::KEY_SHIFT)
18
+ end
19
+ end
20
+
21
+ context "unicode characters" do
22
+ # tell JRuby to run in 1.9 mode
23
+ # http://stackoverflow.com/questions/4755900/how-to-make-jruby-1-6-default-to-ruby-1-9
24
+ it("backspace") { @region.type(Sikuli::KEY_BACKSPACE * 50) }
25
+ it("return") { @region.type(Sikuli::KEY_RETURN) }
26
+ xit("up arrow") { @region.type(Sikuli::UP_ARROW) }
27
+ it("left arrow") { @region.type(Sikuli::LEFT_ARROW) }
28
+ it("down arrow") { @region.type(Sikuli::DOWN_ARROW) }
29
+ it("right arrow") { @region.type(Sikuli::RIGHT_ARROW) }
30
+ end
31
+ end
@@ -10,14 +10,6 @@ describe Sikuli, "image path" do
10
10
  Sikuli.getImagePath().should == ['/Users/images/']
11
11
  end
12
12
 
13
- it "should allow logging to be turned off" do
14
- Sikuli.logging = false
15
-
16
- org.sikuli.script::Settings.InfoLogs.should be_false
17
- org.sikuli.script::Settings.ActionLogs.should be_false
18
- org.sikuli.script::Settings.DebugLogs.should be_false
19
- end
20
-
21
13
  it "should allow logging to be turned on" do
22
14
  Sikuli.logging = true
23
15
 
@@ -25,4 +17,12 @@ describe Sikuli, "image path" do
25
17
  org.sikuli.script::Settings.ActionLogs.should be_true
26
18
  org.sikuli.script::Settings.DebugLogs.should be_true
27
19
  end
20
+
21
+ it "should allow logging to be turned off" do
22
+ Sikuli.logging = false
23
+
24
+ org.sikuli.script::Settings.InfoLogs.should be_false
25
+ org.sikuli.script::Settings.ActionLogs.should be_false
26
+ org.sikuli.script::Settings.DebugLogs.should be_false
27
+ end
28
28
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sikuli
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chas Lemley
@@ -41,6 +41,7 @@ files:
41
41
  - lib/sikuli.rb
42
42
  - lib/sikuli/app.rb
43
43
  - lib/sikuli/clickable.rb
44
+ - lib/sikuli/key_code.rb
44
45
  - lib/sikuli/region.rb
45
46
  - lib/sikuli/screen.rb
46
47
  - lib/sikuli/searchable.rb
@@ -49,8 +50,11 @@ files:
49
50
  - lib/sikuli/version.rb
50
51
  - sikuli.gemspec
51
52
  - spec/sikuli/app_spec.rb
53
+ - spec/sikuli/clickable_spec.rb
52
54
  - spec/sikuli/region_spec.rb
53
55
  - spec/sikuli/screen_spec.rb
56
+ - spec/sikuli/searchable_spec.rb
57
+ - spec/sikuli/typeable_spec.rb
54
58
  - spec/sikuli_spec.rb
55
59
  - spec/spec_helper.rb
56
60
  - spec/support/images/.DS_Store
@@ -87,8 +91,11 @@ specification_version: 3
87
91
  summary: Ruby wrapper for Sikuli GUI automation library
88
92
  test_files:
89
93
  - spec/sikuli/app_spec.rb
94
+ - spec/sikuli/clickable_spec.rb
90
95
  - spec/sikuli/region_spec.rb
91
96
  - spec/sikuli/screen_spec.rb
97
+ - spec/sikuli/searchable_spec.rb
98
+ - spec/sikuli/typeable_spec.rb
92
99
  - spec/sikuli_spec.rb
93
100
  - spec/spec_helper.rb
94
101
  - spec/support/images/.DS_Store