bubble-wrap 1.2.0 → 1.3.0.osx

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.
Files changed (79) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +4 -2
  3. data/Gemfile.lock +1 -1
  4. data/README.md +217 -7
  5. data/Rakefile +23 -2
  6. data/lib/bubble-wrap/camera.rb +10 -6
  7. data/lib/bubble-wrap/core.rb +14 -1
  8. data/lib/bubble-wrap/ext/motion_project_app.rb +8 -0
  9. data/lib/bubble-wrap/font.rb +3 -1
  10. data/lib/bubble-wrap/http.rb +2 -0
  11. data/lib/bubble-wrap/loader.rb +17 -2
  12. data/lib/bubble-wrap/location.rb +9 -6
  13. data/lib/bubble-wrap/media.rb +10 -6
  14. data/lib/bubble-wrap/test.rb +6 -1
  15. data/lib/bubble-wrap/ui.rb +5 -2
  16. data/lib/bubble-wrap/version.rb +2 -7
  17. data/motion/core.rb +6 -1
  18. data/motion/core/app.rb +3 -64
  19. data/motion/core/device.rb +0 -55
  20. data/motion/core/device/{camera.rb → ios/camera.rb} +0 -0
  21. data/motion/core/device/{camera_wrapper.rb → ios/camera_wrapper.rb} +0 -0
  22. data/motion/core/device/ios/screen.rb +75 -0
  23. data/motion/core/device/osx/screen.rb +18 -0
  24. data/motion/core/device/screen.rb +1 -69
  25. data/motion/core/ios/app.rb +71 -0
  26. data/motion/core/ios/device.rb +59 -0
  27. data/motion/core/osx/app.rb +15 -0
  28. data/motion/core/osx/device.rb +6 -0
  29. data/motion/core/string.rb +3 -2
  30. data/motion/http.rb +0 -364
  31. data/motion/http/query.rb +367 -0
  32. data/motion/http/response.rb +32 -0
  33. data/motion/test_suite_delegate.rb +58 -0
  34. data/motion/ui/ui_alert_view.rb +169 -0
  35. data/motion/ui/ui_bar_button_item.rb +55 -53
  36. data/motion/util/constants.rb +34 -32
  37. data/samples/alert/.gitignore +16 -0
  38. data/samples/alert/Gemfile +3 -0
  39. data/samples/alert/Rakefile +10 -0
  40. data/samples/alert/app/app_delegate.rb +8 -0
  41. data/samples/alert/app/controllers/alert_view_controller.rb +74 -0
  42. data/samples/alert/resources/Default-568h@2x.png +0 -0
  43. data/samples/alert/spec/main_spec.rb +9 -0
  44. data/samples/media/.gitignore +16 -0
  45. data/samples/media/Rakefile +11 -0
  46. data/samples/media/app/app_delegate.rb +8 -0
  47. data/samples/media/app/controllers/play_controller.rb +46 -0
  48. data/samples/media/resources/Default-568h@2x.png +0 -0
  49. data/samples/media/resources/test.mp3 +0 -0
  50. data/samples/media/spec/main_spec.rb +9 -0
  51. data/samples/osx/Gemfile +3 -0
  52. data/samples/osx/Gemfile.lock +10 -0
  53. data/samples/osx/Rakefile +11 -0
  54. data/samples/osx/app/app_delegate.rb +69 -0
  55. data/samples/osx/app/menu.rb +108 -0
  56. data/samples/osx/resources/Credits.rtf +29 -0
  57. data/samples/osx/spec/main_spec.rb +9 -0
  58. data/spec/motion/core/app_spec.rb +5 -164
  59. data/spec/motion/core/device/{camera_spec.rb → ios/camera_spec.rb} +0 -0
  60. data/spec/motion/core/device/{camera_wrapper_spec.rb → ios/camera_wrapper_spec.rb} +0 -0
  61. data/spec/motion/core/device/ios/device_spec.rb +74 -0
  62. data/spec/motion/core/device/{screen_spec.rb → ios/screen_spec.rb} +2 -1
  63. data/spec/motion/core/device/osx/screen_spec.rb +26 -0
  64. data/spec/motion/core/device_spec.rb +0 -71
  65. data/spec/motion/core/ios/app_spec.rb +180 -0
  66. data/spec/motion/core/kvo_spec.rb +23 -7
  67. data/spec/motion/core/ns_index_path_spec.rb +10 -2
  68. data/spec/motion/core/osx/app_spec.rb +15 -0
  69. data/spec/motion/core/string_spec.rb +11 -5
  70. data/spec/motion/core_spec.rb +13 -2
  71. data/spec/motion/http/query_spec.rb +731 -0
  72. data/spec/motion/http/response_spec.rb +44 -0
  73. data/spec/motion/http_spec.rb +0 -722
  74. data/spec/motion/{core → ui}/gestures_spec.rb +0 -0
  75. data/spec/motion/ui/ui_alert_view_spec.rb +1188 -0
  76. data/spec/motion/{core → ui}/ui_bar_button_item_spec.rb +80 -24
  77. data/spec/motion/{core → ui}/ui_control_spec.rb +0 -0
  78. data/spec/motion/util/constants_spec.rb +4 -4
  79. metadata +86 -26
