summaryrefslogtreecommitdiff
path: root/adb/fdevent_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'adb/fdevent_test.cpp')
-rw-r--r--adb/fdevent_test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/adb/fdevent_test.cpp b/adb/fdevent_test.cpp
index bdb973a01..86e020957 100644
--- a/adb/fdevent_test.cpp
+++ b/adb/fdevent_test.cpp
@@ -173,3 +173,24 @@ TEST_F(FdeventTest, invalid_fd) {
std::thread thread(InvalidFdThreadFunc);
thread.join();
}
+
+TEST_F(FdeventTest, run_on_main_thread) {
+ std::vector<int> vec;
+
+ PrepareThread();
+ std::thread thread(fdevent_loop);
+
+ for (int i = 0; i < 100; ++i) {
+ fdevent_run_on_main_thread([i, &vec]() {
+ check_main_thread();
+ vec.push_back(i);
+ });
+ }
+
+ TerminateThread(thread);
+
+ ASSERT_EQ(100u, vec.size());
+ for (int i = 0; i < 100; ++i) {
+ ASSERT_EQ(i, vec[i]);
+ }
+}