Robottler 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +8 -0
- data/bin/robottler +11 -0
- data/lib/robottler.rb +99 -1
- data/templates/build.gradle +18 -0
- data/templates/class.erb.java +31 -0
- data/templates/class_test_runner.java +40 -0
- data/templates/debug_manifest.xml +3 -0
- data/test/fixtures/main/AndroidManifest.xml +16 -0
- data/test/test_robottler.rb +11 -0
- metadata +43 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04864ffa82d9436a45db9ce73a7f9b39529a4525
|
4
|
+
data.tar.gz: 7bcc6792429897d72fde37d03a237f5be19c0a7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d002a1d310bb4f43d80ac9da43b965f5984f00495a49252091b578c53ba6c724265cec7c7be32066c16a5c6e9e824e684774d3c46c14f0ed798f4115c00e084d
|
7
|
+
data.tar.gz: 1ddfe4742bb19b1e1e3015bf2dd0d359d60e4fee24e5c7a56b0c11f734b7e98aa6bfe44846547cb4fb046eb84cc2145ebcf1fcbd7bdd6a1ebb148696d3e8f59f
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 tosa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/robottler
ADDED
data/lib/robottler.rb
CHANGED
@@ -1,6 +1,104 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'erb'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'executable'
|
7
|
+
|
1
8
|
class Robottler
|
9
|
+
include Executable
|
10
|
+
|
11
|
+
class Renderer < OpenStruct
|
12
|
+
def render(erb)
|
13
|
+
erb.result(binding)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Use for eclipse project
|
18
|
+
def eclipse=(bool)
|
19
|
+
@eclipse = bool
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
def eclipse?
|
24
|
+
@eclipse
|
25
|
+
end
|
2
26
|
|
3
|
-
|
27
|
+
# Use for gradle project
|
28
|
+
def gradle=(bool)
|
29
|
+
@gradle = bool
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
def gradle?
|
34
|
+
@gradle
|
35
|
+
end
|
36
|
+
|
37
|
+
# Show this message.
|
38
|
+
def help!
|
39
|
+
cli.show_help
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
alias :h! :help!
|
43
|
+
|
44
|
+
# add spoon tests to project
|
45
|
+
def call()
|
46
|
+
name = eclipse? ? "eclipse" : "gradle"
|
47
|
+
if eclipse
|
48
|
+
puts "Eclipse support not implemented yet."
|
49
|
+
return
|
50
|
+
end
|
51
|
+
str = "Hello, #{name}!"
|
52
|
+
puts "=================#{str}================="
|
53
|
+
puts __FILE__
|
54
|
+
root_dir = File.expand_path("../..", __FILE__)
|
55
|
+
|
56
|
+
puts ''
|
57
|
+
puts ''
|
4
58
|
puts 'creating tests'
|
59
|
+
begin
|
60
|
+
content = File.read("./AndroidManifest.xml")
|
61
|
+
@doc = Nokogiri::XML(content)
|
62
|
+
activities = @doc.xpath("//activity")
|
63
|
+
if activities.size > 0
|
64
|
+
filename = "#{root_dir}/templates/class.erb.java"
|
65
|
+
erb = ERB.new(File.read(filename))
|
66
|
+
|
67
|
+
directory_name = "../instrumentTest"
|
68
|
+
unless File.exists?(directory_name)
|
69
|
+
puts "create directory #{directory_name}"
|
70
|
+
test_runner_package = "java/au/com/jtribe/testing"
|
71
|
+
FileUtils.mkdir_p("#{directory_name}/#{test_runner_package}")
|
72
|
+
FileUtils.cp("#{root_dir}/templates/class_test_runner.java", "#{directory_name}/#{test_runner_package}/WakeUpInstrumentationTestRunner.java")
|
73
|
+
end
|
74
|
+
|
75
|
+
puts "\nAdd these permissions to your debug manifest."
|
76
|
+
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
77
|
+
puts "!!!!!!!!!!!!! Don't add them to your release apk !!!!!!!!!!!!!"
|
78
|
+
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n"
|
79
|
+
puts File.read("#{root_dir}/templates/debug_manifest.xml")
|
80
|
+
puts "\nAdd this to your build.gradle file\n\n"
|
81
|
+
puts File.read("#{root_dir}/templates/build.gradle")
|
82
|
+
|
83
|
+
activities.each do |a|
|
84
|
+
attribute = a.attribute('name')
|
85
|
+
unless attribute.nil?
|
86
|
+
package = attribute.to_s.gsub(/\w+$/, '').chop!
|
87
|
+
package_dir = package.gsub('.','/')
|
88
|
+
file_path = "#{directory_name}/java/#{package_dir}"
|
89
|
+
FileUtils.mkdir_p(file_path)
|
90
|
+
activity = attribute.to_s.match(/\w+$/)
|
91
|
+
puts "\tfor #{activity}"
|
92
|
+
r = Renderer.new({ activity: activity, package: package})
|
93
|
+
File.open("#{file_path}/#{activity}Test.java", 'w') do |f|
|
94
|
+
f.write r.render(erb)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
rescue
|
100
|
+
puts '================ Can\'t find AndroidManifest ================'
|
101
|
+
puts 'Make sure you are in the folder where your AndroidManifest.xml is!'
|
102
|
+
end
|
5
103
|
end
|
6
104
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
buildscript {
|
2
|
+
...
|
3
|
+
dependencies {
|
4
|
+
...
|
5
|
+
classpath 'com.stanfy.spoon:spoon-gradle-plugin:0.9.+'
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
...
|
10
|
+
|
11
|
+
apply plugin: 'spoon'
|
12
|
+
|
13
|
+
...
|
14
|
+
|
15
|
+
dependencies {
|
16
|
+
...
|
17
|
+
instrumentTestCompile 'com.squareup.spoon:spoon-client:1.1.0'
|
18
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
package <%= package %>;
|
2
|
+
|
3
|
+
import android.content.Intent;
|
4
|
+
import android.test.ActivityInstrumentationTestCase2;
|
5
|
+
|
6
|
+
import <%= package %>.<%= activity %>;
|
7
|
+
import <%= package %>.R;
|
8
|
+
|
9
|
+
import com.squareup.spoon.Spoon;
|
10
|
+
|
11
|
+
public class <%= activity %>Test extends ActivityInstrumentationTestCase2<<%= activity %>> {
|
12
|
+
|
13
|
+
public <%= activity %>Test() {
|
14
|
+
super(<%= activity %>.class);
|
15
|
+
}
|
16
|
+
|
17
|
+
@Override
|
18
|
+
protected void setUp() throws Exception {
|
19
|
+
super.setUp();
|
20
|
+
getActivity();
|
21
|
+
}
|
22
|
+
|
23
|
+
@Override
|
24
|
+
protected void tearDown() throws Exception {
|
25
|
+
super.tearDown();
|
26
|
+
}
|
27
|
+
|
28
|
+
public void testView() {
|
29
|
+
Spoon.screenshot(getActivity(), "initial_state");
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
package au.com.jtribe.testing;
|
2
|
+
|
3
|
+
import android.app.Application;
|
4
|
+
import android.app.KeyguardManager;
|
5
|
+
import android.os.PowerManager;
|
6
|
+
import android.test.InstrumentationTestRunner;
|
7
|
+
|
8
|
+
import static android.content.Context.KEYGUARD_SERVICE;
|
9
|
+
import static android.content.Context.POWER_SERVICE;
|
10
|
+
import static android.os.PowerManager.ACQUIRE_CAUSES_WAKEUP;
|
11
|
+
import static android.os.PowerManager.FULL_WAKE_LOCK;
|
12
|
+
import static android.os.PowerManager.ON_AFTER_RELEASE;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Created by tosa on 19/12/13.
|
16
|
+
* Test runner which disables the keyguard and wake up the screen during execution. Requires test
|
17
|
+
* application have {@code android.permission.DISABLE_KEYGUARD} permission declared.
|
18
|
+
**/
|
19
|
+
public class WakeUpInstrumentationTestRunner extends InstrumentationTestRunner {
|
20
|
+
|
21
|
+
@Override public void onStart() {
|
22
|
+
runOnMainSync(new Runnable() {
|
23
|
+
@Override public void run() {
|
24
|
+
Application app = (Application) getTargetContext().getApplicationContext();
|
25
|
+
String simpleName = WakeUpInstrumentationTestRunner.class.getSimpleName();
|
26
|
+
|
27
|
+
// Unlock the device so that the tests can input keystrokes.
|
28
|
+
((KeyguardManager) app.getSystemService(KEYGUARD_SERVICE)) //
|
29
|
+
.newKeyguardLock(simpleName) //
|
30
|
+
.disableKeyguard();
|
31
|
+
// Wake up the screen.
|
32
|
+
((PowerManager) app.getSystemService(POWER_SERVICE)) //
|
33
|
+
.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, simpleName) //
|
34
|
+
.acquire();
|
35
|
+
}
|
36
|
+
});
|
37
|
+
|
38
|
+
super.onStart();
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
package="de.tosa.test_robottler"
|
4
|
+
android:versionCode="1"
|
5
|
+
android:versionName="1.0" >
|
6
|
+
<application>
|
7
|
+
<activity name="de.tosa.test_robottler.MainActivity">
|
8
|
+
<intent-filter>
|
9
|
+
<action android:name="android.intent.action.MAIN" />
|
10
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
11
|
+
</intent-filter>
|
12
|
+
</activity>
|
13
|
+
<activity name="de.tosa.test_robottler.SettingsActivity" />
|
14
|
+
</application>
|
15
|
+
|
16
|
+
</manifest>
|
metadata
CHANGED
@@ -1,23 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Robottler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tosa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
12
|
-
dependencies:
|
11
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: executable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: Simple gem to generate ui tests for you app by looking at your manifest.
|
14
42
|
Default tests will be espresso tests with spoon integration for taking screenshots.
|
15
43
|
email: tosa.info@gmail.com
|
16
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- robottler
|
17
46
|
extensions: []
|
18
47
|
extra_rdoc_files: []
|
19
48
|
files:
|
49
|
+
- Rakefile
|
50
|
+
- bin/robottler
|
20
51
|
- lib/robottler.rb
|
52
|
+
- test/fixtures/main/AndroidManifest.xml
|
53
|
+
- test/test_robottler.rb
|
54
|
+
- templates/build.gradle
|
55
|
+
- templates/class.erb.java
|
56
|
+
- templates/class_test_runner.java
|
57
|
+
- templates/debug_manifest.xml
|
58
|
+
- README.md
|
59
|
+
- LICENSE
|
21
60
|
homepage: https://github.com/tobibo/robottler
|
22
61
|
licenses:
|
23
62
|
- MIT
|