Tests: added grpcs tests with flow control (ticket #2229).

The tests fail with level-triggered event methods, fixed in 058a67435e83.
diff --git a/grpc_ssl.t b/grpc_ssl.t
index 1740c7f..b686562 100644
--- a/grpc_ssl.t
+++ b/grpc_ssl.t
@@ -29,7 +29,7 @@
 $t->{_configure_args} =~ /OpenSSL ([\d\.]+)/;
 plan(skip_all => 'OpenSSL too old') unless defined $1 and $1 ge '1.0.2';
 
-$t->write_file_expand('nginx.conf', <<'EOF')->plan(33);
+$t->write_file_expand('nginx.conf', <<'EOF')->plan(38);
 
 %%TEST_GLOBALS%%
 
@@ -56,6 +56,8 @@
         ssl_verify_client optional;
         ssl_client_certificate client.crt;
 
+        http2_body_preread_size 128k;
+
         location / {
             grpc_pass 127.0.0.1:8082;
             add_header X-Connection $connection;
@@ -66,6 +68,8 @@
         listen       127.0.0.1:8080 http2;
         server_name  localhost;
 
+        http2_body_preread_size 128k;
+
         location / {
             grpc_pass grpcs://127.0.0.1:8081;
             grpc_ssl_name localhost;
@@ -189,6 +193,37 @@
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection');
 
+# flow control
+
+$f->{http_start}('/FlowControl');
+$frames = $f->{data_len}(('Hello' x 13000) . ('x' x 550), 65535);
+my $sum = eval join '+', map { $_->{type} eq "DATA" && $_->{length} } @$frames;
+is($sum, 65535, 'flow control - iws length');
+
+TODO: {
+local $TODO = 'not yet' if ($^O eq 'MSWin32' or $^O eq 'solaris')
+	and !$t->has_version('1.21.2');
+
+$f->{update}(10);
+$f->{update_sid}(10);
+
+$frames = $f->{data_len}(undef, 10);
+($frame) = grep { $_->{type} eq "DATA" } @$frames;
+is($frame->{length}, 10, 'flow control - update length');
+is($frame->{flags}, 0, 'flow control - update flags');
+
+$f->{update_sid}(10);
+$f->{update}(10);
+
+$frames = $f->{data_len}(undef, 5);
+($frame) = grep { $_->{type} eq "DATA" } @$frames;
+is($frame->{length}, 5, 'flow control - rest length');
+is($frame->{flags}, 1, 'flow control - rest flags');
+
+}
+
+$f->{http_end}();
+
 # upstream keepalive
 
 $f->{http_start}('/KeepAlive');
@@ -263,6 +298,17 @@
 		$sid = $frame->{sid};
 		return $frames;
 	};
+	$f->{data_len} = sub {
+		my ($body, $len) = @_;
+		$s->h2_body($body) if defined $body;
+		return $c->read(all => [{ sid => $sid, length => $len }]);
+	};
+	$f->{update} = sub {
+		$c->h2_window(shift);
+	};
+	$f->{update_sid} = sub {
+		$c->h2_window(shift, $sid);
+	};
 	$f->{data} = sub {
 		my ($body, %extra) = @_;
 		$s->h2_body($body, { %extra });