device_api-android 1.1.3 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc10f13dd26a8bb1dfb280a89a47fc53f0abaae8
4
- data.tar.gz: c055ac388b285256b3af8b64e43794943de19172
3
+ metadata.gz: 9e869674eefcdfc233369a21f2d14d11d27df450
4
+ data.tar.gz: 6da4897b07d21f066230bd3bd9ada5f3240a6764
5
5
  SHA512:
6
- metadata.gz: bbad38ebff1f0ce2b03194034151f33e23be15aff5fe3a3caf892994be7423900bf91cbb3ead9e50f78c88eba0e56733cc00a32812dde55f7602900ce6981363
7
- data.tar.gz: f0d33b10a999afd50bc6d9fd50377e5c8d0c30acf00d5ea4a88c7b8252205eccfb8834c2073ee4aa4487b4331f560cc5f94c6f97c4726fc94d331c9d17d2274a
6
+ metadata.gz: e543135408a47beef36b487b98d481235120f441df30af60aae043a5775ae1d131fc9cd9ca802f91977a3e258956c8d4f1677d78b930a42bc965c56dfd8d9bbe
7
+ data.tar.gz: f62b5e92503750c0bdd704295761b7189aa1e2e4193e41f1c7611201f689d32581621463b2234f662fc5fe95fc480a715a5bf0e4a0edefcba9b570917d356f91
@@ -42,7 +42,7 @@ module DeviceAPI
42
42
 
43
43
  raise ADBCommandError.new(result.stderr) if result.exit != 0
44
44
 
45
- lines = result.stdout.split("\n")
45
+ lines = result.stdout.encode('UTF-8', invalid: :replace).split("\n")
46
46
 
47
47
  process_dumpsys('\[(.*)\]:\s+\[(.*)\]', lines)
48
48
  end
@@ -35,7 +35,8 @@ module DeviceAPI
35
35
  {
36
36
  'device' => :ok,
37
37
  'no device' => :dead,
38
- 'offline' => :offline
38
+ 'offline' => :offline,
39
+ 'unauthorized' => :unauthorized
39
40
  }[@state]
40
41
  end
41
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: device_api-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Buckhurst
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-07 00:00:00.000000000 Z
13
+ date: 2015-10-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: device_api
@@ -52,13 +52,7 @@ executables: []
52
52
  extensions: []
53
53
  extra_rdoc_files: []
54
54
  files:
55
- - ".gitignore"
56
- - 51-android.rules
57
- - Gemfile
58
- - Gemfile.lock
59
- - LICENSE
60
55
  - README.md
61
- - device_api-android.gemspec
62
56
  - lib/device_api/android.rb
63
57
  - lib/device_api/android/aapt.rb
64
58
  - lib/device_api/android/adb.rb
@@ -68,10 +62,6 @@ files:
68
62
  - lib/device_api/android/plugins/disk.rb
69
63
  - lib/device_api/android/plugins/memory.rb
70
64
  - lib/device_api/android/signing.rb
71
- - spec/adb_spec.rb
72
- - spec/android_device_spec.rb
73
- - spec/android_spec.rb
74
- - spec/helpers/stub_helper_spec.rb
75
65
  homepage: https://github.com/bbc/device_api-android
76
66
  licenses:
