Class: Calabash::Cucumber::Device
- Inherits:
-
Object
- Object
- Calabash::Cucumber::Device
- Defined in:
- lib/calabash-cucumber/device.rb
Overview
Class device encapsulates information about the device or devices we are interacting with during a test.
Constant Summary collapse
- GESTALT_IPHONE =
'iPhone'
- GESTALT_IPAD =
'iPad'
- GESTALT_IPHONE5 =
'4-inch'
- GESTALT_SIM_SYS =
'x86_64'
- GESTALT_IPOD =
'iPod'
Instance Attribute Summary collapse
-
#device_family ⇒ Object
readonly
Returns the value of attribute device_family.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#framework_version ⇒ Object
readonly
Returns the value of attribute framework_version.
-
#ios_version ⇒ Object
readonly
Returns the value of attribute ios_version.
-
#iphone_app_emulated_on_ipad ⇒ Object
readonly
Returns the value of attribute iphone_app_emulated_on_ipad.
-
#simulator_details ⇒ Object
readonly
Returns the value of attribute simulator_details.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
-
#udid ⇒ Object
Returns the value of attribute udid.
Instance Method Summary collapse
- #device? ⇒ Boolean
-
#initialize(endpoint, version_data) ⇒ Device
constructor
A new instance of Device.
- #ios5? ⇒ Boolean
- #ios6? ⇒ Boolean
- #ios7? ⇒ Boolean
- #ios_major_version ⇒ Object
- #ipad? ⇒ Boolean
- #iphone? ⇒ Boolean
- #iphone_5? ⇒ Boolean
- #iphone_app_emulated_on_ipad? ⇒ Boolean
- #ipod? ⇒ Boolean
- #screen_size ⇒ Object
- #simulator? ⇒ Boolean
- #version_hash(version_str) ⇒ Object
Constructor Details
#initialize(endpoint, version_data) ⇒ Device
Returns a new instance of Device.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/calabash-cucumber/device.rb', line 24 def initialize (endpoint, version_data) simulator_device = version_data['simulator_device'] @endpoint = endpoint @system = version_data['system'] @device_family = @system.eql?(GESTALT_SIM_SYS) ? simulator_device : @system.split(/[\d,.]/).first @simulator_details = version_data['simulator'] @ios_version = version_data['iOS_version'] @framework_version = version_data['version'] @iphone_app_emulated_on_ipad = version_data['iphone_app_emulated_on_ipad'] end |
Instance Attribute Details
#device_family ⇒ Object (readonly)
Returns the value of attribute device_family.
16 17 18 |
# File 'lib/calabash-cucumber/device.rb', line 16 def device_family @device_family end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
15 16 17 |
# File 'lib/calabash-cucumber/device.rb', line 15 def endpoint @endpoint end |
#framework_version ⇒ Object (readonly)
Returns the value of attribute framework_version.
19 20 21 |
# File 'lib/calabash-cucumber/device.rb', line 19 def framework_version @framework_version end |
#ios_version ⇒ Object (readonly)
Returns the value of attribute ios_version.
17 18 19 |
# File 'lib/calabash-cucumber/device.rb', line 17 def ios_version @ios_version end |
#iphone_app_emulated_on_ipad ⇒ Object (readonly)
Returns the value of attribute iphone_app_emulated_on_ipad.
20 21 22 |
# File 'lib/calabash-cucumber/device.rb', line 20 def iphone_app_emulated_on_ipad @iphone_app_emulated_on_ipad end |
#simulator_details ⇒ Object (readonly)
Returns the value of attribute simulator_details.
17 18 19 |
# File 'lib/calabash-cucumber/device.rb', line 17 def simulator_details @simulator_details end |
#system ⇒ Object (readonly)
Returns the value of attribute system.
18 19 20 |
# File 'lib/calabash-cucumber/device.rb', line 18 def system @system end |
#udid ⇒ Object
Returns the value of attribute udid.
22 23 24 |
# File 'lib/calabash-cucumber/device.rb', line 22 def udid @udid end |
Instance Method Details
#device? ⇒ Boolean
39 40 41 |
# File 'lib/calabash-cucumber/device.rb', line 39 def device? not simulator? end |
#ios5? ⇒ Boolean
82 83 84 |
# File 'lib/calabash-cucumber/device.rb', line 82 def ios5? ios_major_version.eql?('5') end |
#ios6? ⇒ Boolean
78 79 80 |
# File 'lib/calabash-cucumber/device.rb', line 78 def ios6? ios_major_version.eql?('6') end |
#ios7? ⇒ Boolean
74 75 76 |
# File 'lib/calabash-cucumber/device.rb', line 74 def ios7? ios_major_version.eql?('7') end |
#ios_major_version ⇒ Object
70 71 72 |
# File 'lib/calabash-cucumber/device.rb', line 70 def ios_major_version version_hash(ios_version)[:major_version] end |
#ipad? ⇒ Boolean
51 52 53 |
# File 'lib/calabash-cucumber/device.rb', line 51 def ipad? device_family.eql? GESTALT_IPAD end |
#iphone? ⇒ Boolean
43 44 45 |
# File 'lib/calabash-cucumber/device.rb', line 43 def iphone? device_family.eql? GESTALT_IPHONE end |
#iphone_5? ⇒ Boolean
55 56 57 58 59 60 61 |
# File 'lib/calabash-cucumber/device.rb', line 55 def iphone_5? if simulator? !simulator_details.scan(GESTALT_IPHONE5).empty? else system.split(/[\D]/).delete_if { |x| x.eql?('') }.first.eql?('5') end end |
#iphone_app_emulated_on_ipad? ⇒ Boolean
92 93 94 |
# File 'lib/calabash-cucumber/device.rb', line 92 def iphone_app_emulated_on_ipad? iphone_app_emulated_on_ipad end |
#ipod? ⇒ Boolean
47 48 49 |
# File 'lib/calabash-cucumber/device.rb', line 47 def ipod? device_family.eql? GESTALT_IPOD end |
#screen_size ⇒ Object
86 87 88 89 90 |
# File 'lib/calabash-cucumber/device.rb', line 86 def screen_size return { :width => 768, :height => 1024 } if ipad? return { :width => 320, :height => 568 } if iphone_5? { :width => 320, :height => 480 } end |
#simulator? ⇒ Boolean
35 36 37 |
# File 'lib/calabash-cucumber/device.rb', line 35 def simulator? system.eql?(GESTALT_SIM_SYS) end |
#version_hash(version_str) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/calabash-cucumber/device.rb', line 63 def version_hash (version_str) tokens = version_str.split(/[,.]/) {:major_version => tokens[0], :minor_version => tokens[1], :bug_version => tokens[2]} end |