@@ -0,0 +1,74 @@
1
+ describe BubbleWrap::Device do
2
+ describe "iOS" do
3
+ describe 'on iPhone' do
4
+ before do
5
+ @idiom = UIUserInterfaceIdiomPhone
6
+ end
7
+
8
+ describe '.iphone?' do
9
+ it 'returns true' do
10
+ BW::Device.iphone?(@idiom).should == true
11
+ end
12
+ end
13
+
14
+ describe '.ipad?' do
15
+ it 'returns false' do
16
+ BW::Device.ipad?(@idiom).should == false
17
+ end
18
+ end
19
+
20
+ describe '.long_screen?' do
21
+ it 'returns true if screen is wide' do
22
+ BW::Device.long_screen?(@idiom, 568.0).should == true
23
+ end
24
+
25
+ it 'returns false if screen is not wide' do
26
+ BW::Device.long_screen?(@idiom, 480.0).should == false
27
+ end
28
+ end
29
+ end
30
+
31
+ describe 'on iPad' do
32
+ before do
33
+ @idiom = UIUserInterfaceIdiomPad
34
+ end
35
+
36
+ describe '.iphone?' do
37
+ it 'returns false' do
38
+ BW::Device.iphone?(@idiom).should == false
39
+ end
40
+ end
41
+
42
+ describe '.ipad?' do
43
+ it 'returns true' do
44
+ BW::Device.ipad?(@idiom).should == true
45
+ end
46
+ end
47
+
48
+ describe '.long_screen?' do
49
+ it 'always not a widescreen' do
50
+ BW::Device.long_screen?(@idiom, 1024.0).should == false
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '.simulator?' do
56
+ it 'returns true' do
57
+ BW::Device.simulator?.should == true
58
+ end
59
+ end
60
+
61
+ describe '.ios_version' do
62
+ it 'returns true' do
63
+ # exact value depends on system where specs run. 4.0 seems like a safe guess
64
+ BW::Device.ios_version.should > '4.0'
65
+ end
66
+ end
67
+
68
+ describe '.orientation' do
69
+ it 'delegates to BubbleWrap::Screen.orientation' do
70
+ BW::Device.orientation.should == BW::Device::Screen.orientation
71
+ end
72
+ end
73
+ end
74
+ end
@@ -1,5 +1,5 @@
1
1
  describe BubbleWrap::Device::Screen do
2
-
2
+ describe "iOS" do
3
3
  describe 'on retina enabled screen' do
4
4
  before do
5
5
  @screen = Object.new.tap do |o|
@@ -157,3 +157,4 @@ describe BubbleWrap::Device::Screen do
157
157
  end
158
158
  end
159
159
  end
160
+ end
@@ -0,0 +1,26 @@
1
+ describe BubbleWrap::Device::Screen do
2
+ describe "OS X" do
3
+ describe 'on retina enabled screen' do
4
+ before do
5
+ @screen = Object.new.tap do |o|
6
+ def o.respondsToSelector(selector)
7
+ return true if selector == 'backingScaleFactor'
8
+ NSScreen.mainScreen.respondsToSelector(selector)
9
+ end
10
+ def o.backingScaleFactor
11
+ 2.0
12
+ end
13
+ def o.method_missing(*args)
14
+ NSScreen.mainScreen.send(*args)
15
+ end
16
+ end
17
+ end
18
+
19
+ describe '.retina?' do
20
+ it 'returns true' do
21
+ BW::Device::Screen.retina?(@screen).should == true
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,70 +1,5 @@
1
1
  describe BubbleWrap::Device do
2
2
 
