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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/task_scheduler/task_scheduler_impl.h" 5 #include "base/task_scheduler/task_scheduler_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 10 matching lines...) Expand all
21 #include "base/task_scheduler/task_traits.h" 21 #include "base/task_scheduler/task_traits.h"
22 #include "base/task_scheduler/test_task_factory.h" 22 #include "base/task_scheduler/test_task_factory.h"
23 #include "base/test/test_timeouts.h" 23 #include "base/test/test_timeouts.h"
24 #include "base/threading/platform_thread.h" 24 #include "base/threading/platform_thread.h"
25 #include "base/threading/simple_thread.h" 25 #include "base/threading/simple_thread.h"
26 #include "base/threading/thread.h" 26 #include "base/threading/thread.h"
27 #include "base/threading/thread_restrictions.h" 27 #include "base/threading/thread_restrictions.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 #if defined(OS_WIN)
32 #include <objbase.h>
33 #endif // defined(OS_WIN)
34
31 namespace base { 35 namespace base {
32 namespace internal { 36 namespace internal {
33 37
34 namespace { 38 namespace {
35 39
36 struct TraitsExecutionModePair { 40 struct TraitsExecutionModePair {
37 TraitsExecutionModePair(const TaskTraits& traits, 41 TraitsExecutionModePair(const TaskTraits& traits,
38 test::ExecutionMode execution_mode) 42 test::ExecutionMode execution_mode)
39 : traits(traits), execution_mode(execution_mode) {} 43 : traits(traits), execution_mode(execution_mode) {}
40 44
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 Bind( 363 Bind(
360 [](scoped_refptr<TaskRunner> single_thread_task_runner, 364 [](scoped_refptr<TaskRunner> single_thread_task_runner,
361 WaitableEvent* task_ran) { 365 WaitableEvent* task_ran) {
362 EXPECT_FALSE(single_thread_task_runner->RunsTasksOnCurrentThread()); 366 EXPECT_FALSE(single_thread_task_runner->RunsTasksOnCurrentThread());
363 task_ran->Signal(); 367 task_ran->Signal();
364 }, 368 },
365 single_thread_task_runner, Unretained(&task_ran))); 369 single_thread_task_runner, Unretained(&task_ran)));
366 task_ran.Wait(); 370 task_ran.Wait();
367 } 371 }
368 372
373 #if defined(OS_WIN)
374 TEST_F(TaskSchedulerImplTest, COMSTATaskRunnersRunWithCOMSTA) {
375 auto com_sta_task_runner =
376 scheduler_->CreateCOMSTATaskRunnerWithTraits(TaskTraits());
377
378 WaitableEvent task_ran(WaitableEvent::ResetPolicy::MANUAL,
379 WaitableEvent::InitialState::NOT_SIGNALED);
380 com_sta_task_runner->PostTask(
381 FROM_HERE,
382 Bind(
383 [](scoped_refptr<TaskRunner> single_thread_task_runner,
384 WaitableEvent* task_ran) {
385 HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
386 if (SUCCEEDED(hr)) {
387 ADD_FAILURE() << "COM STA was not initialized on this thread";
388 CoUninitialize();
389 }
390 task_ran->Signal();
391 },
392 com_sta_task_runner, Unretained(&task_ran)));
393 task_ran.Wait();
394 }
395 #endif // defined(OS_WIN)
396
369 } // namespace internal 397 } // namespace internal
370 } // namespace base 398 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698