Refactored the executor test testing a single threaded executor with mulitple tasks. I pulled the main

thread out of the array, and assigned it to it's own local var. I think this simplify's the test
making it more amenable to debugging. We are having flakiness in the iOS version of this test, so this is intended to make it absolutely clear what we are testing.

PiperOrigin-RevId: 438897634
This commit is contained in:
jfcarroll
2022-04-01 13:29:47 -07:00
committed by Copybara-Service
parent 6fd243cb6e
commit 9470516984
@@ -126,7 +126,7 @@ TEST(ExecutorTests, SingleThreadedExecutorMultipleTasksSucceeds) {
std::unique_ptr<std::vector<DWORD>> threadIds =
std::make_unique<std::vector<DWORD>>();
threadIds->push_back(GetCurrentThreadId());
auto parent_thread = GetCurrentThreadId();
// Act
for (int index = 0; index < 5; index++) {
@@ -143,12 +143,12 @@ TEST(ExecutorTests, SingleThreadedExecutorMultipleTasksSucceeds) {
// Assert
// We should've run 1 time on the main thread, and 5 times on the
// workerThread
ASSERT_EQ(threadIds->size(), 6);
ASSERT_EQ(threadIds->size(), 5);
// We should still be on the main thread
ASSERT_EQ(GetCurrentThreadId(), threadIds->at(0));
ASSERT_EQ(GetCurrentThreadId(), parent_thread);
// We should've run all runnables on the worker thread
auto workerThreadId = threadIds->at(1);
for (int index = 1; index < threadIds->size(); index++) {
auto workerThreadId = threadIds->at(0);
for (int index = 0; index < threadIds->size(); index++) {
ASSERT_EQ(threadIds->at(index), workerThreadId);
}