Class: Calabash::Cucumber::IPad::Emulation

Inherits:
Object
  • Object
show all
Includes:
FailureHelpers, HTTPHelpers, QueryHelpers, UIA
Defined in:
lib/calabash-cucumber/ipad_1x_2x.rb

Constant Summary collapse

IPAD_1X_2X_BUTTON_LABELS =

NOTE to maintainers - when adding a localization, please notice that the keys and values are semantically reversed.

you should read the hash as:

:emulated_1x #=> what button is showing when the app is emulated at 2X?
:emulated_2x #=> what button is showing when the app is emulated at 1X?
{
      :en => {:emulated_1x => '2X',
              :emulated_2x => '1X'}
}

Constants included from Logging

Logging::CALABASH_NO_DEPRECATION

Constants included from HTTPHelpers

HTTPHelpers::CAL_HTTP_RETRY_COUNT, HTTPHelpers::RETRYABLE_ERRORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UIA

#escape_uia_string, #send_uia_command, #uia, #uia_call, #uia_call_method, #uia_call_windows, #uia_double_tap, #uia_double_tap_mark, #uia_double_tap_offset, #uia_element_does_not_exist?, #uia_element_exists?, #uia_enter, #uia_flick_offset, #uia_handle_command, #uia_names, #uia_pan, #uia_pan_offset, #uia_pinch, #uia_pinch_offset, #uia_query, #uia_query_el, #uia_query_windows, #uia_screenshot, #uia_scroll_to, #uia_send_app_to_background, #uia_serialize_argument, #uia_serialize_arguments, #uia_serialize_command, #uia_set_location, #uia_swipe, #uia_swipe_offset, #uia_tap, #uia_tap_mark, #uia_tap_offset, #uia_touch_hold, #uia_touch_hold_offset, #uia_two_finger_tap, #uia_two_finger_tap_offset, #uia_type_string, #uia_wait_tap

Methods included from Logging

#_deprecated, #calabash_info, #calabash_warn, #debug_logging?, #full_console_logging?, #no_deprecation_warnings?

Methods included from QueryHelpers

#escape_quotes, #point_from

Methods included from HTTPHelpers

#http, #init_request, #make_http_request, #url_for

Methods included from FailureHelpers

#fail, #screenshot, #screenshot_and_raise, #screenshot_embed

Constructor Details

#initialize(lang_code = :en) ⇒ Emulation

Returns a new instance of Emulation.



34
35
36
37
38
39
40
41
42
# File 'lib/calabash-cucumber/ipad_1x_2x.rb', line 34

def initialize (lang_code=:en)
  @button_names_hash = IPAD_1X_2X_BUTTON_LABELS[lang_code]
  if @button_names_hash.nil?
    raise "could not find 1X/2X buttons for language code '#{lang_code}'"
  end

  @lang_code = lang_code
  @scale = _internal_ipad_emulation_scale
end

Instance Attribute Details

#lang_codeObject (readonly)

Returns the value of attribute lang_code.



30
31
32
# File 'lib/calabash-cucumber/ipad_1x_2x.rb', line 30

def lang_code
  @lang_code
end

#scaleObject (readonly)

Returns the value of attribute scale.



29
30
31
# File 'lib/calabash-cucumber/ipad_1x_2x.rb', line 29

def scale
  @scale
end

Instance Method Details

#tap_ipad_scale_buttonObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/calabash-cucumber/ipad_1x_2x.rb', line 44

def tap_ipad_scale_button
  key = @scale
  name = @button_names_hash[key]

  res = uia_call_windows([:view, {:marked => "#{name}"}], :tap)

  # ':nil' is a very strange success return value...
  if res.is_a?(Hash) or res != ':nil'
    screenshot_and_raise "could not touch scale button '#{name}' - '#{res['value']}'"
  end
end