Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: base/task_scheduler/task_scheduler_impl_unittest.cc

Issue 2768873007: Add Support to Get a COM STA Task Runner from the Task Scheduler API (Closed)
Patch Set: Simplify COM Init for ScopedTaskScheduler Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.cc ('k') | base/test/scoped_task_scheduler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/task_scheduler_impl_unittest.cc
diff --git a/base/task_scheduler/task_scheduler_impl_unittest.cc b/base/task_scheduler/task_scheduler_impl_unittest.cc
index bacedb7cf98747e75dc9f8987fe25b8e5027b026..1489baebe4f958f5d12477ac2dc9c19e6ed41376 100644
--- a/base/task_scheduler/task_scheduler_impl_unittest.cc
+++ b/base/task_scheduler/task_scheduler_impl_unittest.cc
@@ -28,6 +28,10 @@
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_WIN)
+#include <objbase.h>
+#endif // defined(OS_WIN)
+
namespace base {
namespace internal {
@@ -366,5 +370,29 @@ TEST_F(TaskSchedulerImplTest, SingleThreadRunsTasksOnCurrentThread) {
task_ran.Wait();
}
+#if defined(OS_WIN)
+TEST_F(TaskSchedulerImplTest, COMSTATaskRunnersRunWithCOMSTA) {
+ auto com_sta_task_runner =
+ scheduler_->CreateCOMSTATaskRunnerWithTraits(TaskTraits());
+
+ WaitableEvent task_ran(WaitableEvent::ResetPolicy::MANUAL,
+ WaitableEvent::InitialState::NOT_SIGNALED);
+ com_sta_task_runner->PostTask(
+ FROM_HERE,
+ Bind(
+ [](scoped_refptr<TaskRunner> single_thread_task_runner,
+ WaitableEvent* task_ran) {
+ HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+ if (SUCCEEDED(hr)) {
+ ADD_FAILURE() << "COM STA was not initialized on this thread";
+ CoUninitialize();
+ }
+ task_ran->Signal();
+ },
+ com_sta_task_runner, Unretained(&task_ran)));
+ task_ran.Wait();
+}
+#endif // defined(OS_WIN)
+
} // namespace internal
} // namespace base
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.cc ('k') | base/test/scoped_task_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698