77
67
  - MIT
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- .idea
2
-
data/51-android.rules DELETED
@@ -1,62 +0,0 @@
1
- # adb protocol on passion (Nexus One)
2
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="hive"
3
- # fastboot protocol on passion (Nexus One)
4
- SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="hive"
5
- # adb protocol on crespo/crespo4g (Nexus S)
6
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="hive"
7
- # fastboot protocol on crespo/crespo4g (Nexus S)
8
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="hive"
9
- # adb protocol on stingray/wingray (Xoom)
10
- SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="hive"
11
- # fastboot protocol on stingray/wingray (Xoom)
12
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="hive"
13
- # adb protocol on maguro/toro (Galaxy Nexus)
14
- SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="hive"
15
- # fastboot protocol on maguro/toro (Galaxy Nexus)
16
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="hive"
17
- # adb protocol on panda (PandaBoard)
18
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="hive"
19
- # adb protocol on panda (PandaBoard ES)
20
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="hive"
21
- # fastboot protocol on panda (PandaBoard)
22
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="hive"
23
- # usbboot protocol on panda (PandaBoard)
24
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="hive"
25
- # usbboot protocol on panda (PandaBoard ES)
26
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="hive"
27
- # adb protocol on grouper/tilapia (Nexus 7)
28
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="hive"
29
- # fastboot protocol on grouper/tilapia (Nexus 7)
30
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="hive"
31
- # adb protocol on manta (Nexus 10)
32
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="hive"
33
- # fastboot protocol on manta (Nexus 10)
34
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="hive"
35
- # moto G 22b8:2e76
36
- SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e76", MODE="0666", OWNER="hive"
37
- # Oneplus One
38
- SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", ATTR{idProduct}=="6765", MODE="0666", OWNER="hive"
39
- # Tesco Hudl
40
- SUBSYSTEM=="usb", ATTR{idVendor}=="0e79", ATTR{idProduct}=="5009", MODE="0666", OWNER="hive"
41
- # Nexus 7 (Grouper)
42
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0666", OWNER="hive"
43
- # Nexus 7 (Flo)
44
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0666", OWNER="hive"
45
- # Kindle Fire HD 8.9"
46
- SUBSYSTEM=="usb", ATTR{idVendor}=="1949", ATTR{idProduct}=="0008", MODE="0666", OWNER="hive"
47
- # Kindle Fire
48
- SUBSYSTEM=="usb", ATTR{idVendor}=="1949", ATTR{idProduct}=="000b", MODE="0666", OWNER="hive"
49
- # Kindle Fire
50
- SUBSYSTEM=="usb", ATTR{idVendor}=="1949", ATTR{idProduct}=="000c", MODE="0666", OWNER="hive"
51
- # Kindle Fire (Pink Case)
52
- SUBSYSTEM=="usb", ATTR{idVendor}=="1949", ATTR{idProduct}=="00f2", MODE="0666", OWNER="hive"
53
- # Kindle Fire HDX 8.9 (3rd Generation) OS 4.5.5
54
- SUBSYSTEM=="usb", ATTR{idVendor}=="1949", ATTR{idProduct}=="000d", mode="0666", OWNER="hive"
55
- # Sony Ericsson ST25i
56
- SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", ATTR{idProduct}=="5171", MODE="0666", OWNER="hive"
57
- # Galaxy S2/S3
58
- SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="hive"
59
- # LG G2
60
- SUBSYSTEM=="usb", ATTR{idVendor}=="1004", ATTR{idProduct}=="631f", MODE="0666", OWNER="hive"
61
- # Tesco Hudl 2
62
- SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", ATTR{idProduct}=="504b", MODE="0666", OWNER="hive"
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'device_api', '>=1.0.0'
4
-
5
- group :test do
6
- gem 'rspec'
7
- end
data/Gemfile.lock DELETED
@@ -1,25 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- device_api (1.0.1)
5
- diff-lcs (1.2.5)
6
- rspec (3.3.0)
7
- rspec-core (~> 3.3.0)
8
- rspec-expectations (~> 3.3.0)
9
- rspec-mocks (~> 3.3.0)
10
- rspec-core (3.3.1)
11
- rspec-support (~> 3.3.0)
12
- rspec-expectations (3.3.0)
13
- diff-lcs (>= 1.2.0, < 2.0)
14
- rspec-support (~> 3.3.0)
15
- rspec-mocks (3.3.1)
16
- diff-lcs (>= 1.2.0, < 2.0)
17
- rspec-support (~> 3.3.0)
18
- rspec-support (3.3.0)
19
-
20
- PLATFORMS
21
- ruby
22
-
23
- DEPENDENCIES
24
- device_api (>= 1.0.0)
25
- rspec
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 BBC
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 all
13
- 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 THE
21
- SOFTWARE.
@@ -1,14 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'device_api-android'
3
- s.version = '1.1.3'
4
- s.date = Time.now.strftime("%Y-%m-%d")
5
- s.summary = 'Android Device Management API'
6
- s.description = 'Android implementation of DeviceAPI'
7
- s.authors = ['David Buckhurst','Jitesh Gosai', 'Jon Wilson']
8
- s.email = 'david.buckhurst@bbc.co.uk'
9
- s.files = `git ls-files`.split "\n"
10
- s.homepage = 'https://github.com/bbc/device_api-android'
11
- s.license = 'MIT'
12
- s.add_runtime_dependency 'device_api', '>=1.0', '<2.0'
13
- s.add_development_dependency 'rspec'
14
- end
data/spec/adb_spec.rb DELETED
@@ -1,157 +0,0 @@
1
- $LOAD_PATH.unshift('./lib/')
2
-
3
- require 'device_api'
4
- require 'device_api/android/adb'
5
-
6
- include RSpec
7
-
8
- #
9
- #
10
- # FIRST
11
- describe DeviceAPI::Android::ADB do
12
- describe '.devices' do
13
-
14
- it 'returns an empty array when there are no devices' do
15
- out = <<eos
16
- List of devices attached
17
-
18
-
19
- eos
20
- allow(Open3).to receive(:capture3) {
21
- [out, '', $STATUS_ZERO]
22
- }
23
- expect(DeviceAPI::Android::ADB.devices).to eq([])
24
- end
25
-
26
- it "returns an array with a single item when there's one device attached" do
27
- out = <<_______________________________________________________
28
- List of devices attached
29
- SH34RW905290 device
30
-
31
- _______________________________________________________
32
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
33
- expect(DeviceAPI::Android::ADB.devices).to eq([{ 'SH34RW905290' => 'device' }])
34
- end
35
-
36
- it 'returns an an array with multiple items when there are multiple items attached' do
37
- out = <<_______________________________________________________
38
- List of devices attached
39
- SH34RW905290 device
40
- 123456324 no device
41
-
42
- _______________________________________________________
43
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
44
- expect(DeviceAPI::Android::ADB.devices).to eq([{ 'SH34RW905290' => 'device' }, { '123456324' => 'no device' }])
45
- end
46
-
47
- it 'can deal with extra output when adb starts up' do
48
- out = <<_______________________________________________________
49
- * daemon not running. starting it now on port 5037 *
50
- * daemon started successfully *
51
- List of devices attached
52
- SH34RW905290 device
53
- _______________________________________________________
54
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
55
- expect(DeviceAPI::Android::ADB.devices).to eq([{ 'SH34RW905290' => 'device' }])
56
- end
57
-
58
- it 'can deal with no devices connected' do
59
- allow(Open3).to receive(:capture3) { ["error: device not found\n", '', $STATUS_ZERO] }
60
- expect(DeviceAPI::Android::ADB.devices).to be_empty
61
- end
62
- end
63
-
64
- describe ".get_uptime" do
65
- it "can process an uptime" do
66
- out = <<_______________________________________________________
67
- 12307.23 48052.0
68
- _______________________________________________________
69
- allow(Open3).to receive(:capture3) { [ out, '', $STATUS_ZERO] }
70
- expect( DeviceAPI::Android::ADB.get_uptime('SH34RW905290')).to eq( 12307 )
71
- end
72
- end
73
-
74
- describe ".getprop" do
75
-
76
- it "Returns a hash of name value pair properties" do
77
- out = <<________________________________________________________
78
- [net.hostname]: [android-f1e4efe3286b0785]
79
- [dhcp.wlan0.ipaddress]: [10.0.1.34]
80
- [ro.build.version.release]: [4.1.2]
81
- [ro.build.version.sdk]: [16]
82
- [ro.product.bluetooth]: [4.0]
83
- [ro.product.device]: [m7]
84
- [ro.product.display_resolution]: [4.7 inch 1080p resolution]
85
- [ro.product.manufacturer]: [HTC]
86
- [ro.product.model]: [HTC One]
87
- [ro.product.name]: [m7]
88
- [ro.product.processor]: [Quadcore]
89
- [ro.product.ram]: [2GB]
90
- [ro.product.version]: [1.28.161.7]
91
- [ro.product.wifi]: [802.11 a/b/g/n/ac]
92
- [ro.revision]: [3]
93
- [ro.serialno]: [SH34RW905290]
94
- [ro.sf.lcd_density]: [480]
95
- ________________________________________________________
96
-
97
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
98
-
99
- props = DeviceAPI::Android::ADB.getprop('SH34RW905290')
100
-
101
- expect(props).to be_a Hash
102
- expect(props['ro.product.model']).to eq('HTC One')
103
- end
104
- end
105
-
106
- describe ".get_status" do
107
-
108
- it "Returns a state for a single device" do
109
- out = <<_______________________________________________________
110
- device
111
- _______________________________________________________
112
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
113
-
114
- state = DeviceAPI::Android::ADB.get_state('SH34RW905290')
115
-
116
- expect(state).to eq 'device'
117
- end
118
- end
119
-
120
- describe ".monkey" do
121
-
122
- it "Constructs and executes monkey command line" do
123
- out = <<_______________________________________________________
124
- ** Monkey aborted due to error.
125
- Events injected: 3082
126
- :Sending rotation degree=0, persist=false
127
- :Dropped: keys=88 pointers=180 trackballs=0 flips=0 rotations=0
128
- ## Network stats: elapsed time=14799ms (0ms mobile, 0ms wifi, 14799ms not connected)
129
- ** System appears to have crashed at event 3082 of 5000000 using seed 1409644708681
130
- end
131
- _______________________________________________________
132
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
133
-
134
- expect( DeviceAPI::Android::ADB.monkey( '1234323', :events => 5000, :package => 'my.app.package' )).to be_a OpenStruct
135
- end
136
- end
137
-
138
- describe ".wifi" do
139
- it "returns wifi info" do
140
- out= <<_______________________________________________________
141
- mNetworkInfo [type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "TVMP-DevNet", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false]
142
- _______________________________________________________
143
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
144
- expect( DeviceAPI::Android::ADB.wifi('12345').class).to eq(Hash)
145
- end
146
- end
147
-
148
- describe ".am" do
149
- it "returns the stdout" do
150
- out= <<_______________________________________________________
151
- Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
152
- _______________________________________________________
153
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
154
- expect( DeviceAPI::Android::ADB.am('03157df373208426' ,'12345').class).to eq(String)
155
- end
156
- end
157
- end
@@ -1,49 +0,0 @@
1
- require 'device_api/android'
2
- include RSpec
3
-
4
- describe DeviceAPI::Android do
5
-
6
- describe '.devices' do
7
-
8
- it 'Returns an empty array when no devices are connected' do
9
- out = <<_______________________________________________________
10
- List of devices attached
11
-
12
- _______________________________________________________
13
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
14
- expect(DeviceAPI::Android.devices).to eq([])
15
- end
16
-
17
- it "returns an array with a single item when there's one device attached" do
18
- out = <<_______________________________________________________
19
- List of devices attached
20
- SH34RW905290 device
21
-
22
- _______________________________________________________
23
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
24
-
25
- devices = DeviceAPI::Android.devices
26
-
27
- expect(devices.count).to eq(1)
28
- expect(devices[0]).to be_a DeviceAPI::Android::Device
29
- expect(devices[0].serial).to eq('SH34RW905290')
30
- expect(devices[0].status).to eq(:ok)
31
- end
32
- end
33
-
34
- describe ".device" do
35
-
36
- it "Returns an object representing a device" do
37
- out = <<_______________________________________________________
38
- device
39
- _______________________________________________________
40
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
41
-
42
- device = DeviceAPI::Android.device('SH34RW905290')
43
- expect(device).to be_a DeviceAPI::Android::Device
44
- expect(device.serial).to eq('SH34RW905290')
45
- expect(device.status).to eq(:ok)
46
- end
47
-
48
- end
49
- end
data/spec/android_spec.rb DELETED
@@ -1,207 +0,0 @@
1
- require 'device_api/android/device'
2
- include RSpec
3
-
4
- describe DeviceAPI::Android::Device do
5
-
6
- describe '.model' do
7
-
8
- it 'Returns model name' do
9
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
10
-
11
- allow(Open3).to receive(:capture3) { ['[ro.product.model]: [HTC One]\n', '', $STATUS_ZERO] }
12
- expect(device.model).to eq('HTC One')
13
- end
14
-
15
- end
16
-
17
- describe '.orientation' do
18
- it 'Returns portrait when device is portrait' do
19
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
20
- allow(Open3).to receive(:capture3) { ["SurfaceOrientation: 0\r\n", '', $STATUS_ZERO] }
21
-
22
- expect(device.orientation).
23
- to eq(:portrait)
24
- end
25
-
26
- it 'Returns landscape when device is landscape' do
27
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
28
- allow(Open3).to receive(:capture3) { ["SurfaceOrientation: 1\r\n", '', $STATUS_ZERO] }
29
-
30
- expect(device.orientation).
31
- to eq(:landscape)
32
- end
33
-
34
- it 'Returns landscape when device is landscape for a kindle Fire' do
35
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
36
- allow(Open3).to receive(:capture3) { ["SurfaceOrientation: 3\r\n", '', $STATUS_ZERO] }
37
-
38
- expect(device.orientation).
39
- to eq(:landscape)
40
- end
41
-
42
- it 'Returns an error if response not understood' do
43
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
44
-
45
- allow(Open3).to receive(:capture3) { ["SurfaceOrientation: 564654654\n", '', $STATUS_ZERO] }
46
-
47
- expect { device.orientation }.
48
- to raise_error(StandardError, 'Device orientation not returned got: 564654654.')
49
- end
50
-
51
- it 'Returns an error if no device found' do
52
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
53
-
54
- allow(Open3).to receive(:capture3) { ["error: device not found\n", '', $STATUS_ZERO] }
55
-
56
- expect { device.orientation }.
57
- to raise_error(StandardError, 'No output returned is there a device connected?')
58
- end
59
-
60
- it 'Can handle device orientation changes during a test' do
61
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
62
- landscape = "SurfaceOrientation: 1\r\n"
63
- portrait = "SurfaceOrientation: 0\r\n"
64
-
65
- allow(Open3).to receive(:capture3) { [portrait, '', $STATUS_ZERO] }
66
- expect(device.orientation).
67
- to eq(:portrait)
68
- allow(Open3).to receive(:capture3) { [landscape, '', $STATUS_ZERO] }
69
- expect(device.orientation).
70
- to eq(:landscape)
71
- end
72
-
73
- it 'Can filter on large amounts of adb output to find the correct value', type: 'adb' do
74
- out = <<_______________________________________________________
75
- uchMajor: min=0, max=15, flat=0, fuzz=0, resolution=0\r\n TouchMinor: unknown range\r\n
76
- ToolMajor: unknown range\r\n ToolMinor: unknown range\r\n Orientation: unknown range\r\n
77
- Distance: unknown range\r\n TiltX: unknown range\r\n TiltY: unknown range\r\n
78
- TrackingId: min=0, max=65535, flat=0, fuzz=0, resolution=0\r\n Slot: min=0, max=9, flat=0, fuzz=0,
79
- resolution=0\r\n Calibration:\r\n touch.size.calibration: diameter\r\n
80
- touch.size.scale: 22.500\r\n touch.size.bias: 0.000\r\n touch.size.isSummed: false\r\n
81
- touch.pressure.calibration: amplitude\r\n touch.pressure.scale: 0.013\r\n touch.orientation.calibration: none\r\n
82
- touch.distance.calibration: none\r\n touch.coverage.calibration: none\r\n Viewport: displayId=0, orientation=0,
83
- logicalFrame=[0, 0, 768, 1280], physicalFrame=[0, 0, 768, 1280], deviceSize=[768, 1280]\r\n SurfaceWidth: 768px\r\n
84
- SurfaceHeight: 1280px\r\n SurfaceLeft: 0\r\n SurfaceTop: 0\r\n SurfaceOrientation: 0\r\n
85
- Translation and Scaling Factors:\r\n XTranslate: 0.000\r\n YTranslate: 0.000\r\n XScale: 0.500\r\n
86
- YScale: 0.500\r\n XPrecision: 2.000\r\n YPrecision: 2.000\r\n
87
- _______________________________________________________
88
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
89
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
90
-
91
- expect(device.orientation).
92
- to eq(:portrait)
93
-
94
- end
95
-
96
- end
97
-
98
- describe '.install' do
99
-
100
- it 'Can install an apk' do
101
- out = <<_______________________________________________________
102
- 4458 KB/s (9967857 bytes in 2.183s)
103
- pkg: /data/local/tmp/bbciplayer-debug.apk
104
- Success
105
- _______________________________________________________
106
-
107
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
108
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
109
- expect(device.install('some_apk.spk')).
110
- to eq(:success)
111
- end
112
-
113
- it 'Can display an error when the apk is not found' do
114
- out = "can't find 'fake.apk' to install"
115
-
116
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
117
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
118
- expect { device.install('fake.apk') }.
119
- to raise_error(StandardError, "can't find 'fake.apk' to install")
120
- end
121
-
122
- it 'Can display an error message when no apk is specified' do
123
- out = 'No apk specified.'
124
-
125
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
126
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
127
- expect { device.install('fake.apk') }.
128
- to raise_error(StandardError, 'No apk specified.')
129
- end
130
-
131
- it 'Can display an error when the apk is already installed' do
132
- out = 'Failure [INSTALL_FAILED_ALREADY_EXISTS]'
133
-
134
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
135
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
136
- expect { device.install('fake.apk') }.
137
- to raise_error(StandardError, 'Failure [INSTALL_FAILED_ALREADY_EXISTS]')
138
- end
139
-
140
- describe '.uninstall' do
141
-
142
- it 'Can uninstall an apk' do
143
- out = 'Success'
144
-
145
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
146
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
147
- expect(device.uninstall('pack_name')).
148
- to eq(:success)
149
- end
150
-
151
- it 'Can raise an error if the uninstall was unsuccessful' do
152
- out = 'Failure'
153
-
154
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
155
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
156
- expect { device.uninstall('pack_name') }.
157
- to raise_error(StandardError, "Unable to install 'package_name' Error Reported: Failure")
158
- end
159
-
160
- end
161
-
162
- describe '.package_name' do
163
- out = "package: name='bbc.iplayer.android' versionCode='4200066' versionName='4.2.0.66'"
164
-
165
- it 'Can get the package name from an apk' do
166
-
167
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
168
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
169
- expect(device.package_name('iplayer.apk')).
170
- to eq('bbc.iplayer.android')
171
- end
172
-
173
- it 'Can get the version number from an apk' do
174
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
175
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
176
- expect(device.app_version_number('iplayer.apk')).
177
- to eq('4.2.0.66')
178
- end
179
-
180
- it 'can raise an error if the app package name is not found' do
181
- out = "package: versionCode='4200066' versionName='4.2.0.66'"
182
-
183
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
184
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
185
- expect { device.package_name('iplayer.apk') }.
186
- to raise_error(StandardError, 'Package name not found')
187
- end
188
-
189
- it 'can raise an error if the app version number is not found' do
190
- out = "package: name='bbc.iplayer.android' yyyyy='xxxxxxxx' qqqqq='rrrrrrrr'"
191
-
192
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
193
- allow(Open3).to receive(:capture3) { [out, '', $STATUS_ZERO] }
194
- expect { device.app_version_number('iplayer.apk') }.
195
- to raise_error(StandardError, 'Version number not found')
196
- end
197
-
198
- it 'can raise an error if aapt can not be found' do
199
- device = DeviceAPI::Android::Device.new(serial: 'SH34RW905290')
200
- allow(Open3).to receive(:capture3) { ['', '', $STATUS_ONE] }
201
- expect { device.app_version_number('iplayer.apk') }.
202
- to raise_error(StandardError, 'aapt not found - please create a symlink in $ANDROID_HOME/tools')
203
- end
204
-
205
- end
206
- end
207
- end
@@ -1,4 +0,0 @@
1
- ProcessStatusStub = Struct.new(:exitstatus)
2
- $STATUS_ZERO = ProcessStatusStub.new(0)
3
- $STATUS_ONE = ProcessStatusStub.new(1)
4
-