| 59 | }; |
| 60 | |
| 61 | TEST(AsyncAccessControl, simple) { |
| 62 | AsyncAccessControl control; |
| 63 | volatile bool sent = false; |
| 64 | ASSERT_FALSE(control.mainThreadCTS()) |
| 65 | << "CTS should have no tasks waiting."; |
| 66 | |
| 67 | ScopedThread asyncThread(new boost::thread([&] { |
| 68 | RequestToSend rts(control); |
| 69 | ASSERT_TRUE(rts.request()) << "Request should be approved"; |
| 70 | ASSERT_FALSE(rts.isNested()); |
| 71 | sent = true; |
| 72 | })); |
| 73 | |
| 74 | pleaseSleep(); |
| 75 | ASSERT_FALSE(sent) << "Shouldn't have been permitted to send yet."; |
| 76 | while (!control.mainThreadCTS()) { |
| 77 | pleaseYield(); |
| 78 | } |
| 79 | ASSERT_TRUE(sent) << "Should have sent"; |
| 80 | |
| 81 | ASSERT_FALSE(control.mainThreadCTS()) |
| 82 | << "CTS should have no tasks waiting."; |
| 83 | } |
| 84 | |
| 85 | TEST(AsyncAccessControl, serialRequests) { |
| 86 | AsyncAccessControl control; |
nothing calls this directly
no test coverage detected