module Briar::Keyboard

Constants

UITextAutocapitalizationTypeAllCharacters
UITextAutocapitalizationTypeNone
UITextAutocapitalizationTypeSentences
UITextAutocapitalizationTypeWords
UITextAutocorrectionTypeNo
UITextAutocorrectionTypeYes
UITextSpellCheckingTypeNo

might be 0 and 1?

UITextSpellCheckingTypeYes

Public Instance Methods

auto_correct_type() click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 60
def auto_correct_type
  if !query('textView index:0').empty?
    query('textView index:0', :autocorrectionType).first.to_i
  elsif !query('textField index:0').empty?
    query('textField index:0', :autocorrectionType).first.to_i
  else
    screenshot_and_raise 'could not find a text view or text field'
  end
end
autocapitalization_type() click to toggle source

is it possible to find what view the keyboard is responding to?

# File lib/briar/keyboard/keyboard.rb, line 50
def autocapitalization_type
  if !query('textView index:0').empty?
    query('textView index:0', :autocapitalizationType).first.to_i
  elsif !query('textField index:0').empty?
    query('textField index:0', :autocapitalizationType).first.to_i
  else
    screenshot_and_raise 'could not find a text view or text field'
  end
end
briar_clear_text(view_id, timeout=nil) click to toggle source

noinspection RubyUnusedLocalVariable

# File lib/briar/keyboard/keyboard.rb, line 72
def briar_clear_text(view_id, timeout=nil)
  unless timeout.nil?
    _deprecated('0.1.1', "will remove 'timeout' argument in a future release", :warn)
  end
  clear_text("view marked:'#{view_id}'")

  # i really wanted this to work, but there are too many issues with the
  # touch not bringing up the the Select menu bar - for example sometimes
  # it brings up the typo correction bar.
  #wait_for_view view_id
  #step_pause
  #touch("view marked:'#{view_id}'")
  #wait_for_button 'Select All', timeout
  #step_pause
  #touch_button_and_wait_for_view 'Select All', 'Cut', timeout
  #step_pause
  #touch_button 'Cut'
  #step_pause
end
briar_keyboard_enter_text(text) click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 41
def briar_keyboard_enter_text (text)
  keyboard_enter_text text
  # not ideal, but entering text by uia keyboard will never return what
  # was text was actually input to the keyboard
  @text_entered_by_keyboard = text
end
set_autocapitalization(type) click to toggle source

noinspection RubyUnusedLocalVariable

# File lib/briar/keyboard/keyboard.rb, line 95
def set_autocapitalization (type)
  _deprecated('0.1.1', 'does not work', :pending)
  #if !query('textView index:0').empty?
  #  query('textView index:0', [{setAutocapitalizationType: type}])
  #elsif !query('textField index:0').empty?
  #  query('textField index:0', [{setAutocapitalizationType: type}])
  #else
  #  screenshot_and_raise 'could not find a text view or text field'
  #end
end
set_autocorrect(type) click to toggle source

noinspection RubyUnusedLocalVariable

# File lib/briar/keyboard/keyboard.rb, line 112
def set_autocorrect (type)
  _deprecated('0.1.1', 'does not work', :pending)
  #if !query('textView index:0').empty?
  #  query('textView index:0', [{setAutocorrectionType: type}])
  #elsif !query('textField index:0').empty?
  #  query('textField index:0', [{setAutocorrectionType: type}])
  #else
  #  screenshot_and_raise 'could not find a text view or text field'
  #end
end
should_not_see_keyboard(timeout=BRIAR_WAIT_TIMEOUT) click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 31
def should_not_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT)
  msg = "waited for '#{timeout}' seconds but keyboard did not disappear"
  wait_for(:timeout => timeout,
           :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
           :post_timeout => BRIAR_WAIT_STEP_PAUSE,
           :timeout_message => msg) do
    element_does_not_exist 'keyboardAutomatic'
  end
end
should_see_keyboard(timeout=BRIAR_WAIT_TIMEOUT) click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 21
def should_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT)
  msg = "waited for '#{timeout}' seconds but did not see keyboard"
  wait_for(:timeout => timeout,
           :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
           :post_timeout => BRIAR_WAIT_STEP_PAUSE,
           :timeout_message => msg) do
    element_exists('keyboardAutomatic')
  end
end
turn_autocapitalization_off() click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 106
def turn_autocapitalization_off
  _deprecated('0.1.1', 'does not work', :pending)
  #set_autocapitalization UITextAutocapitalizationTypeNone
end
turn_autocorrect_off() click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 123
def turn_autocorrect_off
  _deprecated('0.1.1', 'does not work', :pending)
  # set_autocorrect UITextAutocorrectionTypeNo
end
turn_spell_correct_off() click to toggle source
# File lib/briar/keyboard/keyboard.rb, line 128
def turn_spell_correct_off
  _deprecated('0.1.1', 'does not work', :pending)
  #if !query('textView index:0').empty?
  #  query('textView index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
  #elsif !query('textField index:0').empty?
  #  query('textField index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
  #else
  #  screenshot_and_raise 'could not find a text view or text field'
  #end
end