Patch for the IO::Async new_handle change, this also fixes some test issues due to Tangence API changes.
commit 7ec3a8c329129d589a9786503197f2f67c232ded
Author: tom <TEAM@cpan.org>
Date: Sun Jun 25 02:20:55 2017 +0800
Fix IO::Async-usage and tests
diff --git a/lib/Circle.pm b/lib/Circle.pm
index 3eaf68c..910cbb0 100644
--- a/lib/Circle.pm
+++ b/lib/Circle.pm
@@ -65,7 +65,7 @@ sub make_local_client
# Internal hackery; stolen from IaListener
my $acceptor = $self->acceptor;
- my $handle = $self->{new_handle}->( $self );
+ my $handle = $self->{handle_constructor}->( $self );
$S1->blocking( 0 );
$handle->set_handle( $S1 );
$self->on_accept( $handle );
diff --git a/t/01rootobj.t b/t/01rootobj.t
index 153889c..5bb662c 100644
--- a/t/01rootobj.t
+++ b/t/01rootobj.t
@@ -32,23 +32,17 @@ my $widgets = get_widgetset_from $rootobj;
ok( my $scroller = $widgets->{"Circle.Widget.Scroller"}, 'Found a Scroller widget' );
ok( my $entry = $widgets->{"Circle.Widget.Entry"}, 'Found an Entry widget' );
-my $watching;
my $displayevents;
$scroller->watch_property(
- property => "displayevents",
+ "displayevents",
on_updated => sub { $displayevents = $_[0] },
- on_watched => sub { $watching++ },
-);
-
-wait_for { $watching };
+)->get;
my $time_before = time;
$entry->call_method(
- method => "enter",
- args => [ "/eval 1" ],
- on_result => sub { },
-);
+ enter => "/eval 1"
+)->get;
wait_for { $displayevents };
@@ -65,10 +59,8 @@ is_deeply( $event->[2], { text => "Result: 1" }, '$event args' );
undef $displayevents;
$rootobj->call_method(
- method => "do_command",
- args => [ "eval 1" ],
- on_result => sub { },
-);
+ do_command => "eval 1"
+)->get;
wait_for { $displayevents };
diff --git a/t/02session.t b/t/02session.t
index 613d712..5b85fc1 100644
--- a/t/02session.t
+++ b/t/02session.t
@@ -23,11 +23,10 @@ my $session = get_session $rootobj;
ok( $session->proxy_isa( "Circle.Session.Tabbed" ), '$session proxy isa Circle.Session.Tabbed' );
my $tabs;
-$session->watch_property(
- property => "tabs",
- want_initial => 1,
+$session->watch_property_with_initial(
+ "tabs",
on_updated => sub { $tabs = $_[0] },
-);
+)->get;
wait_for { $tabs };
diff --git a/t/50net-raw.t b/t/50net-raw.t
index ef6da73..445e1cd 100644
--- a/t/50net-raw.t
+++ b/t/50net-raw.t
@@ -22,23 +22,17 @@ my $session = get_session $rootobj;
send_command $rootobj, "networks add -type raw Test";
-my $rawnet;
-$session->get_property(
- property => "tabs",
- on_value => sub {
- $rawnet = $_[0]->[1],
- defined $rawnet or die "Expected a tab [1] didn't get one";
- },
-);
-wait_for { defined $rawnet };
-
+my ($rawnet) = $session->get_property(
+ "tabs",
+)->get->[1];
+defined $rawnet or die "Expected a tab [1] didn't get one";
ok( $rawnet->proxy_isa( "Circle.Net.Raw" ), '$rawnet proxy isa Circle.Net.Raw' );
my $connected_args;
$rawnet->subscribe_event(
- event => "connected",
+ "connected",
on_fire => sub { $connected_args = [ @_ ] },
-);
+)->get;
my $widgets = get_widgetset_from $rawnet;
@@ -87,28 +81,22 @@ $serverstream->configure(
$loop->add( $serverstream );
$widgets->{"Circle.Widget.Entry"}->call_method(
- method => "enter",
- args => [ "Hello, server!" ],
- on_result => sub { },
-);
+ enter => "Hello, server!"
+)->get;
wait_for { @lines_from_client };
is( shift @lines_from_client, "Hello, server!", 'client can send to server' );
-my $watching;
my @displayevents;
$widgets->{"Circle.Widget.Scroller"}->watch_property(
- property => "displayevents",
+ "displayevents",
on_set => sub {},
on_push => sub {
push @displayevents, @_;
},
on_shift => sub {},
- on_watched => sub { $watching++ },
-);
-
-wait_for { $watching };
+)->get;
my $time_before = time;
diff --git a/t/CircleTest.pm b/t/CircleTest.pm
index 7c02901..6c9815d 100644
--- a/t/CircleTest.pm
+++ b/t/CircleTest.pm
@@ -23,14 +23,9 @@ sub get_session
{
my ( $rootobj ) = @_;
- my $session;
- $rootobj->call_method(
- method => "get_session",
- args => [ [qw( tabs )] ],
- on_result => sub { $session = $_[0] },
- );
-
- wait_for { $session };
+ my ($session) = $rootobj->call_method(
+ get_session => [qw( tabs )]
+ )->get;
return $session;
}
@@ -39,14 +34,9 @@ sub get_widget_from
{
my ( $windowitem ) = @_;
- my $widget;
- $windowitem->call_method(
- method => "get_widget",
- on_result => sub { $widget = $_[0] },
- on_error => sub { die "Test failed early - $_[-1]" },
- );
-
- wait_for { $widget };
+ my ($widget) = $windowitem->call_method(
+ 'get_widget'
+ )->get;
return $widget;
}
@@ -77,15 +67,9 @@ sub send_command
{
my ( $windowitem, $command ) = @_;
- my $done;
$windowitem->call_method(
- method => "do_command",
- args => [ $command ],
- on_result => sub { $done = 1 },
- on_error => sub { die "Test failed early - $_[-1]" },
- );
-
- wait_for { $done };
+ do_command => $command,
+ )->get;
}
0x55AA;