<commit_before>require 'calabash-cucumber/ibase'
require "run_loop"

require File.join(File.dirname(__FILE__), '..', 'support', 'wait_options')

module WebViewApp
  class TabBar < Calabash::IBase
    include WebViewApp::WaitOpts

    def trait
      'UITabBar'
    end

    def navigate_to(page_id)
      case page_id
        when :uiwebview
          index = 0
        when :wkwebview
          index = 1
        else
          raise "Expected '#{page_id}' to be one of [:uiwebview, :wkwebview]"
      end

      qstr = "UITabBarButton index:#{index}"
      wait_for(wait_options(qstr)) do
        !query(qstr).empty?
      end

      count = 0
      begin
        touch(qstr)
      rescue => e
        count = count + 1
        if count == 3
          raise e.message
        else
          puts "Touch failed; retrying..."
        end

        sleep(0.4)
        retry
      end

      with_active_page do |page|
        qstr = page.query_str

        if RunLoop::Environment.xtc?
          timeout = 45
        elsif RunLoop::Environment.ci?<commit_msg>Travis: increase web page load timeouts<commit_after>require 'calabash-cucumber/ibase'
require "run_loop"

require File.join(File.dirname(__FILE__), '..', 'support', 'wait_options')

module WebViewApp
  class TabBar < Calabash::IBase
    include WebViewApp::WaitOpts

    def trait
      'UITabBar'
    end

    def navigate_to(page_id)
      case page_id
        when :uiwebview
          index = 0
        when :wkwebview
          index = 1
        else
          raise "Expected '#{page_id}' to be one of [:uiwebview, :wkwebview]"
      end

      qstr = "UITabBarButton index:#{index}"
      wait_for(wait_options(qstr)) do
        !query(qstr).empty?
      end

      count = 0
      begin
        touch(qstr)
      rescue => e
        count = count + 1
        if count == 3
          raise e.message
        else
          puts "Touch failed; retrying..."
        end

        sleep(0.4)
        retry
      end

      with_active_page do |page|
        qstr = page.query_str

        if RunLoop::Environment.xtc?
          timeout = 45
        elsif RunLoop::Environment.travis?
          timeout = 60
        elsif RunLoop::Environment.ci?
{'fraction_non_alphanumeric': 0.09247506799637353, 'fraction_numerical': 0.009066183136899365, 'mean_word_length': 1.8367609254498716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4759576', 'n_tokens_mistral': 718, 'n_tokens_neox': 685, 'n_words': 174}