test/broadcast_receiver_test.rb in ruboto-0.9.0 vs test/broadcast_receiver_test.rb in ruboto-0.10.0.rc.0
- old
+ new
@@ -19,10 +19,12 @@
activity_filename = 'src/ruboto_test_app_activity.rb'
activity_content = File.read(activity_filename)
assert activity_content.sub!(/ def on_create\(bundle\)\n/, <<EOF)
def on_create(bundle)
+ super
+ $broadcast_test_activity = self
@receiver = $package.ClickReceiver.new
filter = android.content.IntentFilter.new('#{action_name}')
Thread.start do
begin
android.os.Looper.prepare
@@ -51,10 +53,10 @@
receiver_content = File.read(receiver_filename)
assert receiver_content.sub!(/ def on_receive\(context, intent\)\n.*?^ end\n/m, <<EOF)
def on_receive(context, intent)
Log.d "RUBOTO TEST", "Changing UI text"
- context.run_on_ui_thread{$activity.find_view_by_id(42).text = '#{message}'}
+ context.run_on_ui_thread{$broadcast_test_activity.find_view_by_id(42).text = '#{message}'}
Log.d "RUBOTO TEST", "UI text changed OK!"
rescue
Log.e "RUBOTO TEST", "Exception changing UI text: \#{$!.message}"
Log.e "RUBOTO TEST", $!.message
Log.e "RUBOTO TEST", $!.backtrace.join("\\n")