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

Unified Diff: base/test/scoped_task_scheduler_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/test/scoped_task_scheduler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_task_scheduler_unittest.cc
diff --git a/base/test/scoped_task_scheduler_unittest.cc b/base/test/scoped_task_scheduler_unittest.cc
index f2037e1e937b11d3649a1c994ddfcb4314f93837..27552bf2679116d66aaabef961db053e7f453d84 100644
--- a/base/test/scoped_task_scheduler_unittest.cc
+++ b/base/test/scoped_task_scheduler_unittest.cc
@@ -20,6 +20,10 @@
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_WIN)
+#include <objbase.h>
+#endif // defined(OS_WIN)
+
namespace base {
namespace test {
@@ -224,6 +228,32 @@ TEST(ScopedTaskSchedulerTest, CreateSingleThreadTaskRunnerAndPostTask) {
EXPECT_TRUE(second_task_ran);
}
+#if defined(OS_WIN)
+// Verify that COM STAs work correctly from the ScopedTaskScheduler.
+TEST(ScopedTaskSchedulerTest, COMSTAAvailable) {
+ ScopedTaskScheduler scoped_task_scheduler;
+ auto com_task_runner = CreateCOMSTATaskRunnerWithTraits(TaskTraits());
+
+ bool com_task_ran = false;
+ com_task_runner->PostTask(
+ FROM_HERE,
+ Bind(
+ [](bool* com_task_ran) {
+ *com_task_ran = true;
+ HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+ if (SUCCEEDED(hr)) {
+ ADD_FAILURE() << "COM STA was not initialized on this thread";
+ CoUninitialize();
+ }
+ },
+ &com_task_ran));
+
+ RunLoop().RunUntilIdle();
+
+ EXPECT_TRUE(com_task_ran);
+}
+#endif // defined(OS_WIN)
+
TEST(ScopedTaskSchedulerTest, NonBlockShutdownTasksPostedAfterShutdownDontRun) {
ScopedTaskScheduler scoped_task_scheduler;
TaskScheduler::GetInstance()->Shutdown();
« no previous file with comments | « base/test/scoped_task_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698