3
- describe 'on iPhone' do
4
- before do
5
- @idiom = UIUserInterfaceIdiomPhone
6
- end
7
-
8
- describe '.iphone?' do
9
- it 'returns true' do
10
- BW::Device.iphone?(@idiom).should == true
11
- end
12
- end
13
-
14
- describe '.ipad?' do
15
- it 'returns false' do
16
- BW::Device.ipad?(@idiom).should == false
17
- end
18
- end
19
-
20
- describe '.long_screen?' do
21
- it 'returns true if screen is wide' do
22
- BW::Device.long_screen?(@idiom, 568.0).should == true
23
- end
24
-
25
- it 'returns false if screen is not wide' do
26
- BW::Device.long_screen?(@idiom, 480.0).should == false
27
- end
28
- end
29
- end
30
-
31
- describe 'on iPad' do
32
- before do
33
- @idiom = UIUserInterfaceIdiomPad
34
- end
35
-
36
- describe '.iphone?' do
37
- it 'returns false' do
38
- BW::Device.iphone?(@idiom).should == false
39
- end
40
- end
41
-
42
- describe '.ipad?' do
43
- it 'returns true' do
44
- BW::Device.ipad?(@idiom).should == true
45
- end
46
- end
47
-
48
- describe '.long_screen?' do
49
- it 'always not a widescreen' do
50
- BW::Device.long_screen?(@idiom, 1024.0).should == false
51
- end
52
- end
53
- end
54
-
55
- describe '.simulator?' do
56
- it 'returns true' do
57
- BW::Device.simulator?.should == true
58
- end
59
- end
60
-
61
- describe '.ios_version' do
62
- it 'returns true' do
63
- # exact value depends on system where specs run. 4.0 seems like a safe guess
64
- BW::Device.ios_version.should > '4.0'
65
- end
66
- end
67
-
68
3
  describe '.screen' do
69
4
  it 'return BubbleWrap::Screen' do
70
5
  BW::Device.screen.should == BW::Device::Screen
@@ -76,10 +11,4 @@ describe BubbleWrap::Device do
76
11
  BW::Device.retina?.should == BW::Device::Screen.retina?
77
12
  end
78
13
  end
79
-
80
- describe '.orientation' do
81
- it 'delegates to BubbleWrap::Screen.orientation' do
82
- BW::Device.orientation.should == BW::Device::Screen.orientation
83
- end
84
- end
85
14
  end
@@ -0,0 +1,180 @@
1
+ describe BubbleWrap::App do
2
+ describe "iOS" do
3
+ describe '.alert' do
4
+ after do
5
+ @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false)
6
+ end
7
+
8
+ describe "with only one string argument" do
9
+ before do
10
+ @alert = App.alert('1.21 Gigawatts!')
11
+ end
12
+
13
+ it 'returns an alert' do
14
+ @alert.class.should == BW::UIAlertView
15
+ end
16
+
17
+ it 'is displaying the correct title' do
18
+ @alert.title.should == '1.21 Gigawatts!'
19
+ end
20
+
21
+ describe 'cancelButton' do
22
+ it 'is present' do
23
+ @alert.cancelButtonIndex.should == 0
24
+ end
25
+
26
+ it 'has the correct title' do
27
+ @alert.buttonTitleAtIndex(@alert.cancelButtonIndex).should == 'OK'
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "with only two string arguments" do
33
+ before do
34
+ @alert = App.alert('1.21 Gigawatts!', 'Great Scott!')
35
+ end
36
+
37
+ it 'returns an alert' do
38
+ @alert.class.should == BW::UIAlertView
39
+ end
40
+
41
+ it 'is displaying the correct title' do
42
+ @alert.title.should == '1.21 Gigawatts!'
43
+ end
44
+
45
+ describe 'cancelButton' do
46
+ it 'is present' do
47
+ @alert.cancelButtonIndex.should == 0
48
+ end
49
+
50
+ it 'has the correct title' do
51
+ @alert.buttonTitleAtIndex(@alert.cancelButtonIndex).should == 'Great Scott!'
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "with variable args" do
57
+ before do
58
+ @alert = App.alert('1.21 Gigawatts!', cancel_button_title: 'Great Scott!',
59
+ message: 'Some random message')
60
+ end
61
+
62
+ it 'returns an alert' do
63
+ @alert.class.should == BW::UIAlertView
64
+ end
65
+
66
+ it 'is displaying the correct title' do
67
+ @alert.title.should == '1.21 Gigawatts!'
68
+ end
69
+
70
+ it 'is displaying the correct message' do
71
+ @alert.message.should == 'Some random message'
72
+ end
73
+
74
+ describe 'cancelButton' do
75
+ it 'is present' do
76
+ @alert.cancelButtonIndex.should == 0
77
+ end
78
+
79
+ it 'has the correct title' do
80
+ @alert.buttonTitleAtIndex(@alert.cancelButtonIndex).should == 'Great Scott!'
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "with a block" do
86
+ before do
87
+ @alert = App.alert('1.21 Gigawatts!') do |alert|
88
+ alert.message = 'My message!!'
89
+ end
90
+ end
91
+
92
+ it 'returns an alert' do
93
+ @alert.class.should == BW::UIAlertView
94
+ end
95
+
96
+ it 'is displaying the correct title' do
97
+ @alert.title.should == '1.21 Gigawatts!'
98
+ end
99
+
100
+ it 'is displaying the correct message' do
101
+ @alert.message.should == 'My message!!'
102
+ end
103
+
104
+ describe 'cancelButton' do
105
+ it 'is present' do
106
+ @alert.cancelButtonIndex.should == 0
107
+ end
108
+
109
+ it 'has the correct title' do
110
+ @alert.buttonTitleAtIndex(@alert.cancelButtonIndex).should == 'OK'
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ describe '.frame' do
117
+ it 'returns Application Frame' do
118
+ App.frame.should == UIScreen.mainScreen.applicationFrame
119
+ end
120
+ end
121
+
122
+ describe '.bounds' do
123
+ it 'returns Main Screen bounds' do
124
+ App.bounds.should == UIScreen.mainScreen.bounds
125
+ end
126
+ end
127
+
128
+
129
+ describe '.delegate' do
130
+ it 'returns a TestSuiteDelegate' do
131
+ App.delegate.should == UIApplication.sharedApplication.delegate
132
+ end
133
+ end
134
+
135
+ describe '.shared' do
136
+ it 'returns UIApplication.sharedApplication' do
137
+ App.shared.should == UIApplication.sharedApplication
138
+ end
139
+ end
140
+
141
+ describe '.window' do
142
+ it 'returns UIApplication.sharedApplication.keyWindow' do
143
+ App.window.should == UIApplication.sharedApplication.keyWindow
144
+ end
145
+ end
146
+
147
+ describe '.run_after' do
148
+ class DelayedRunAfterTest; attr_accessor :test_value end
149
+
150
+ it 'should run a block after the provided delay' do
151
+ @test_obj = DelayedRunAfterTest.new
152
+
153
+ App.run_after(0.1){ @test_obj.test_value = true }
154
+ wait_for_change(@test_obj, 'test_value') do
155
+ @test_obj.test_value.should == true
156
+ end
157
+ end
158
+
159
+ end
160
+
161
+ describe ".open_url" do
162
+
163
+ it "uses NSURL or converts NSString in NSURL and opens it" do
164
+ application = UIApplication.sharedApplication
165
+ def application.url; @url end
166
+ def application.openURL(url); @url = url end
167
+
168
+ url = NSURL.URLWithString('http://localhost')
169
+ App.open_url(url)
170
+ application.url.should.equal url
171
+
172
+ url = 'http://localhost'
173
+ App.open_url(url)
174
+ application.url.class.should.equal NSURL
175
+ application.url.description.should.equal url
176
+ end
177
+
178
+ end
179
+ end
180
+ end
@@ -9,14 +9,29 @@ describe BubbleWrap::KVO do
9
9
  def initialize
