emu_ctl 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 70b6267618c425101056703bb2c0a0f1b9853ee5
4
+ data.tar.gz: afbe4dab8a920e3eae6c07c46ee5c04a7c2c6333
5
+ SHA512:
6
+ metadata.gz: 05bc213291c3c847fa10d36f67c00bc921720c3f7e98f813f51231d613e9f95e2815416d732ebf6143e20dd93c88abd65aec80d317f0bf3b74ffd79f951ac864
7
+ data.tar.gz: 14f903eafb516e901e18d2fac8611673cb188ad0e654635047fc9fbaf51d9024c27789de1859d80c0b156fc795372470e6868bc886aa16868bc0e2404f9a92af
data/.gitignore ADDED
@@ -0,0 +1,39 @@
1
+ # Created by https://www.gitignore.io
2
+
3
+ ### Ruby ###
4
+ *.gem
5
+ *.rbc
6
+ /.config
7
+ /coverage/
8
+ /InstalledFiles
9
+ /pkg/
10
+ /spec/reports/
11
+ /test/tmp/
12
+ /test/version_tmp/
13
+ /tmp/
14
+
15
+ ## Specific to RubyMotion:
16
+ .dat*
17
+ .repl_history
18
+ build/
19
+
20
+ ## Documentation cache and generated files:
21
+ /.yardoc/
22
+ /_yardoc/
23
+ /doc/
24
+ /rdoc/
25
+
26
+ ## Environment normalisation:
27
+ /.bundle/
28
+ /vendor/bundle
29
+ /lib/bundler/man/
30
+
31
+ # for a library or gem, you might want to ignore these files since the code is
32
+ # intended to run in multiple environments; otherwise, check them in:
33
+ # Gemfile.lock
34
+ # .ruby-version
35
+ # .ruby-gemset
36
+
37
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
38
+ .rvmrc
39
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ emu_ctl (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ celluloid (0.16.0)
10
+ timers (~> 4.0.0)
11
+ coderay (1.1.0)
12
+ diff-lcs (1.2.5)
13
+ ffi (1.9.8)
14
+ formatador (0.2.5)
15
+ guard (2.12.5)
16
+ formatador (>= 0.2.4)
17
+ listen (~> 2.7)
18
+ lumberjack (~> 1.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.9.12)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-rspec (4.5.0)
26
+ guard (~> 2.1)
27
+ guard-compat (~> 1.1)
28
+ rspec (>= 2.99.0, < 4.0)
29
+ hitimes (1.2.2)
30
+ listen (2.10.0)
31
+ celluloid (~> 0.16.0)
32
+ rb-fsevent (>= 0.9.3)
33
+ rb-inotify (>= 0.9)
34
+ lumberjack (1.0.9)
35
+ method_source (0.8.2)
36
+ nenv (0.2.0)
37
+ notiffany (0.0.6)
38
+ nenv (~> 0.1)
39
+ shellany (~> 0.0)
40
+ pry (0.10.1)
41
+ coderay (~> 1.1.0)
42
+ method_source (~> 0.8.1)
43
+ slop (~> 3.4)
44
+ rake (10.4.2)
45
+ rb-fsevent (0.9.4)
46
+ rb-inotify (0.9.5)
47
+ ffi (>= 0.5.0)
48
+ rspec (3.2.0)
49
+ rspec-core (~> 3.2.0)
50
+ rspec-expectations (~> 3.2.0)
51
+ rspec-mocks (~> 3.2.0)
52
+ rspec-core (3.2.3)
53
+ rspec-support (~> 3.2.0)
54
+ rspec-expectations (3.2.1)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.2.0)
57
+ rspec-mocks (3.2.1)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.2.0)
60
+ rspec-support (3.2.2)
61
+ shellany (0.0.1)
62
+ slop (3.6.0)
63
+ thor (0.19.1)
64
+ timers (4.0.1)
65
+ hitimes
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bundler (~> 1.8)
72
+ emu_ctl!
73
+ guard-rspec
74
+ rake (~> 10.0)
75
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ directories %w(lib spec bin)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
76
+ end
77
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Nemo Oudeis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Emulator Control
2
+
3
+ Commandline util to maintain android emulators on headless machines (or just without window in gerneral).
4
+
5
+ # NOT READY FOR PRODUCTION
6
+
7
+ ## WHY?
8
+
9
+ Using the android emulator on CI is painful. For jenkins there is a nice emulator plugin, but unfortunately it is not very reliable, emulators tend to break for no reason and manual cleanup work becomes necessary. This gem makes the emulator scriptable so you have more control what happens with the emulator for CI
10
+
11
+ ## Installation
12
+
13
+ $ gem install emu_ctl
14
+
15
+ ## Usage
16
+
17
+ $ emu_ctl
18
+ Usage:
19
+ emu_ctl list prints all available emulators
20
+ emu_ctl running shows all running emulators
21
+ emu_ctl kill kills all running emulators
22
+ emu_ctl launch ID runs the emulator with ID,
23
+ ID is an integer form the output of `list`
24
+ emu_ctl targets shows all possible targets and skins, will only display targets with abi
25
+ emu_ctl new ID SKIN creates a new avd with API level according to ID and skin SKIN
26
+ check `targets` for possible values (depends on installed sdk packages)
27
+ Only works for targets with default abi
28
+ emu_ctl rm ID deletes avd with ID returned in list
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task :default => :spec
data/bin/emu_ctl ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+ require 'emu_ctl'
3
+ require 'rubygems'
4
+ require 'open3'
5
+
6
+ #
7
+ # starts up android emulator on headless unix machine
8
+ # can only handle 1 emulator at a time
9
+ # needs adb, android and emulator on the path (from Android SDK)
10
+ #
11
+
12
+ usage = "
13
+ Usage:
14
+ #{File.basename($0)} list prints all available emulators
15
+ #{File.basename($0)} running shows all running emulators
16
+ #{File.basename($0)} kill kills all running emulators
17
+ #{File.basename($0)} launch ID runs the emulator with ID,
18
+ ID is an integer form the output of `list`
19
+ #{File.basename($0)} targets shows all possible targets and skins, will only display targets with abi
20
+ #{File.basename($0)} new ID SKIN creates a new avd with API level according to ID and skin SKIN
21
+ check `targets` for possible values (depends on installed sdk packages)
22
+ Only works for targets with default abi
23
+ #{File.basename($0)} rm ID deletes avd with ID returned in list"
24
+
25
+ # command line args
26
+ if ARGV.empty?
27
+ puts "You need to specify an action"
28
+ puts "#{usage}"
29
+ exit(2)
30
+ end
31
+
32
+ action = ARGV.shift
33
+ case action
34
+ when 'kill'
35
+ pids = EmuCtl::Emulator.running_pids
36
+ puts "found running emulators with pid: #{pids}"
37
+ EmuCtl::Emulator.kill_all
38
+ puts "killed all emulators"
39
+ when 'list'
40
+ emus = EmuCtl::Emulator.list
41
+ puts emus.map{ |o| "#{emus.index(o)} - #{o.to_s}" }.join("\n")
42
+ when 'launch'
43
+ raise "you need to specify the emulator id\n#{usage}" if ARGV.empty?
44
+ index = ARGV.shift.to_i
45
+ emu = EmuCtl::Emulator.list[index]
46
+ EmuCtl::Emulator.start(emu)
47
+ when 'targets'
48
+ targets = EmuCtl::Emulator.list_targets
49
+ puts targets.map{ |o| "#{targets.index(o)} - #{o.to_s}" }.join("\n")
50
+ when 'new'
51
+ target_index = ARGV.shift.to_i
52
+ skin = ARGV.shift
53
+ raise "you need to specify target and skin" if target_index.nil? || skin.nil?
54
+ target = EmuCtl::Emulator.list_targets[target_index]
55
+ puts "creating new avd from #{target.id} with skin #{skin}"
56
+ EmuCtl::Emulator.create(target, skin)
57
+ when 'running'
58
+ puts EmuCtl::ADB.devices
59
+ when 'rm'
60
+ emu_index = ARGV.shift
61
+ raise 'you need to specify the emulator id' if emu_index.nil?
62
+ emu = EmuCtl::Emulator.list[Integer(emu_index)]
63
+ puts "deleting: #{emu}"
64
+ EmuCtl::Emulator.delete(emu)
65
+ else
66
+ raise "unknown action #{action}\n#{usage}"
67
+ end
data/emu_ctl.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "emu_ctl/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "emu_ctl"
8
+ s.version = EmuCtl::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Nemo Oudeis"]
11
+ s.email = ["nemo@oudeis.eu"]
12
+ s.homepage = "https://github.com/NemoOudeis/EmulatorControl"
13
+ s.summary = %q{command line tool to easily control android emulators}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.post_install_message = <<-EOS
21
+
22
+ ****************************************************
23
+ * emu_ctl expects the Android SDK on your $PATH. *
24
+ * (at least `android` and `adb`) *
25
+ ****************************************************
26
+
27
+ EOS
28
+
29
+ s.add_development_dependency "rspec", "~> 3.2.0"
30
+ s.add_development_dependency "bundler", "~> 1.8"
31
+ s.add_development_dependency "rake", "~> 10.0"
32
+ s.add_development_dependency "guard-rspec", "~> 4.5.0"
33
+ end
@@ -0,0 +1,20 @@
1
+ module EmuCtl
2
+ class ADB
3
+ def self.devices
4
+ _, stdout, _ = Open3.popen3('adb devices')
5
+ lines = []
6
+ stdout.each_line { |l| lines.push(l) }
7
+ lines.join
8
+ end
9
+
10
+ def self.boot_complete?
11
+ _, stdout, stderr = Open3.popen3('adb shell getprop dev.bootcomplete')
12
+ return stderr.gets.nil?
13
+ end
14
+
15
+ def self.unlock_emulator
16
+ system 'adb shell input keyevent 82'
17
+ system 'adb shell input keyevent 4'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,68 @@
1
+ module EmuCtl
2
+ class Emulator
3
+ @@EMU_TIMEOUT = 180
4
+
5
+ def self.start(emu)
6
+ raise 'invalid name: nil' if emu.name.nil?
7
+ puts "starting emulator: #{emu}"
8
+ puts "emulator -no-boot-anim -avd #{emu.name} -no-snapshot-load -no-snapshot-save -no-window"
9
+ system "emulator -no-boot-anim -avd #{emu.name} -no-snapshot-load -no-snapshot-save -no-window &"
10
+ starting_up = true
11
+
12
+ start = Time.now
13
+ until ADB.boot_complete?
14
+ sleep 2
15
+ ellapsed = Time.now - start
16
+ print "\r"
17
+ print "Waiting for emulator " + "."*(ellapsed/2).to_i
18
+ STDOUT.flush
19
+ abort "unable to start emulator for #{@@EMU_TIMEOUT/60} minutes" if Time.now - start > @@EMU_TIMEOUT
20
+ end
21
+
22
+ puts ''
23
+ puts 'emulator up and running'
24
+ puts ADB.devices
25
+
26
+ puts 'unlocking screen'
27
+ ADB.unlock_emulator
28
+ puts 'emulator ready'
29
+ end
30
+
31
+ def self.list
32
+ _, stdout, _ = Open3.popen3('android list avd')
33
+ lines = []
34
+ stdout.each_line { |l| lines.push(l) }
35
+ lines.join.split('---------').map { |desc| Avd.new(desc) }
36
+ end
37
+
38
+ def self.list_targets(filter = true)
39
+ _, stdout, _ = Open3.popen3('android list targets')
40
+ lines = []
41
+ stdout.each_line { |l| lines.push(l) }
42
+ target_descs = lines.join.split('----------').select { |t| t.include?('id: ') }
43
+ target_descs.map { |desc| Target.new(desc) }.select{|t| t.abi.nil? == false && filter}
44
+ end
45
+
46
+ def self.create(target, skin)
47
+ escaped_id = target.id.gsub(/(\s|:)/,'-')
48
+ cmd = "android create avd -n emu_#{escaped_id}_#{skin} -t \"#{target.id}\" -s #{skin}"
49
+ puts cmd
50
+ system cmd
51
+ end
52
+
53
+ def self.delete(emu)
54
+ system "android delete avd -n #{emu.name}"
55
+ end
56
+
57
+ def self.running_pids
58
+ _, stdout, _ = Open3.popen3("pgrep 'emulator'")
59
+ pids = []
60
+ stdout.each_line { |l| pids.push(l.strip) }
61
+ pids
62
+ end
63
+
64
+ def self.kill_all
65
+ Emulator.running_pids.each { |pid| system "kill -9 #{pid}" }
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,41 @@
1
+ module EmuCtl
2
+
3
+ class Target
4
+ attr_accessor(:id, :name, :skins, :abi, :api_lvl)
5
+
6
+ def initialize(desc)
7
+ @lines = desc.split("\n")
8
+ @id = /id: \d+ .* "(.+)"/.match(desc)[1]
9
+ @name = /Name: (.+)/.match(desc)[1]
10
+ @skins = /Skins: (.*)/.match(desc)[1].split(',').map{|n| n.strip}
11
+ @abi = /ABIs : (.+)/.match(desc)[1]
12
+ @abi = nil if @abi.include?('no ABIs.')
13
+ @api_lvl = /API level.? (\d+)/.match(desc)[1].to_i
14
+ end
15
+
16
+ def to_s
17
+ "#{@id}\n\tName: #{@name}\n\t#{@skins}\n\tABI: #{abi}"
18
+ end
19
+ end
20
+
21
+ class Avd
22
+ attr_accessor(:name, :target, :abi, :skin)
23
+
24
+ def initialize(desc)
25
+ @lines = desc.split("\n")
26
+ @name = /Name: (.+)/.match(desc)[1]
27
+ @skin = /Skin: (.+)/.match(desc)[1]
28
+ @target = /Target: (.+)/.match(desc)[1]
29
+ @abi = /Tag\/ABI: (.+)/.match(desc)[1]
30
+ end
31
+
32
+ def has_id?(id)
33
+ puts "checking me '#{@name}' for '#{id}'"
34
+ @name.include?(id)
35
+ end
36
+
37
+ def to_s
38
+ "#{@name}"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module EmuCtl
2
+ VERSION = "0.0.2"
3
+ end
data/lib/emu_ctl.rb ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'emu_ctl/adb'
3
+ require 'emu_ctl/emulator'
4
+ require 'emu_ctl/model'
5
+ require 'open3'
data/spec/adb_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "emu_ctl"
2
+
3
+ RSpec.describe EmuCtl::ADB do
4
+ describe 'lists', :wip => true do
5
+ it 'looks up running emulators' do
6
+ devices = EmuCtl::ADB.devices
7
+ puts devices
8
+ expect(devices).to_not be_nil
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ require "emu_ctl"
2
+
3
+ RSpec.describe EmuCtl::Emulator do
4
+ describe 'lists' do
5
+ it 'looks up existings avds' do
6
+ expect(EmuCtl::Emulator.list).to_not be_nil
7
+ end
8
+
9
+ it 'looks up available targets' do
10
+ expect(EmuCtl::Emulator.list_targets).to_not be_nil
11
+ end
12
+ end
13
+
14
+ describe 'emulator creation and deletion' do
15
+ it 'creates new emulator' do
16
+ old_list = EmuCtl::Emulator.list
17
+ # only targets with default abi
18
+ target = EmuCtl::Emulator.list_targets.select{|t| t.abi.include?('default')}.last
19
+ puts "creating emulator for target #{target.name} and skin #{target.skins[0]}"
20
+
21
+ EmuCtl::Emulator.create(target, target.skins[0])
22
+ expect(EmuCtl::Emulator.list.count).to eq(old_list.count + 1)
23
+ end
24
+
25
+ it 'deletes emulators' do
26
+ old_list = EmuCtl::Emulator.list
27
+ emu = old_list.last
28
+ puts "deleting emulator #{emu}"
29
+ EmuCtl::Emulator.delete(emu)
30
+ expect(EmuCtl::Emulator.list.count).to eq(old_list.count - 1)
31
+ end
32
+
33
+ it 'looks up available targets' do
34
+ expect(EmuCtl::Emulator.list_targets).to_not be_nil
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,94 @@
1
+ require "emu_ctl"
2
+
3
+ RSpec.describe EmuCtl::Target do
4
+ describe 'init' do
5
+ conosole_output = "
6
+ id: 1 or \"android-14\"
7
+ Name: Android 4.0
8
+ Type: Platform
9
+ API level: 14
10
+ Revision: 4
11
+ Skins: HVGA, QVGA, WQVGA400, WVGA800 (default)
12
+ Tag/ABIs : no ABIs.
13
+ "
14
+
15
+ it 'parses console output of `android list target`' do
16
+ target = EmuCtl::Target.new(conosole_output)
17
+ expect(target.id).to eq("android-14")
18
+ expect(target.name).to eq("Android 4.0")
19
+ end
20
+
21
+ it 'converts skins into string list' do
22
+ target = EmuCtl::Target.new(conosole_output)
23
+ expect(target.skins).to eq(['HVGA', 'QVGA', 'WQVGA400', 'WVGA800 (default)'])
24
+ end
25
+
26
+ it 'converts "API level" to integer' do
27
+ target = EmuCtl::Target.new(conosole_output)
28
+ expect(target.api_lvl).to eq(14)
29
+ end
30
+
31
+ it 'converts "no ABIs" to nil' do
32
+ target = EmuCtl::Target.new(conosole_output)
33
+ expect(target.abi).to eq(nil)
34
+ end
35
+
36
+ conosole_output2 = "
37
+ id: 13 or \"Google Inc.:Google APIs:18\"
38
+ Name: Google APIs
39
+ Type: Add-On
40
+ Vendor: Google Inc.
41
+ Revision: 3
42
+ Description: Android + Google APIs
43
+ Based on Android 4.3.1 (API level 18)
44
+ Libraries:
45
+ * com.google.android.media.effects (effects.jar)
46
+ Collection of video effects
47
+ * com.android.future.usb.accessory (usb.jar)
48
+ API for USB Accessories
49
+ * com.google.android.maps (maps.jar)
50
+ API for Google Maps
51
+ Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
52
+ Tag/ABIs : default/armeabi-v7a"
53
+
54
+ it 'recognizes Based on `Android X.Y.Z (API level XX)` correctly' do
55
+ target = EmuCtl::Target.new(conosole_output2)
56
+ expect(target.api_lvl).to eq(18)
57
+ end
58
+ end
59
+ end
60
+
61
+
62
+ RSpec.describe EmuCtl::Avd do
63
+ describe 'init' do
64
+ conosole_output = "
65
+ Name: ci_avd
66
+ Path: /Users/Dave/.android/avd/ci_avd.avd
67
+ Target: Android 4.1.2 (API level 16)
68
+ Tag/ABI: default/armeabi-v7a
69
+ Skin: WVGA800
70
+ "
71
+
72
+ it 'parses console output of `android list avd`' do
73
+ avd = EmuCtl::Avd.new(conosole_output)
74
+ expect(avd.name).to eq("ci_avd")
75
+ end
76
+
77
+ it 'parses skin' do
78
+ avd = EmuCtl::Avd.new(conosole_output)
79
+ expect(avd.skin).to eq('WVGA800')
80
+ end
81
+
82
+ it 'parses abi' do
83
+ avd = EmuCtl::Avd.new(conosole_output)
84
+ expect(avd.abi).to eq('default/armeabi-v7a')
85
+ end
86
+
87
+ it 'parses target' do
88
+ avd = EmuCtl::Avd.new(conosole_output)
89
+ expect(avd.target).to eq('Android 4.1.2 (API level 16)')
90
+ end
91
+ end
92
+ end
93
+
94
+
@@ -0,0 +1,94 @@
1
+ Bundler.setup
2
+ require 'emu_ctl'
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
7
+ # this file to always be loaded, without a need to explicitly require it in any
8
+ # files.
9
+ #
10
+ # Given that it is always loaded, you are encouraged to keep this file as
11
+ # light-weight as possible. Requiring heavyweight dependencies from this file
12
+ # will add to the boot time of your test suite on EVERY test run, even for an
13
+ # individual file that may not need all of that loaded. Instead, consider making
14
+ # a separate helper file that requires the additional dependencies and performs
15
+ # the additional setup, and require it from the spec files that actually need
16
+ # it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is
57
+ # recommended. For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # This setting enables warnings. It's recommended, but in some cases may
64
+ # be too noisy due to issues in dependencies.
65
+ config.warnings = true
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = 'doc'
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emu_ctl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nemo Oudeis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.5.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.5.0
69
+ description:
70
+ email:
71
+ - nemo@oudeis.eu
72
+ executables:
73
+ - emu_ctl
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - Guardfile
82
+ - LICENSE
83
+ - README.md
84
+ - Rakefile
85
+ - bin/emu_ctl
86
+ - emu_ctl.gemspec
87
+ - lib/emu_ctl.rb
88
+ - lib/emu_ctl/adb.rb
89
+ - lib/emu_ctl/emulator.rb
90
+ - lib/emu_ctl/model.rb
91
+ - lib/emu_ctl/version.rb
92
+ - spec/adb_spec.rb
93
+ - spec/emulator_spec.rb
94
+ - spec/model_spec.rb
95
+ - spec/spec_helper.rb
96
+ homepage: https://github.com/NemoOudeis/EmulatorControl
97
+ licenses: []
98
+ metadata: {}
99
+ post_install_message: |2+
100
+
101
+ ****************************************************
102
+ * emu_ctl expects the Android SDK on your $PATH. *
103
+ * (at least `android` and `adb`) *
104
+ ****************************************************
105
+
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.6
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: command line tool to easily control android emulators
125
+ test_files:
126
+ - spec/adb_spec.rb
127
+ - spec/emulator_spec.rb
128
+ - spec/model_spec.rb
129
+ - spec/spec_helper.rb