uiauto 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed1dc6ce64fc2949895916755c61d112f34cf5c0
4
- data.tar.gz: 020fca7e5018461aa99f95f24447ffefb6db9dfe
3
+ metadata.gz: b13ad5de892dd0145639a2f46bfc12a3d6555535
4
+ data.tar.gz: 0b3a7d825433f830e6bb0ced19bce989d033a28b
5
5
  SHA512:
6
- metadata.gz: 805e4f7309178911232396a1ff6c01c318a3754b1adfaac1886828b203161be761406295d5d932062d20dce61fc7946cbe615a7193a36cf168a844e5bc27cd3d
7
- data.tar.gz: 013447062aa6df1bffc1502a15ef42bbf42dcddf0f5e76e2d42fa9c09df0c7774c0c5379f05ed3b4dc67a45db2d71926866dee9a8538edee4bdd437d23178147
6
+ metadata.gz: 8334839a2bf68692b91729130c0951d4d97837020709a23b32acf21d70ad2ee809c5d1c9644332e38f3fad2ed438983787c7071ed281043cfe17ec8957f845fc
7
+ data.tar.gz: eacf0342d04567d12ee38caf0402567631f9ad46a31ca0a6d77aa4307cf685cc24121363d6d37483d3ddf4db54de742a2d79b080b55f93014828e562c815fa8d
data/README.md CHANGED
@@ -4,8 +4,6 @@ UIAuto is a command line tool for running UI Automation scripts. It improves App
4
4
 
5
5
  UIAuto also facilitates the setup of simulator data for running scripts in a repeatable and known state.
6
6
 
7
- Note: UIAuto only works with the simulator for now.
8
-
9
7
  ## Prerequisites
10
8
 
11
9
  * Xcode command line tools
@@ -24,7 +22,7 @@ UIAuto does not build your app. You can use Xcode or `xcodebuild`.
24
22
 
25
23
  #### With Xcode
26
24
 
27
- The easiest way to build your app for UIAuto is to use Xcode. Open your app in Xcode, select the simulator, then build your project (command+b). This builds your app and places the resulting bundle in derived data.
25
+ The easiest way to build your app for UIAuto is to use Xcode. Open your app in Xcode then build your project (command+b). This builds your app and places the resulting bundle in derived data.
28
26
 
29
27
  #### With xcodebuild
30
28
 
@@ -36,7 +34,7 @@ You can build from the command line using `xcodebuild`. The following examples s
36
34
  # Example using xcodebuild to build a project
37
35
  $ xcodebuild -project MyApp.xcodeproj -sdk iphonesimulator6.1
38
36
 
39
- By building with the commands above, the resulting bundle is placed in derived data.
37
+ By building with the commands above, the resulting bundle is placed in derived data. Replace `iphonesimulator6.1` with `iphoneos6.1` if you want to build for the device.
40
38
 
41
39
  ### Run UI Automation scripts
42
40
 
@@ -64,10 +62,20 @@ Running `uiauto help exec` prints the following message.
64
62
 
65
63
  [--app=APP]
66
64
 
65
+ [--device=DEVICE]
66
+
67
67
  If you build your app outside of derived data, then you can specify the `--app` flag to tell uiauto where to find the `*.app`. You can also override the default locations for the trace file and results. For example, if your build your app in a build directory you can run the following
68
68
 
69
69
  uiauto exec uiauto/scripts/script_to_run.js --app=build/MyApp.app
70
70
 
71
+ Pass the `--device` flag to run on the device.
72
+
73
+ # Run on a connected device
74
+ $ uiauto exec uiauto/scripts/script_to_run.js --device
75
+
76
+ # Run on a connected device with a specific udid
77
+ $ uiauto exec uiauto/scripts/script_to_run.js --device=UDID
78
+
71
79
  ### Simulator data
72
80
 
73
81
  UIAuto's `simulator` subcommand allows you to setup the simulator's applications, settings, and data. This is done by taking a "snapshot" of the simulator's current data by saving the `~/Library/Application Support/iPhone Simulator/(SDK VERSION)/` directory somewhere, then loading it back in when needed.
data/lib/uiauto/cli.rb CHANGED
@@ -43,6 +43,7 @@ module UIAuto
43
43
  method_option :results, :default => File.expand_path("./uiauto/results")
44
44
  method_option :trace, :default => File.expand_path("./uiauto/results/trace")
45
45
  method_option :app
46
+ method_option :device
46
47
  def exec(file_or_dir = "./uiauto/scripts/")
47
48
  Runner.run(file_or_dir, options)
48
49
  end
@@ -4,12 +4,13 @@ require 'cfpropertylist'
4
4
 
5
5
  module UIAuto
6
6
  class Instruments
7
- attr_accessor :trace, :app, :results, :script
7
+ attr_accessor :trace, :app, :results, :script, :device
8
8
 
9
9
  def initialize(script, opts = {})
10
10
  @script = script
11
11
  @trace = opts[:trace]
12
12
  @results = opts[:results]
13
+ @device = opts[:device]
13
14
  @app = opts[:app] || default_application
14
15
 
15
16
  FileUtils.mkdir_p(@results) unless File.exists?(@results)
@@ -17,6 +18,7 @@ module UIAuto
17
18
 
18
19
  def command
19
20
  command = ["xcrun instruments"]
21
+ command << "-w #{device_id}" if device_id
20
22
  command << "-D #{@trace}"
21
23
  command << "-t #{automation_template_location}"
22
24
  command << @app
@@ -67,9 +69,9 @@ module UIAuto
67
69
  end
68
70
  end
69
71
 
70
- # TODO: Add support for running on a device
71
72
  sorted_matches = matching_directories.sort_by { |dir| File.mtime(dir) }
72
- Dir.glob(File.join(sorted_matches.last, "Build/Products/*-iphonesimulator/*.app")).sort_by { |dir| File.mtime(dir) }.last
73
+ build_products_directory = device_id ? "Build/Products/*-iphoneos/*.app" : "Build/Products/*-iphonesimulator/*.app"
74
+ Dir.glob(File.join(sorted_matches.last, build_products_directory)).sort_by { |dir| File.mtime(dir) }.last
73
75
  end
74
76
 
75
77
  def automation_template_location
@@ -87,5 +89,16 @@ module UIAuto
87
89
  File.expand_path("~/Library/Developer/Xcode/DerivedData/")
88
90
  end
89
91
 
92
+ def device_id
93
+ @device_id ||= begin
94
+ if @device == 'device'
95
+ ioreg = `ioreg -w 0 -rc IOUSBDevice -k SupportsIPhoneOS`
96
+ ioreg[/"USB Serial Number" = "([0-9a-z]+)"/] && $1
97
+ else
98
+ @device
99
+ end
100
+ end
101
+ end
102
+
90
103
  end
91
104
  end
@@ -1,3 +1,3 @@
1
1
  module UIAuto
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uiauto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Enriquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-16 00:00:00.000000000 Z
11
+ date: 2013-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler