tabbyx 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tabby +46 -0
- data/bin/tabby-android.rb +29 -0
- data/bin/{console → tabby-console} +1 -0
- data/bin/tabby-generate.rb +35 -0
- data/bin/tabby-helpers.rb +46 -0
- data/bin/tabby-run.rb +133 -0
- data/bin/{setup → tabby-setup} +0 -0
- data/lib/tabbyx.rb +0 -3
- data/lib/tabbyx/calabash_android.rb +2 -1
- data/lib/tabbyx/{utils/code_coverage.rb → code_coverage.rb} +0 -0
- data/lib/tabbyx/core/base.rb +3 -4
- data/lib/tabbyx/core/initialize.rb +2 -2
- data/lib/tabbyx/fixtures/global.rb +8 -10
- data/lib/tabbyx/helpers/excel_helper.rb +2 -2
- data/lib/tabbyx/helpers/http_helper.rb +1 -1
- data/lib/tabbyx/helpers/test_helper.rb +4 -0
- data/lib/tabbyx/steps_android/performance_steps.rb +49 -0
- data/lib/tabbyx/utils/adb_devices.rb +12 -2
- data/lib/tabbyx/utils/adb_screenshot.rb +1 -1
- data/lib/tabbyx/version.rb +1 -1
- metadata +19 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580a9cee308ed04a5c7de491985bc50f6451c673
|
4
|
+
data.tar.gz: 92eb33602f0661a7d4743772267e3b05c64ea836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6576a90c0205a0894684df18c019cb559ef4d214ddda7f9362231e8199a46803a6204e40e64d615c7caa30a477464b1795b7c0ae001a10ea25742e015c465a1
|
7
|
+
data.tar.gz: 2fdddbdf85bba2e9e5a0698ec07711d0b022f97fb986aa6909471258de73048249c592297d04918c8da9bc4a92e2a68bb965395540f72945a347f92e322fc64f
|
data/bin/tabby
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "tabbyx"
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), "tabby-helpers")
|
6
|
+
require File.join(File.dirname(__FILE__), "tabby-run")
|
7
|
+
require File.join(File.dirname(__FILE__), "tabby-android")
|
8
|
+
|
9
|
+
if ARGV.length == 0
|
10
|
+
print_usage
|
11
|
+
else
|
12
|
+
cmd = ARGV.shift
|
13
|
+
|
14
|
+
case cmd
|
15
|
+
when 'help'
|
16
|
+
print_help
|
17
|
+
when 'build'
|
18
|
+
|
19
|
+
when 'run'
|
20
|
+
read_configurations
|
21
|
+
run_tests
|
22
|
+
|
23
|
+
when 'html'
|
24
|
+
read_configurations
|
25
|
+
run_tests_html_report
|
26
|
+
|
27
|
+
when 'ci'
|
28
|
+
require 'tabbyx/code_coverage'
|
29
|
+
read_configurations
|
30
|
+
run_tests_on_ci
|
31
|
+
|
32
|
+
when 'gen'
|
33
|
+
|
34
|
+
when 'setup'
|
35
|
+
|
36
|
+
when 'reinstall'
|
37
|
+
reinstall_android_app
|
38
|
+
|
39
|
+
when 'version'
|
40
|
+
require 'tabbyx/version'
|
41
|
+
puts Tabbyx::VERSION
|
42
|
+
else
|
43
|
+
puts "TABBYX: Invalid command '#{cmd}'"
|
44
|
+
print_usage
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'tabbyx'
|
2
|
+
|
3
|
+
def reinstall_android_app
|
4
|
+
package_name = APP["android_package_name"]
|
5
|
+
tests_name = APP["uiautomator_test_package_name"]
|
6
|
+
|
7
|
+
tests_path = File.expand_path("./apps/" + APP["uiautomator_test"])
|
8
|
+
apk_path = File.expand_path("./apps/" + APP["android_apk_name"])
|
9
|
+
puts tests_path, apk_path
|
10
|
+
|
11
|
+
puts "TABBYX: uninstall apps if they've been installed."
|
12
|
+
ADBDevices.uninstall_app(package_name)
|
13
|
+
ADBDevices.uninstall_app(tests_name)
|
14
|
+
sleep 5
|
15
|
+
|
16
|
+
puts "TABBYX: install apps before run UI automator tests."
|
17
|
+
ADBDevices.install_app(apk_path)
|
18
|
+
ADBDevices.install_app(tests_path)
|
19
|
+
sleep 5
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def test_initialized
|
24
|
+
puts "TABBYX: run uiautomator tests..."
|
25
|
+
class_name = APP["uiautomator_test_class"]
|
26
|
+
package_name = APP["android_package_name"]
|
27
|
+
ADBDevices.run_android_test_by_class(class_name,package_name)
|
28
|
+
sleep 5
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'json'
|
3
|
+
require 'tabbyx'
|
4
|
+
|
5
|
+
def generate_calabash_settings
|
6
|
+
keystore = APP["android_keystore"]
|
7
|
+
|
8
|
+
if keystore.nil? || keystore == ""
|
9
|
+
# 使用debug签名
|
10
|
+
keystore_path = File.expand_path("./signatures/") + "/debug.keystore"
|
11
|
+
print "TABBYX: keystore_path:", keystore_path, "\n"
|
12
|
+
calabash_settings = {"keystore_location":"#{keystore_path}","keystore_password":"android","keystore_alias":"androiddebugkey"}.to_s
|
13
|
+
puts "TABBYX: .calabash_settings' content:", calabash_settings
|
14
|
+
|
15
|
+
# 生成文件.calabash_settings并将calabash settings写入
|
16
|
+
Base.create_file(".calabash_settings",ROOT_PATH)
|
17
|
+
f = File.new(".calabash_settings", "w")
|
18
|
+
f.syswrite(calabash_settings)
|
19
|
+
else
|
20
|
+
# 获取keystore的路径
|
21
|
+
keystore_path = File.expand_path("./signatures/") + "/" + keystore
|
22
|
+
print "TABBYX: keystore_path:", keystore_path, "\n"
|
23
|
+
|
24
|
+
# 生成calabash settings字符串
|
25
|
+
calabash_settings = JSON({"keystore_location":"#{keystore_path}","keystore_password":"#{APP["keystore_password"]}","keystore_alias":"#{APP["keystore_alias"]}"}.to_hash)
|
26
|
+
puts "TABBYX: .calabash_settings' content:", calabash_settings
|
27
|
+
|
28
|
+
# 生成文件.calabash_settings并将calabash settings写入
|
29
|
+
Base.create_file(".calabash_settings",ROOT_PATH)
|
30
|
+
f = File.new(".calabash_settings", "w")
|
31
|
+
f.syswrite(calabash_settings)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'json'
|
3
|
+
require "rubygems"
|
4
|
+
|
5
|
+
|
6
|
+
def msg(title, &block)
|
7
|
+
puts "\n" + "-"*10 + title + "-"*10
|
8
|
+
block.call
|
9
|
+
puts "-"*10 + "-------" + "-"*10 + "\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
def print_usage
|
13
|
+
puts <<EOF
|
14
|
+
Usage: tabby <command-name> [parameters] [options]
|
15
|
+
<command-name> can be one of
|
16
|
+
help
|
17
|
+
prints more detailed help information.
|
18
|
+
run <platform> <tag> <excluded_tags>
|
19
|
+
runs tests in the current folder with the environment needed.
|
20
|
+
version
|
21
|
+
prints the gem version
|
22
|
+
|
23
|
+
<options> can be
|
24
|
+
-v, --verbose
|
25
|
+
Turns on verbose logging
|
26
|
+
EOF
|
27
|
+
end
|
28
|
+
|
29
|
+
def print_help
|
30
|
+
print_usage
|
31
|
+
end
|
32
|
+
|
33
|
+
def is_json?(str)
|
34
|
+
str[0..0] == '{'
|
35
|
+
end
|
36
|
+
|
37
|
+
def read_configurations
|
38
|
+
# Read the configuration files
|
39
|
+
puts "TABBYX: ---------------- Running tests ------------------"
|
40
|
+
puts "TABBYX: Configuring for product #{ENV['PRODUCT']}, environment #{ENV['SERVER']}"
|
41
|
+
warn("TABBYX: please check config/env.yml to make sure product and environment should be correct!!!")
|
42
|
+
|
43
|
+
warn("TABBYX: 请配置测试账户信息!") unless USER
|
44
|
+
warn("TABBYX: 请配置app信息!") unless APP
|
45
|
+
warn("TABBYX: 请配置当前项目的host!") unless HOST
|
46
|
+
end
|
data/bin/tabby-run.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'tabbyx'
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "tabby-generate")
|
4
|
+
require File.join(File.dirname(__FILE__), "tabby-android")
|
5
|
+
|
6
|
+
def run_uiautomator_tests
|
7
|
+
@package_name = APP["android_package_name"]
|
8
|
+
tests_path = File.expand_path("./testcases/") + "/uiautomator_tests.txt"
|
9
|
+
puts tests_path
|
10
|
+
test_classes = TXThelper.read_file_by_path(tests_path)
|
11
|
+
test_classes.each do | class_name |
|
12
|
+
ADBDevices.run_android_test_by_class(class_name.chomp,@package_name)
|
13
|
+
sleep(5)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
$cmd = ''
|
18
|
+
|
19
|
+
def run_tests
|
20
|
+
unless system("bundle version")
|
21
|
+
puts "Can't find bundler. Check your ruby environment."
|
22
|
+
puts "If your using ~/.calabash then run:"
|
23
|
+
puts <<EOF
|
24
|
+
|
25
|
+
export GEM_HOME=~/.calabash
|
26
|
+
export GEM_PATH=~/.calabash
|
27
|
+
export PATH="$PATH:$HOME/.calabash/bin"
|
28
|
+
EOF
|
29
|
+
exit(false)
|
30
|
+
end
|
31
|
+
|
32
|
+
ENV['PLATFORM'] = ARGV[0]
|
33
|
+
unless ENV['PLATFORM'].nil?
|
34
|
+
print "TABBYX: Configuring for Platform: ", ENV['PLATFORM'], "\n"
|
35
|
+
else
|
36
|
+
abort("TABBYX: 缺少参数,请检查")
|
37
|
+
end
|
38
|
+
|
39
|
+
ARGV[2].include?("@") ? ENV['TAGS_EXCLUDED'] = ARGV[2] : ENV['BROWSER'] = ARGV[2] unless ARGV[2].nil?
|
40
|
+
ARGV[1].include?("@") ? ENV['TAGS'] = ARGV[1] : ENV['BROWSER'] = ARGV[1] unless ARGV[1].nil?
|
41
|
+
ARGV[1].include?(".txt")? ENV['RERUN_TAGS'] = ARGV[1]: ENV['BROWSER'] = ARGV[1] unless ARGV[1].nil?
|
42
|
+
|
43
|
+
case ENV['PLATFORM']
|
44
|
+
when 'uiautomator'
|
45
|
+
|
46
|
+
# Run uiautomator tests
|
47
|
+
reinstall_android_app
|
48
|
+
run_uiautomator_tests
|
49
|
+
|
50
|
+
cmd = 'cucumber'
|
51
|
+
when 'android'
|
52
|
+
|
53
|
+
unless APP["android_apk_name"].nil?
|
54
|
+
app_path = File.expand_path("./apps/" + APP["android_apk_name"])
|
55
|
+
else
|
56
|
+
raise("TABBYX: please make sure your apk file has been placed in apps folder")
|
57
|
+
app_path = ""
|
58
|
+
end
|
59
|
+
|
60
|
+
reinstall_android_app
|
61
|
+
test_initialized
|
62
|
+
|
63
|
+
#resign app
|
64
|
+
Shell.process("calabash-android resign #{app_path}")
|
65
|
+
|
66
|
+
# 配置签名并使用该签名生成calabash server
|
67
|
+
generate_calabash_settings
|
68
|
+
puts "TABBYX: sign test server to make sure it's consistent with apk under test before running calabash scripts!"
|
69
|
+
Shell.process("calabash-android build #{app_path}")
|
70
|
+
sleep 5
|
71
|
+
# Run Calabash tests
|
72
|
+
cmd = "calabash-android run #{app_path}"
|
73
|
+
when 'ios'
|
74
|
+
cmd = 'cucumber'
|
75
|
+
when 'web'
|
76
|
+
if ENV['BROWSER']
|
77
|
+
print "TABBYX: Configuring for Web Browser: ", ENV['BROWSER'], "\n"
|
78
|
+
cmd = "cucumber -p #{ENV['BROWSER']}"
|
79
|
+
else
|
80
|
+
cmd = 'cucumber'
|
81
|
+
end
|
82
|
+
when 'dummy'
|
83
|
+
cmd = 'cucumber'
|
84
|
+
else
|
85
|
+
puts 'TABBYX: wrong targets,please input platform like ios or android you want to test.'
|
86
|
+
end
|
87
|
+
|
88
|
+
cmd << " -p #{ENV['PLATFORM']}"
|
89
|
+
|
90
|
+
if ENV['RERUN_TAGS']
|
91
|
+
print "TABBYX: Configuring for rerun file: ", ENV['TAGS'], "\n"
|
92
|
+
cmd << " #{ENV['TAGS']}"
|
93
|
+
end
|
94
|
+
|
95
|
+
if ENV['TAGS']
|
96
|
+
print "TABBYX: Configuring for Tags(@): ", ENV['TAGS'], "\n"
|
97
|
+
cmd << " --tags #{ENV['TAGS']}"
|
98
|
+
else
|
99
|
+
cmd << " --tags @dummy" if ENV['PLATFORM'] == "uiautomator"
|
100
|
+
end
|
101
|
+
|
102
|
+
if ENV['TAGS_EXCLUDED']
|
103
|
+
print "TABBYX: excluded Tags(@): ",ENV['TAGS_EXCLUDED'], "\n"
|
104
|
+
cmd << " --tags ~#{ENV['TAGS_EXCLUDED']}"
|
105
|
+
end
|
106
|
+
|
107
|
+
$cmd = cmd
|
108
|
+
puts "Command: #{$cmd}"
|
109
|
+
exec($cmd)
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
def run_tests_html_report
|
114
|
+
if ENV['RERUN_TAGS']
|
115
|
+
$cmd << " --format html --out cucumber_report.html"
|
116
|
+
else
|
117
|
+
$cmd << " -f rerun --out rerun.txt --format html --out cucumber_report.html"
|
118
|
+
end
|
119
|
+
|
120
|
+
puts "Command: #{$cmd}"
|
121
|
+
exec($cmd)
|
122
|
+
end
|
123
|
+
|
124
|
+
def run_tests_on_ci
|
125
|
+
if ENV['RERUN_TAGS']
|
126
|
+
$cmd << " --format pretty --format json --out reports.json"
|
127
|
+
else
|
128
|
+
$cmd << " -f rerun --out rerun.txt --format pretty --format json --out reports.json"
|
129
|
+
end
|
130
|
+
|
131
|
+
puts "Command: #{$cmd}"
|
132
|
+
exec($cmd)
|
133
|
+
end
|
data/bin/{setup → tabby-setup}
RENAMED
File without changes
|
data/lib/tabbyx.rb
CHANGED
@@ -15,9 +15,6 @@ require 'tabbyx/helpers/excel_helper'
|
|
15
15
|
require 'tabbyx/helpers/txt_helper'
|
16
16
|
require 'tabbyx/helpers/screenshot_helpers'
|
17
17
|
|
18
|
-
# support
|
19
|
-
require 'tabbyx/utils/code_coverage'
|
20
|
-
|
21
18
|
# utilities
|
22
19
|
require 'tabbyx/utils/shell'
|
23
20
|
require 'tabbyx/utils/adb_devices'
|
@@ -8,4 +8,5 @@ require 'tabbyx/steps_android/navigation_steps'
|
|
8
8
|
require 'tabbyx/steps_android/press_button_steps'
|
9
9
|
require 'tabbyx/steps_android/progress_steps'
|
10
10
|
require 'tabbyx/steps_android/search_steps'
|
11
|
-
require 'tabbyx/steps_android/spinner_steps'
|
11
|
+
require 'tabbyx/steps_android/spinner_steps'
|
12
|
+
require 'tabbyx/steps_android/performance_steps'
|
File without changes
|
data/lib/tabbyx/core/base.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'tabbyx/fixtures/constants'
|
3
3
|
|
4
|
-
|
5
4
|
module Base
|
6
5
|
|
7
6
|
# load all yaml files in config folder
|
@@ -13,11 +12,11 @@ module Base
|
|
13
12
|
def Base::read_yaml(filename)
|
14
13
|
path = File.absolute_path(CONFIG_PATH)
|
15
14
|
file = File.join(path,"config","#{filename}.yml")
|
16
|
-
# puts file
|
17
15
|
if File.exist?(file)
|
18
16
|
YAML.load_file(file)
|
19
17
|
else
|
20
|
-
warn('cannot find the yaml file '+ filename)
|
18
|
+
warn('TABBYX: cannot find the yaml file '+ filename)
|
19
|
+
return nil
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
@@ -33,7 +32,7 @@ module Base
|
|
33
32
|
path = File.absolute_path(file_path)
|
34
33
|
file = File.join(path,file_name)
|
35
34
|
unless File.exist?(file)
|
36
|
-
puts "create file..."
|
35
|
+
puts "TABBYX: create file..."
|
37
36
|
File.new(file, "a+")
|
38
37
|
end
|
39
38
|
file
|
@@ -9,10 +9,10 @@ module Tabby
|
|
9
9
|
def self.initialize_project
|
10
10
|
Base.create_directory("apps",ROOT_PATH)
|
11
11
|
Base.create_directory("screenshots",ROOT_PATH)
|
12
|
-
Base.create_directory("reports",ROOT_PATH)
|
12
|
+
# Base.create_directory("reports",ROOT_PATH)
|
13
13
|
# Base.create_directory("inputs",ROOT_PATH)
|
14
14
|
# Base.create_directory("outputs",ROOT_PATH)
|
15
|
-
Base.create_directory("testcases",ROOT_PATH)
|
15
|
+
# Base.create_directory("testcases",ROOT_PATH)
|
16
16
|
Base.create_directory("testsuites",ROOT_PATH+"features/")
|
17
17
|
|
18
18
|
if ENV['PLATFORM'] == 'android'
|
@@ -8,16 +8,20 @@ ENV['BROWSER'] = 'chrome' if ENV['BROWSER'].nil?
|
|
8
8
|
|
9
9
|
ENV['CONNECT_TIMEOUT'] = '90' if ENV['CONNECT_TIMEOUT'].nil?
|
10
10
|
|
11
|
+
env = Base.read_yaml('env')
|
12
|
+
unless env.nil?
|
13
|
+
ENV['SERVER'] = env["environment"]
|
14
|
+
ENV['PRODUCT'] = env["product"]
|
15
|
+
ENV['TARGET'] = env["target"]
|
16
|
+
end
|
17
|
+
|
18
|
+
|
11
19
|
# Always use downcase
|
12
20
|
ENV['SERVER'] = ENV['SERVER'].downcase
|
13
21
|
ENV['PRODUCT'] = ENV['PRODUCT'].downcase
|
14
22
|
ENV['TARGET'] = ENV['TARGET'].downcase
|
15
23
|
ENV['BROWSER'] = ENV['BROWSER'].downcase
|
16
24
|
|
17
|
-
# Read the configuration files
|
18
|
-
puts "Configuring for product #{ENV['PRODUCT']}, environment #{ENV['SERVER']}"
|
19
|
-
warn("please check support/env.rb to make sure product and environment should be correct!!!")
|
20
|
-
|
21
25
|
config = Config.read_config(ENV['PRODUCT'], ENV['SERVER'], ENV['TARGET'])
|
22
26
|
|
23
27
|
# Setup global constants
|
@@ -28,12 +32,6 @@ APP = config[:app]
|
|
28
32
|
DEVICE = config[:device]
|
29
33
|
HOST = config[:host]
|
30
34
|
|
31
|
-
puts USER, APP, HOST
|
32
|
-
|
33
|
-
warn("请配置测试账户信息!") unless USER
|
34
|
-
warn("请配置app信息!") unless APP
|
35
|
-
warn("请配置当前项目的host!") unless HOST
|
36
|
-
|
37
35
|
# Relevant configurations for API Testing
|
38
36
|
USER_AGENT = "QDReaderAppStore/3.7.3 (iPhone; iOS 9.3; Scale/2.00)"
|
39
37
|
COOKIE = "QDHeader=NzRiMjdkYzIxMmY2NjNlYmRlNWI2NzdkY2RkYzRmNWJ8My43LjN8NzUwfDEzMzR8UWlZZXw5LjMwfDV8aVBob25lIE9TL2lQaG9uZS94ODZfNjR8MTY0fFFpWWV8Mw==; _ga=GA1.2.207823887.1473851687; cmfuToken=N((cfBPzO963RhWhcOx2uGENWANvs2qlZ4zKVpEK8Tlo1RKq3oztfJ4onZu5bFWY3-a4XjIMPYkQOmqWfUrob5VIX1i7EQP6OP6TaPc9tWnPtMxigj0_wm4hU3rxDO24U-ewbhHaG_Ibeca9uUrJXCZe9JkwBizrFwDXUJoCGAMbQPTJwGekSHeQeJWMJF0OlJzPmLXmcIHeoxQ_hrACayIuQTxkLaSAXwBUjkXdzXukBQXW7P5nVMQkkHvTfhs8WajMOuPuv5X1hh9I_M0xNG2CbtyChJBVxvVSKf8_yDOxHaLdEvglmHAEg2; stat_gid=8208333844"
|
@@ -41,14 +41,14 @@ module ExcelHelper
|
|
41
41
|
def self.write_into_worksheet(filename,worksheet,row,column,value)
|
42
42
|
if Base.file_exists?(filename)
|
43
43
|
file = Base.file(filename)
|
44
|
-
raise("指定的文件不是excel,请检查") unless File.extname(file) == ".xlsx"
|
44
|
+
raise("TABBYX: 指定的文件不是excel,请检查") unless File.extname(file) == ".xlsx"
|
45
45
|
excel = RubyXL::Parser.parse(file)
|
46
46
|
elsif Base.file_exists?(filename,"../outputs/")
|
47
47
|
file = Base.file(filename,"../outputs/")
|
48
48
|
excel = RubyXL::Parser.parse(file)
|
49
49
|
else
|
50
50
|
file = Base.file(filename,"../outputs/")
|
51
|
-
puts "创建excel文件"+filename
|
51
|
+
puts "TABBYX: 创建excel文件"+filename
|
52
52
|
excel = RubyXL::Workbook.new
|
53
53
|
end
|
54
54
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
Then /^打开GT$/ do
|
3
|
+
#macro %(初始化GT获取设备读写权限)
|
4
|
+
ADBDevices.start_activity("com.tencent.wstt.gt/com.tencent.wstt.gt.activity.GTMainActivity")
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^初始化GT获取设备读写权限$/ do
|
8
|
+
ADBDevices.send_keyboard("61") #TAB聚焦到弹窗
|
9
|
+
ADBDevices.send_keyboard("61") #TAB切换到允许
|
10
|
+
ADBDevices.send_keyboard("66") #点击允许
|
11
|
+
ADBDevices.send_keyboard("66") #允许
|
12
|
+
ADBDevices.send_keyboard("66") #允许
|
13
|
+
ADBDevices.send_keyboard("4") #关闭页面并后台运行
|
14
|
+
end
|
15
|
+
|
16
|
+
#SDK插桩场景使用
|
17
|
+
Then /^再次打开初始化参数列表$/ do
|
18
|
+
ADBDevices.start_activity("com.tencent.wstt.gt/com.tencent.wstt.gt.activity.GTMainActivity")
|
19
|
+
ADBDevices.send_keyboard("4") #关闭页面并后台运行
|
20
|
+
end
|
21
|
+
|
22
|
+
#SDK插桩场景使用
|
23
|
+
Then /^开始GT数据采集$/ do
|
24
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.startTest")
|
25
|
+
end
|
26
|
+
|
27
|
+
Then /^开始测试包名为"([^"]*)"的应用$/ do |pkgname|
|
28
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.startTest --es pkgName "<< pkgname)
|
29
|
+
end
|
30
|
+
|
31
|
+
Then /^开启通用指标采集$/ do
|
32
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.sampleData --ei cpu 1")
|
33
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.sampleData --ei jif 1")
|
34
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.sampleData --ei pss 1")
|
35
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.sampleData --ei pri 1")
|
36
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.sampleData --ei net 1")
|
37
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.sampleData --ei fps 1")
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
Then /^停止GT并保存"([^"]*)"采集结果$/ do |name|
|
42
|
+
Shell.adb_shell(" am broadcast -a com.tencent.wstt.gt.baseCommand.endTest --es saveFolderName " << "\"" << name << "\"")
|
43
|
+
#macro %(关闭GT)
|
44
|
+
end
|
45
|
+
|
46
|
+
Then /^关闭GT$/ do
|
47
|
+
ADBDevices.stop_app("com.tencent.wstt.gt")
|
48
|
+
end
|
49
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# adb_devices.rb 用Ruby封装了常用的Android SDK提供的adb命令,在Android测试脚本中可以随时随地使用
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'shell'
|
4
4
|
|
5
5
|
module ADBDevices
|
6
6
|
|
@@ -34,6 +34,11 @@ module ADBDevices
|
|
34
34
|
resolution
|
35
35
|
end
|
36
36
|
|
37
|
+
#adb-shell发送按键命令
|
38
|
+
def self.send_keyboard(key)
|
39
|
+
Shell.adb_shell("input keyevent" << " " << key)
|
40
|
+
end
|
41
|
+
|
37
42
|
# 返回设备电池电量
|
38
43
|
def self.get_battery_level
|
39
44
|
Shell.adb_shell("dumpsys battery | grep level").split(": ")[1]
|
@@ -45,7 +50,7 @@ module ADBDevices
|
|
45
50
|
temp.to_i/10.0
|
46
51
|
end
|
47
52
|
|
48
|
-
|
53
|
+
# 获取电池充电状态: 返回状态数值
|
49
54
|
def self.get_battery_status
|
50
55
|
status = Shell.adb_shell("dumpsys battery | grep status").split(": ")[1].to_i
|
51
56
|
case status
|
@@ -101,6 +106,11 @@ module ADBDevices
|
|
101
106
|
end
|
102
107
|
|
103
108
|
# 退出当前应用
|
109
|
+
def self.stop_app(package_name)
|
110
|
+
Shell.adb_shell("am force-stop " << package_name)
|
111
|
+
end
|
112
|
+
|
113
|
+
# 退出指定包名应用
|
104
114
|
def self.stop_current_app
|
105
115
|
Shell.adb_shell("am force-stop " << self.get_current_package_name)
|
106
116
|
end
|
@@ -7,7 +7,7 @@ module ADBScreenShot
|
|
7
7
|
|
8
8
|
def self.take_screenshot(image_name)
|
9
9
|
temp_path = File.absolute_path(SCREENSHOT_TEMP)+"/"
|
10
|
-
|
10
|
+
print "TABBYX: screenshot folder", temp_path, "\n"
|
11
11
|
Shell.adb_shell("screencap -p /data/local/tmp/" << image_name << ".png")
|
12
12
|
Shell.adb("pull /data/local/tmp/" << image_name << ".png " << temp_path)
|
13
13
|
Shell.adb_shell("rm /data/local/tmp/*.png")
|
data/lib/tabbyx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabbyx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- angelia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -203,16 +203,27 @@ description: an agile testing framework supports testing web and mobile apps,inc
|
|
203
203
|
email:
|
204
204
|
- angeliawang@me.com
|
205
205
|
executables:
|
206
|
-
-
|
207
|
-
-
|
206
|
+
- tabby
|
207
|
+
- tabby-android.rb
|
208
|
+
- tabby-console
|
209
|
+
- tabby-generate.rb
|
210
|
+
- tabby-helpers.rb
|
211
|
+
- tabby-run.rb
|
212
|
+
- tabby-setup
|
208
213
|
extensions: []
|
209
214
|
extra_rdoc_files: []
|
210
215
|
files:
|
211
|
-
- bin/
|
212
|
-
- bin/
|
216
|
+
- bin/tabby
|
217
|
+
- bin/tabby-android.rb
|
218
|
+
- bin/tabby-console
|
219
|
+
- bin/tabby-generate.rb
|
220
|
+
- bin/tabby-helpers.rb
|
221
|
+
- bin/tabby-run.rb
|
222
|
+
- bin/tabby-setup
|
213
223
|
- lib/tabbyx.rb
|
214
224
|
- lib/tabbyx/calabash_android.rb
|
215
225
|
- lib/tabbyx/calabash_ios.rb
|
226
|
+
- lib/tabbyx/code_coverage.rb
|
216
227
|
- lib/tabbyx/core/base.rb
|
217
228
|
- lib/tabbyx/core/config.rb
|
218
229
|
- lib/tabbyx/core/initialize.rb
|
@@ -225,6 +236,7 @@ files:
|
|
225
236
|
- lib/tabbyx/helpers/http_helper.rb
|
226
237
|
- lib/tabbyx/helpers/minitest_helper.rb
|
227
238
|
- lib/tabbyx/helpers/screenshot_helpers.rb
|
239
|
+
- lib/tabbyx/helpers/test_helper.rb
|
228
240
|
- lib/tabbyx/helpers/txt_helper.rb
|
229
241
|
- lib/tabbyx/steps_android/assert_steps.rb
|
230
242
|
- lib/tabbyx/steps_android/check_box_steps.rb
|
@@ -233,6 +245,7 @@ files:
|
|
233
245
|
- lib/tabbyx/steps_android/enter_text_steps.rb
|
234
246
|
- lib/tabbyx/steps_android/location_steps.rb
|
235
247
|
- lib/tabbyx/steps_android/navigation_steps.rb
|
248
|
+
- lib/tabbyx/steps_android/performance_steps.rb
|
236
249
|
- lib/tabbyx/steps_android/press_button_steps.rb
|
237
250
|
- lib/tabbyx/steps_android/progress_steps.rb
|
238
251
|
- lib/tabbyx/steps_android/search_steps.rb
|
@@ -243,7 +256,6 @@ files:
|
|
243
256
|
- lib/tabbyx/steps_ios/wait.rb
|
244
257
|
- lib/tabbyx/utils/adb_devices.rb
|
245
258
|
- lib/tabbyx/utils/adb_screenshot.rb
|
246
|
-
- lib/tabbyx/utils/code_coverage.rb
|
247
259
|
- lib/tabbyx/utils/shell.rb
|
248
260
|
- lib/tabbyx/version.rb
|
249
261
|
homepage: https://github.com/angeliaw/tabbyx
|