10
10
  @items = [ "Apple", "Banana", "Chickpeas" ]
11
11
 
12
- @label = UILabel.alloc.initWithFrame [[0,0],[320, 30]]
13
- @label.text = "Foo"
12
+ if App.osx?
13
+ @label = NSTextField.alloc.initWithFrame [[0,0],[320, 30]]
14
+ @label.stringValue = "Foo"
15
+ else
16
+ @label = UILabel.alloc.initWithFrame [[0,0],[320, 30]]
17
+ @label.text = "Foo"
18
+ end
14
19
  end
15
20
 
16
21
  # Test helper
17
22
 
23
+ def get_text
24
+ App.osx? ? @label.stringValue : @label.text
25
+ end
26
+
27
+ def set_text(text)
28
+ method = App.osx? ? :stringValue : :text
29
+ @label.send("#{method}=", text)
30
+ end
31
+
18
32
  def observe_label(&block)
19
- observe(@label, :text, &block)
33
+ method = App.osx? ? :stringValue : :text
34
+ observe(@label, method, &block)
20
35
  end
21
36
 
22
37
  def observe_collection(&block)
@@ -24,7 +39,8 @@ describe BubbleWrap::KVO do
24
39
  end
25
40
 
26
41
  def unobserve_label
27
- unobserve(@label, :text)
42
+ method = App.osx? ? :stringValue : :text
43
+ unobserve(@label, method)
28
44
  end
29
45
 
30
46
  # def unobserve_all
@@ -135,7 +151,7 @@ describe BubbleWrap::KVO do
135
151
  new_value.should == "Bar"
136
152
  end
137
153
 
138
- @example.label.text = "Bar"
154
+ @example.set_text "Bar"
139
155
  observed.should == true
140
156
  end
141
157
 
@@ -153,7 +169,7 @@ describe BubbleWrap::KVO do
153
169
  observed_three = true
154
170
  end
155
171
 
156
- @example.label.text = "Bar"
172
+ @example.set_text "Bar"
157
173
  observed_one.should == true
158
174
  observed_two.should == true
159
175
  observed_three.should == true
@@ -168,7 +184,7 @@ describe BubbleWrap::KVO do
168
184
  end
169
185
  @example.unobserve_label
170
186
 
171
- @example.label.text = "Bar"
187
+ @example.set_text "Bar"
172
188
  observed.should == false
173
189
  end
174
190