h4oflashsdk 1.0.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.
Files changed (94) hide show
  1. data/Gemfile +3 -0
  2. data/Gemfile.lock +41 -0
  3. data/POSTINSTALL.rdoc +79 -0
  4. data/README.textile +79 -0
  5. data/VERSION +1 -0
  6. data/bin/flashlog +8 -0
  7. data/bin/flashplayer +9 -0
  8. data/bin/sprout-as3 +9 -0
  9. data/bin/sprout-flex +8 -0
  10. data/ext/CloseFlashPlayerForDumbassOSX.scpt +6 -0
  11. data/ext/OpenFlashPlayerForDumbassOSX.scpt +12 -0
  12. data/flashsdk.gemspec +25 -0
  13. data/flashsdk.komodoproject +4 -0
  14. data/lib/flashplayer/errors.rb +12 -0
  15. data/lib/flashplayer/executable.rb +143 -0
  16. data/lib/flashplayer/log_file.rb +94 -0
  17. data/lib/flashplayer/mm_config.rb +96 -0
  18. data/lib/flashplayer/module.rb +51 -0
  19. data/lib/flashplayer/specification.rb +45 -0
  20. data/lib/flashplayer/system_mixins.rb +98 -0
  21. data/lib/flashplayer/task.legacy.rb +293 -0
  22. data/lib/flashplayer/task.rb +62 -0
  23. data/lib/flashplayer/trust.rb +45 -0
  24. data/lib/flashplayer.rb +9 -0
  25. data/lib/flashsdk/acompc.rb +29 -0
  26. data/lib/flashsdk/adl.rb +83 -0
  27. data/lib/flashsdk/adt.rb +276 -0
  28. data/lib/flashsdk/amxmlc.rb +28 -0
  29. data/lib/flashsdk/asdoc.rb +164 -0
  30. data/lib/flashsdk/compc.rb +124 -0
  31. data/lib/flashsdk/compiler_base.rb +1131 -0
  32. data/lib/flashsdk/fcsh.rb +173 -0
  33. data/lib/flashsdk/fcsh_socket.rb +167 -0
  34. data/lib/flashsdk/fdb.rb +833 -0
  35. data/lib/flashsdk/generators/class_generator.rb +87 -0
  36. data/lib/flashsdk/generators/flash_helper.rb +234 -0
  37. data/lib/flashsdk/generators/flex_project_generator.rb +30 -0
  38. data/lib/flashsdk/generators/project_generator.rb +31 -0
  39. data/lib/flashsdk/generators/templates/ActionScript3Class.as +9 -0
  40. data/lib/flashsdk/generators/templates/ActionScript3MainClass.as +11 -0
  41. data/lib/flashsdk/generators/templates/ActionScript3RunnerClass.as +19 -0
  42. data/lib/flashsdk/generators/templates/DefaultProjectImage.png +0 -0
  43. data/lib/flashsdk/generators/templates/Flex4Application.mxml +45 -0
  44. data/lib/flashsdk/generators/templates/Flex4Main.css +7 -0
  45. data/lib/flashsdk/generators/templates/Flex4Rakefile.rb +34 -0
  46. data/lib/flashsdk/generators/templates/Flex4RunnerClass.mxml +29 -0
  47. data/lib/flashsdk/generators/templates/FlexTestRunner.mxml +0 -0
  48. data/lib/flashsdk/generators/templates/Gemfile +5 -0
  49. data/lib/flashsdk/generators/templates/rakefile.rb +79 -0
  50. data/lib/flashsdk/module.rb +107 -0
  51. data/lib/flashsdk/mxmlc.rb +160 -0
  52. data/lib/flashsdk.rb +24 -0
  53. data/lib/flex3.rb +54 -0
  54. data/lib/flex4.rb +115 -0
  55. data/rakefile.rb +42 -0
  56. data/test/fixtures/acompc/simple/SomeAirFile.as +11 -0
  57. data/test/fixtures/air/simple/SomeProject.apk +1 -0
  58. data/test/fixtures/air/simple/SomeProject.as +11 -0
  59. data/test/fixtures/air/simple/SomeProject.mxml +9 -0
  60. data/test/fixtures/air/simple/SomeProject.pfx +0 -0
  61. data/test/fixtures/air/simple/SomeProject.swf +0 -0
  62. data/test/fixtures/air/simple/SomeProject.xml +13 -0
  63. data/test/fixtures/asdoc/lib/OtherFile.as +17 -0
  64. data/test/fixtures/asdoc/src/SomeFile.as +11 -0
  65. data/test/fixtures/compc/simple/SomeFile.as +11 -0
  66. data/test/fixtures/flashplayer/AsUnit Runner.swf +0 -0
  67. data/test/fixtures/mxmlc/broken/SomeFile.as +10 -0
  68. data/test/fixtures/mxmlc/simple/SomeFile.as +11 -0
  69. data/test/fixtures/sdk/fdb +90 -0
  70. data/test/fixtures/sdk/mxmlc +56 -0
  71. data/test/unit/acompc_test.rb +37 -0
  72. data/test/unit/adl_test.rb +32 -0
  73. data/test/unit/adt_test.rb +185 -0
  74. data/test/unit/amxmlc_test.rb +55 -0
  75. data/test/unit/asdoc_test.rb +45 -0
  76. data/test/unit/class_generator_test.rb +56 -0
  77. data/test/unit/compc_test.rb +37 -0
  78. data/test/unit/fake_flashplayer_system.rb +11 -0
  79. data/test/unit/fcsh_socket_test.rb +53 -0
  80. data/test/unit/fcsh_test.rb +55 -0
  81. data/test/unit/fdb_test.rb +54 -0
  82. data/test/unit/flash_helper_test.rb +43 -0
  83. data/test/unit/flashplayer_executable_test.rb +69 -0
  84. data/test/unit/flashplayer_log_file_test.rb +47 -0
  85. data/test/unit/flashplayer_mm_config_test.rb +74 -0
  86. data/test/unit/flashplayer_module_test.rb +56 -0
  87. data/test/unit/flashplayer_task_test.rb +91 -0
  88. data/test/unit/flashplayer_trust_test.rb +30 -0
  89. data/test/unit/flex_compiler_options_test.rb +213 -0
  90. data/test/unit/flex_generator_test.rb +37 -0
  91. data/test/unit/mxmlc_test.rb +65 -0
  92. data/test/unit/project_generator_test.rb +57 -0
  93. data/test/unit/test_helper.rb +18 -0
  94. metadata +284 -0
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class FakeFDB
4
+
5
+ def initialize
6
+ str = "Adobe fdb (Flash Player Debugger) [build 16076]\n"
7
+ str << "Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.\n"
8
+ str << "(fdb) "
9
+ printf str
10
+ gather_input
11
+ end
12
+
13
+ def gather_input
14
+ $stdout.flush
15
+ command = $stdin.gets.chomp!
16
+ parts = command.split(' ')
17
+ name = parts.shift
18
+
19
+ case name
20
+ when "run"
21
+ handle_run parts
22
+ when "break"
23
+ handle_break parts
24
+ when "continue"
25
+ handle_continue parts
26
+ when "kill"
27
+ handle_kill parts
28
+ when "y"
29
+ handle_confirmation parts
30
+ when "quit"
31
+ handle_quit parts
32
+ when "run_with_error"
33
+ handle_run_with_error parts
34
+ else
35
+ puts "FAKE FDB doesn't know how to respond to #{command}"
36
+ exit 1
37
+ end
38
+
39
+ gather_input
40
+ end
41
+
42
+ def handle_run args
43
+ str = "Waiting for Player to connect\n"
44
+ str << "Player connected; session starting.\n"
45
+ str << "Set breakpoints and then type 'continue' to resume the session.\n"
46
+ str = "[SWF] Users:lbayes:Projects:AsUnit-P2:asunit-4.0:bin:AsUnitRunner.swf - 226,833 bytes after decompression\n"
47
+ str << "(fdb) "
48
+ printf str
49
+ end
50
+
51
+ def handle_break args
52
+ str = "Breakpoint 1, AsUnitRunner() at AsUnitRunner.as:12\n"
53
+ str << "12 core = new TextCore();\n"
54
+ str << "(fdb) "
55
+ printf str
56
+ end
57
+
58
+ def handle_continue args
59
+ str = "Continuing now\n"
60
+ str << "(fdb) "
61
+ printf str
62
+ end
63
+
64
+ def handle_kill args
65
+ printf "Kill the program being debugged? (y or n) "
66
+ end
67
+
68
+ def handle_confirmation args
69
+ str = "Confirmation accepted\n"
70
+ str << "(fdb) "
71
+ printf str
72
+ end
73
+
74
+ def handle_run_with_error args
75
+ str = "This is an error!\n"
76
+ str << "This is more details about the error!\n"
77
+ str << "Here are even more details!\n"
78
+ $stderr.printf str
79
+ printf "(fdb) "
80
+ end
81
+
82
+ def handle_quit args
83
+ puts ">> EXITING NOW!\n"
84
+ exit! 0
85
+ end
86
+
87
+ end
88
+
89
+ fake_fdb = FakeFDB.new
90
+
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ##
4
+ # This is a Fake MXMLC executable that should
5
+ # support our test cases by performing exactly
6
+ # the same tasks that MXMLC performs, but much
7
+ # faster.
8
+ #
9
+ # This executable should be easily swapped with
10
+ # the real MXMLC binary for any test.
11
+ class FakeMXMLC
12
+
13
+ def initialize args
14
+ #puts ">> ARGS: #{args.inspect}"
15
+ if(args.size == 2 &&
16
+ args[0].include?('SomeFile.swf') &&
17
+ args[1].include?('SomeFile.as'))
18
+ compile_simple_swf args
19
+ elsif args == ["-output=test/fixtures/air/simple/bin/SomeProject.swf", "test/fixtures/air/simple/SomeProject.as"]
20
+ compile_amxmlc_swf args
21
+ else
22
+ raise "Unexpected args sent to mxmlc stub #{args.join(', ')}"
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def compile_amxmlc_swf args
29
+ path = args[0].split('=').pop
30
+ compile_swf path
31
+ end
32
+
33
+ ##
34
+ # /Users/lbayes/Library/Sprouts/1.0/cache/flex4/4.1.0.16076/bin/mxmlc -static-link-runtime-shared-libraries test/fixtures/mxmlc/simple/SomeFile.as
35
+ # Loading configuration file /Users/lbayes/Library/Sprouts/1.0/cache/flex4/4.1.0.16076/frameworks/flex-config.xml
36
+ # /Users/lbayes/Projects/Sprouts/flashsdk/test/fixtures/mxmlc/simple/SomeFile.swf (558 bytes)
37
+ def compile_simple_swf args
38
+ path = File.expand_path(args[0].gsub(/-output=/, ''))
39
+ compile_swf path
40
+ end
41
+
42
+ def compile_swf path
43
+ File.open path, 'wb+' do |f|
44
+ f.write swf_bytes
45
+ end
46
+ puts "#{File.expand_path(path)} (#{swf_bytes.size})"
47
+ end
48
+
49
+ def swf_bytes
50
+ @swf_bytes ||= File.read 'test/fixtures/air/simple/SomeProject.swf'
51
+ end
52
+
53
+ end
54
+
55
+ mxmlc = FakeMXMLC.new ARGV
56
+
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class ACOMPCTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "An ACOMPC tool" do
7
+
8
+ setup do
9
+ @fixture = File.join 'test', 'fixtures', 'acompc', 'simple'
10
+ @input = File.join @fixture, 'SomeAirFile.as'
11
+ @expected_output = File.join @fixture, 'SomeAirFile.swc'
12
+ end
13
+
14
+ teardown do
15
+ remove_file @expected_output
16
+ end
17
+
18
+ should "accept input" do
19
+ as_a_unix_system do
20
+ compc = FlashSDK::ACOMPC.new
21
+ compc.output = @expected_output
22
+ compc.include_sources << @fixture
23
+ assert_equal '--output=test/fixtures/acompc/simple/SomeAirFile.swc --include-sources+=test/fixtures/acompc/simple', compc.to_shell
24
+ end
25
+ end
26
+
27
+ should "compile a swc" do
28
+ compc = FlashSDK::ACOMPC.new
29
+ compc.include_sources << @fixture
30
+ compc.output = @expected_output
31
+ compc.execute
32
+ assert_file @expected_output
33
+ end
34
+
35
+ end
36
+ end
37
+
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ class ADLTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "An ADL tool" do
7
+
8
+ setup do
9
+ @fixture = File.join 'test', 'fixtures', 'air', 'simple'
10
+ @app_desc = File.join @fixture, 'SomeProject.xml'
11
+ @profile = 'mobileDevice'
12
+ @screensize = 'NexusOne'
13
+ end
14
+
15
+ teardown do
16
+ end
17
+
18
+ should "accept input" do
19
+ adl = FlashSDK::ADL.new
20
+ adl.app_desc = @app_desc
21
+ adl.root_dir = Dir.pwd
22
+ adl.screensize = @screensize
23
+ adl.profile = @profile
24
+ assert_equal "-profile #{@profile} -screensize #{@screensize} #{@app_desc} #{Dir.pwd}", adl.to_shell
25
+ # Uncomment to actually launch
26
+ # the AIR application:
27
+ #adl.execute
28
+ end
29
+
30
+ end
31
+ end
32
+
@@ -0,0 +1,185 @@
1
+ require 'test_helper'
2
+
3
+ class ADTTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "An ADT tool" do
7
+
8
+ setup do
9
+ @fixture = File.join 'test', 'fixtures', 'air', 'simple'
10
+ @application_xml = File.join @fixture, 'SomeProject.xml'
11
+ @expected_output = File.join @fixture, 'SomeProject.air'
12
+ @apk_input = File.join @fixture, 'SomeProject.apk'
13
+ @ipa_output = File.join @fixture, 'SomeProject.ipa'
14
+ @swf_input = File.join @fixture, 'SomeProject.swf'
15
+ @swf_main = File.join @fixture, 'SomeProject.mxml'
16
+ @certificate = File.join @fixture, 'SomeProject.pfx'
17
+ @ipa_cert = File.join @fixture, 'SomeProject.p12'
18
+ @provisioning_profile = File.join @fixture, 'Profile.mobileprovision'
19
+ @platform = 'android'
20
+ @target = 'apk-debug'
21
+ @appid = 'com.foo.bar.SomeProject'
22
+ @cert_password = 'samplePassword'
23
+ end
24
+
25
+ teardown do
26
+ clear_tasks
27
+ remove_file @expected_output
28
+ end
29
+
30
+ should "package a SWF with an application.xml" do
31
+ as_a_unix_system do
32
+ t = adt @expected_output do |t|
33
+ t.package = true
34
+ t.target = @target
35
+ t.package_input = @application_xml
36
+ t.package_output = @expected_output
37
+ t.storetype = 'PKCS12'
38
+ t.keystore = @certificate
39
+ t.storepass = @cert_password
40
+ t.included_files << @swf_input
41
+ end
42
+
43
+ assert_equal "-package -storetype PKCS12 -keystore #{@certificate} " +
44
+ "-storepass #{@cert_password} -target #{@target} " +
45
+ "test/fixtures/air/simple/SomeProject.air " +
46
+ "test/fixtures/air/simple/SomeProject.xml " +
47
+ "test/fixtures/air/simple/SomeProject.swf", t.to_shell
48
+
49
+ # Uncomment to actually run adt (much slower)
50
+ #t.execute
51
+ #assert_file @expected_output
52
+ end
53
+ end
54
+
55
+ should "package a SWF and complex assets with an application.xml" do
56
+ as_a_unix_system do
57
+ t = adt @expected_output do |t|
58
+ t.package = true
59
+ t.target = @target
60
+ t.package_input = @application_xml
61
+ t.package_output = @expected_output
62
+ t.storetype = 'PKCS12'
63
+ t.keystore = @certificate
64
+ t.storepass = @cert_password
65
+ t.included_files << @swf_input
66
+ t.file_options << 'bin path/to/asset.xml'
67
+ end
68
+
69
+ assert_equal "-package -storetype PKCS12 -keystore #{@certificate} " +
70
+ "-storepass #{@cert_password} -target #{@target} " +
71
+ "test/fixtures/air/simple/SomeProject.air " +
72
+ "test/fixtures/air/simple/SomeProject.xml " +
73
+ "test/fixtures/air/simple/SomeProject.swf " +
74
+ "-C bin path/to/asset.xml", t.to_shell
75
+
76
+ # Uncomment to actually run adt (much slower)
77
+ #t.execute
78
+ #assert_file @expected_output
79
+ end
80
+ end
81
+
82
+ should "package an iOS swf with a provisioning profile" do
83
+ as_a_unix_system do
84
+ t = adt @ipa_output do |t|
85
+ t.package = true
86
+ t.target = 'ipa-test'
87
+ t.package_input = @application_xml
88
+ t.package_output = @ipa_output
89
+ t.storetype = 'PKCS12'
90
+ t.keystore = @ipa_cert
91
+ t.storepass = @cert_password
92
+ t.provisioning_profile = @provisioning_profile
93
+ t.included_files << @swf_input
94
+ end
95
+
96
+ assert_equal "-package -storetype PKCS12 -keystore #{@ipa_cert} " +
97
+ "-storepass #{@cert_password} -provisioning-profile " +
98
+ "#{@provisioning_profile} -target ipa-test " +
99
+ "test/fixtures/air/simple/SomeProject.ipa " +
100
+ "test/fixtures/air/simple/SomeProject.xml " +
101
+ "test/fixtures/air/simple/SomeProject.swf", t.to_shell
102
+
103
+ # Uncomment to actually run adt (much slower)
104
+ #t.execute
105
+ #assert_file @expected_output
106
+ end
107
+ end
108
+
109
+ should "install an APK" do
110
+ as_a_unix_system do
111
+ t = adt @expected_output do |t|
112
+ t.installApp = true
113
+ t.platform = @platform
114
+ t.package = true
115
+ t.package_input = @apk_input
116
+ end
117
+
118
+ assert_equal "-installApp -platform #{@platform} -package #{@apk_input}", t.to_shell
119
+
120
+ # Uncomment to actually run adt (much slower)
121
+ #t.execute
122
+ #assert_file @expected_output
123
+ end
124
+ end
125
+
126
+ should "uninstall an APK" do
127
+ as_a_unix_system do
128
+ t = adt @expected_output do |t|
129
+ t.uninstallApp = true
130
+ t.platform = @platform
131
+ t.appid = @appid
132
+ end
133
+
134
+ assert_equal "-uninstallApp -platform #{@platform} -appid #{@appid}", t.to_shell
135
+
136
+ # Uncomment to actually run adt (much slower)
137
+ #t.execute
138
+ #assert_file @expected_output
139
+ end
140
+ end
141
+
142
+ should "launch an app" do
143
+ as_a_unix_system do
144
+ t = adt @expected_output do |t|
145
+ t.launchApp = true
146
+ t.platform = @platform
147
+ t.appid = @appid
148
+ end
149
+
150
+ assert_equal "-launchApp -platform #{@platform} -appid #{@appid}", t.to_shell
151
+
152
+ # Uncomment to actually run adt (much slower)
153
+ #t.execute
154
+ #assert_file @expected_output
155
+ end
156
+ end
157
+
158
+ should "create a self-signed certificate" do
159
+ as_a_unix_system do
160
+ t = adt(@certificate) do |t|
161
+ t.certificate = true
162
+ t.cn = 'SelfCertificate'
163
+ t.key_type = '2048-RSA'
164
+ t.pfx_file = @certificate
165
+ t.password = @cert_password
166
+ end
167
+
168
+ assert_equal '-certificate -cn SelfCertificate 2048-RSA test/fixtures/air/simple/SomeProject.pfx samplePassword', t.to_shell
169
+
170
+ # Uncomment to actually run adt (much slower)
171
+ #t.execute
172
+ #assert_file @certificate
173
+ end
174
+ end
175
+
176
+ # USE THIS METHOD TO CREATE THE INPUT SWF:
177
+ #should "create an input swf" do
178
+ #t = amxmlc @swf_input do |t|
179
+ #t.input = @swf_main
180
+ #end
181
+ #t.execute
182
+ #end
183
+ end
184
+ end
185
+
@@ -0,0 +1,55 @@
1
+ require 'test_helper'
2
+
3
+ class AMXMLCTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "An AMXMLC tool" do
7
+
8
+ setup do
9
+ @fixture = File.join 'test', 'fixtures', 'air', 'simple'
10
+ @input = File.join @fixture, 'SomeProject.as'
11
+ @expected_output = File.join @fixture, 'bin', 'SomeProject.swf'
12
+ end
13
+
14
+ teardown do
15
+ remove_file File.join(@fixture, 'bin')
16
+ end
17
+
18
+ should "accept input" do
19
+ as_a_unix_system do
20
+ amxmlc = FlashSDK::AMXMLC.new
21
+ amxmlc.input = @input
22
+ amxmlc.source_path << @fixture
23
+ assert_equal '-source-path+=test/fixtures/air/simple test/fixtures/air/simple/SomeProject.as', amxmlc.to_shell
24
+ end
25
+ end
26
+
27
+ should "compile a swf" do
28
+ FileUtils.mkdir_p File.dirname(@expected_output)
29
+
30
+ amxmlc = FlashSDK::AMXMLC.new
31
+ amxmlc.binary_path = File.join fixtures, 'sdk', 'mxmlc'
32
+ amxmlc.input = @input
33
+ amxmlc.output = @expected_output
34
+ amxmlc.execute
35
+ assert_file @expected_output
36
+ end
37
+
38
+
39
+ should "assign default-size" do
40
+ amxmlc = FlashSDK::AMXMLC.new
41
+ amxmlc.default_size = '800,500'
42
+ assert_equal '-default-size=800,500', amxmlc.to_shell
43
+ end
44
+
45
+ should "assign simple output" do
46
+ as_a_unix_system do
47
+ t = amxmlc 'bin/SomeProject.swf' do |t|
48
+ t.input = @input
49
+ end
50
+ assert_equal '-output=bin/SomeProject.swf test/fixtures/air/simple/SomeProject.as', t.to_shell
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ class AsDocTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "An AsDoc tool" do
7
+
8
+ setup do
9
+ @original_use_fcsh_value = ENV['USE_FCSH']
10
+ @fixture = File.join fixtures, 'asdoc'
11
+ @source_path = File.join @fixture, 'src'
12
+ @lib_path = File.join @fixture, 'lib'
13
+ @doc_output = File.join @fixture, 'docs'
14
+
15
+ @swf_input = File.join @fixture, 'src', 'SomeFile.as'
16
+ @swf_output = File.join @fixture, 'bin', 'SomeFile.swf'
17
+ end
18
+
19
+ teardown do
20
+ remove_file @doc_output
21
+ end
22
+
23
+ should "generate simple documentation" do
24
+ t = FlashSDK::AsDoc.new
25
+ t.doc_sources << @source_path
26
+ t.doc_sources << @lib_path
27
+ t.output = @doc_output
28
+ t.execute
29
+
30
+ assert_file File.join(@doc_output, 'index.html')
31
+ end
32
+
33
+ =begin
34
+ should "work with a rake task too" do
35
+ exe = asdoc @doc_output do |t|
36
+ t.doc_sources << @source_path
37
+ t.doc_sources << @lib_path
38
+ end
39
+ exe.execute
40
+ end
41
+ =end
42
+
43
+ end
44
+ end
45
+
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ class ClassGeneratorTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "a new class generator" do
7
+
8
+ setup do
9
+ @temp = File.join(fixtures, 'generators', 'tmp')
10
+ FileUtils.mkdir_p @temp
11
+ @generator = FlashSDK::ClassGenerator.new
12
+ @generator.path = @temp
13
+ @generator.logger = StringIO.new
14
+
15
+ Sprout::Generator.register FlashSDK::ClassGenerator
16
+ Sprout::Generator.register FlashSDK::TestClassGenerator
17
+ end
18
+
19
+ teardown do
20
+ remove_file @temp
21
+ end
22
+
23
+ should "work with a simple class" do
24
+ @generator.input = 'utils.MathUtil'
25
+ @generator.execute
26
+ assert_file File.join(@temp, 'src', 'utils', 'MathUtil.as')
27
+ end
28
+
29
+ should "work with no package" do
30
+ @generator.input = 'MathUtil'
31
+ @generator.execute
32
+ assert_file File.join(@temp, 'src', 'MathUtil.as')
33
+ end
34
+
35
+ should "work with directory instead of dots" do
36
+ @generator.input = 'src/utils/MathUtil.as'
37
+ @generator.execute
38
+ assert_file File.join(@temp, 'src', 'utils', 'MathUtil.as')
39
+ end
40
+
41
+ should "work with directory but no source" do
42
+ @generator.input = 'utils/MathUtil.as'
43
+ @generator.execute
44
+ assert_file File.join(@temp, 'src', 'utils', 'MathUtil.as')
45
+ end
46
+
47
+ should "not call TestGenerator when no_test" do
48
+ FlashSDK::TestClassGenerator.any_instance.expects(:manifest).never
49
+ @generator.input = 'utils.MathUtil'
50
+ @generator.test_class = false
51
+ @generator.execute
52
+ end
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class COMPCTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "An COMPC tool" do
7
+
8
+ setup do
9
+ @fixture = File.join 'test', 'fixtures', 'compc', 'simple'
10
+ @input = File.join @fixture, 'SomeFile.as'
11
+ @expected_output = File.join @fixture, 'SomeFile.swc'
12
+ end
13
+
14
+ teardown do
15
+ remove_file @expected_output
16
+ end
17
+
18
+ should "accept input" do
19
+ as_a_unix_system do
20
+ compc = FlashSDK::COMPC.new
21
+ compc.output = @expected_output
22
+ compc.include_sources << @fixture
23
+ assert_equal '--output=test/fixtures/compc/simple/SomeFile.swc --include-sources+=test/fixtures/compc/simple', compc.to_shell
24
+ end
25
+ end
26
+
27
+ should "compile a swc" do
28
+ compc = FlashSDK::COMPC.new
29
+ compc.include_sources << @fixture
30
+ compc.output = @expected_output
31
+ compc.execute
32
+ assert_file @expected_output
33
+ end
34
+
35
+ end
36
+ end
37
+
@@ -0,0 +1,11 @@
1
+
2
+ class FakeFlashPlayerSystem
3
+
4
+ def clean_path path
5
+ path
6
+ end
7
+
8
+ def open_flashplayer_with player, swf
9
+ end
10
+ end
11
+
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+
3
+ class FCSHSocketTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "a new fcsh server" do
7
+
8
+ setup do
9
+ # Uncomment to see output:
10
+ #Sprout.stdout = $stdout
11
+ #Sprout.stderr = $stderr
12
+
13
+ @input = File.join(fixtures, 'mxmlc', 'simple', 'SomeFile.as')
14
+ @test_port = 12543
15
+ end
16
+
17
+ teardown do
18
+ clear_tasks
19
+ end
20
+
21
+ should "be instantiable" do
22
+ service_ready = false
23
+ # Create the remote side of the connection:
24
+ t = Thread.new do
25
+ Thread.current.abort_on_exception = true
26
+ server = FlashSDK::FCSHSocket.new
27
+ server.port = @test_port
28
+ service_ready = true
29
+ server.listen
30
+ end
31
+
32
+ # Wait for the remote connection to exist
33
+ while !service_ready
34
+ sleep 0.1
35
+ end
36
+
37
+ sleep 2.0
38
+
39
+ mxmlc = FlashSDK::MXMLC.new
40
+ mxmlc.input = @input
41
+
42
+ client = FlashSDK::FCSHSocket.new
43
+ client.port = @test_port
44
+ client.execute "mxmlc #{mxmlc.to_shell}"
45
+ FileUtils.touch @input
46
+ client.execute "mxmlc #{mxmlc.to_shell}"
47
+ client.execute "quit"
48
+
49
+ t.join
50
+ end
51
+ end
52
+ end
53
+