Sha256: ee8d89f7860b67ed54a0d0995f2cceb66140585c25190ce2f14f82175a4fba5f

Contents?: true

Size: 1.38 KB

Versions: 14

Compression:

Stored size: 1.38 KB

Contents

module Calabash
  # @!visibility private
  module ConsoleHelpers
    def self.render(data, indentation)
      if visible?(data)
        type = data['type']
        simple_name = type.split('.').last.split('$').last

        str_type = if data['type'] == 'dom'
                     "#{Color.yellow("[")}#{simple_name}:#{Color.yellow("#{data['nodeName']}]")} "
                   else
                     Color.yellow("[#{simple_name}] ")
                   end

        text = nil

        if data['value']
          unless data['value'].empty?
            if data['value'].length > 45
              text = "#{data['value'][0,45]}[...]"
            else
              text = data['value']
            end

            newline_index = text.index("\n")

            unless newline_index.nil?
              text = "#{text[0,newline_index]}[...]"
            end
          end
        end

        str_id = data['id'] ? "[id:#{Color.blue(data['id'])}] " : ''
        str_label = data['label'] ? "[contentDescription:#{Color.green(data['label'])}] " : ''
        str_text = text ? "[text:#{Color.magenta(text)}] " : ''
        output("#{str_type}#{str_id}#{str_label}#{str_text}", indentation)
        output("\n", indentation)
      end
    end

    def self.visible?(data)
      (data['type'] != '[object Exception]' && data['visible']) ||
          data['children'].map{|child| visible?(child)}.any?
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
calabash-2.0.0.pre11 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre10 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre9 lib/calabash/android/console_helpers.rb
calabash-2.0.0.prelegacy4 lib/calabash/android/console_helpers.rb
calabash-2.0.0.prelegacy3 lib/calabash/android/console_helpers.rb
calabash-2.0.0.prelegacy2 lib/calabash/android/console_helpers.rb
calabash-2.0.0.prelegacy lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre6 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre5 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre4 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre3 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre2 lib/calabash/android/console_helpers.rb
calabash-2.0.0.pre1 lib/calabash/android/console_helpers.rb
calabash-1.9.9.pre3 lib/calabash/android/console_helpers.rb