| 42 | } |
| 43 | |
| 44 | TEST_F(ControllerTest, notify_on_failed) { |
| 45 | brpc::SocketId id = 0; |
| 46 | ASSERT_EQ(0, brpc::Socket::Create(brpc::SocketOptions(), &id)); |
| 47 | |
| 48 | brpc::Controller cntl; |
| 49 | cntl._current_call.peer_id = id; |
| 50 | ASSERT_FALSE(cntl.IsCanceled()); |
| 51 | |
| 52 | bool cancel = false; |
| 53 | cntl.NotifyOnCancel(brpc::NewCallback(&MyCancelCallback, &cancel)); |
| 54 | // Trigger callback |
| 55 | brpc::Socket::SetFailed(id); |
| 56 | usleep(20000); // sleep a while to wait for the canceling which will be |
| 57 | // happening in another thread. |
| 58 | ASSERT_TRUE(cancel); |
| 59 | ASSERT_TRUE(cntl.IsCanceled()); |
| 60 | } |
| 61 | |
| 62 | TEST_F(ControllerTest, notify_on_destruction) { |
| 63 | brpc::SocketId id = 0; |
nothing calls this directly
no test coverage detected