Merge pull request #4410 from yang-g/fixit_lame_client_c

add test for lame client transport op
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c
index 971055e..1b1955f 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.c
@@ -36,11 +36,47 @@
 #include <grpc/grpc.h>
 #include <grpc/support/alloc.h>
 #include <grpc/support/log.h>
+#include "src/core/channel/channel_stack.h"
+#include "src/core/iomgr/closure.h"
+#include "src/core/surface/channel.h"
+#include "src/core/transport/transport.h"
 #include "test/core/end2end/cq_verifier.h"
 #include "test/core/util/test_config.h"
 
+grpc_closure transport_op_cb;
+
 static void *tag(gpr_intptr x) { return (void *)x; }
 
+void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, int success) {
+  grpc_transport_op* op = arg;
+  GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE == *op->connectivity_state);
+  GPR_ASSERT(success);
+}
+
+void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, int success) { }
+
+void test_transport_op(grpc_channel *channel) {
+  grpc_transport_op op;
+  grpc_channel_element *elem;
+  grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
+  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+
+  memset(&op, 0, sizeof(op));
+  grpc_closure_init(&transport_op_cb, verify_connectivity, &op);
+
+  op.on_connectivity_state_change = &transport_op_cb;
+  op.connectivity_state = &state;
+  elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
+  elem->filter->start_transport_op(&exec_ctx, elem, &op);
+  grpc_exec_ctx_finish(&exec_ctx);
+
+  memset(&op, 0, sizeof(op));
+  grpc_closure_init(&transport_op_cb, do_nothing, NULL);
+  op.on_consumed = &transport_op_cb;
+  elem->filter->start_transport_op(&exec_ctx, elem, &op);
+  grpc_exec_ctx_finish(&exec_ctx);
+}
+
 int main(int argc, char **argv) {
   grpc_channel *chan;
   grpc_call *call;
@@ -66,6 +102,8 @@
       "lampoon:national", GRPC_STATUS_UNKNOWN, "Rpc sent on a lame channel.");
   GPR_ASSERT(chan);
 
+  test_transport_op(chan);
+
   GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE ==
              grpc_channel_check_connectivity_state(chan, 0));