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

Side by Side Diff: base/task_scheduler/scheduler_worker_unittest.cc

Issue 2983143002: Revert of Disable COM Initialization on SchedulerWorkers When COM_INIT_CHECK_HOOK_ENABLED() (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « base/task_scheduler/scheduler_worker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scheduler_worker.h" 5 #include "base/task_scheduler/scheduler_worker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 12 matching lines...) Expand all
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/time/time.h" 26 #include "base/time/time.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include <objbase.h> 32 #include <objbase.h>
33
34 #include "base/win/com_init_check_hook.h"
35 #endif 33 #endif
36 34
37 using testing::_; 35 using testing::_;
38 using testing::Mock; 36 using testing::Mock;
39 using testing::Ne; 37 using testing::Ne;
40 using testing::StrictMock; 38 using testing::StrictMock;
41 39
42 namespace base { 40 namespace base {
43 namespace internal { 41 namespace internal {
44 namespace { 42 namespace {
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 // until GetWork() returns. 924 // until GetWork() returns.
927 auto worker = make_scoped_refptr(new SchedulerWorker( 925 auto worker = make_scoped_refptr(new SchedulerWorker(
928 ThreadPriority::NORMAL, std::move(delegate), &task_tracker, nullptr, 926 ThreadPriority::NORMAL, std::move(delegate), &task_tracker, nullptr,
929 SchedulerBackwardCompatibility::INIT_COM_STA)); 927 SchedulerBackwardCompatibility::INIT_COM_STA));
930 worker->Start(); 928 worker->Start();
931 worker->WakeUp(); 929 worker->WakeUp();
932 delegate_raw->WaitUntilGetWorkReturned(); 930 delegate_raw->WaitUntilGetWorkReturned();
933 931
934 // The call to CoInitializeEx() should have returned S_FALSE to indicate that 932 // The call to CoInitializeEx() should have returned S_FALSE to indicate that
935 // the COM library was already initialized on the thread. 933 // the COM library was already initialized on the thread.
936 // See SchedulerWorker::Thread::ThreadMain for why we expect two different
937 // results here.
938 #if defined(COM_INIT_CHECK_HOOK_ENABLED)
939 EXPECT_EQ(S_OK, delegate_raw->coinitialize_hresult());
940 #else
941 EXPECT_EQ(S_FALSE, delegate_raw->coinitialize_hresult()); 934 EXPECT_EQ(S_FALSE, delegate_raw->coinitialize_hresult());
942 #endif
943 935
944 worker->JoinForTesting(); 936 worker->JoinForTesting();
945 } 937 }
946 938
947 TEST(TaskSchedulerWorkerTest, BackwardCompatibilityDisabled) { 939 TEST(TaskSchedulerWorkerTest, BackwardCompatibilityDisabled) {
948 TaskTracker task_tracker; 940 TaskTracker task_tracker;
949 auto delegate = MakeUnique<CoInitializeDelegate>(); 941 auto delegate = MakeUnique<CoInitializeDelegate>();
950 CoInitializeDelegate* const delegate_raw = delegate.get(); 942 CoInitializeDelegate* const delegate_raw = delegate.get();
951 943
952 // Create a worker with backward compatibility DISABLED. Wake it up and wait 944 // Create a worker with backward compatibility DISABLED. Wake it up and wait
953 // until GetWork() returns. 945 // until GetWork() returns.
954 auto worker = make_scoped_refptr(new SchedulerWorker( 946 auto worker = make_scoped_refptr(new SchedulerWorker(
955 ThreadPriority::NORMAL, std::move(delegate), &task_tracker, nullptr, 947 ThreadPriority::NORMAL, std::move(delegate), &task_tracker, nullptr,
956 SchedulerBackwardCompatibility::DISABLED)); 948 SchedulerBackwardCompatibility::DISABLED));
957 worker->Start(); 949 worker->Start();
958 worker->WakeUp(); 950 worker->WakeUp();
959 delegate_raw->WaitUntilGetWorkReturned(); 951 delegate_raw->WaitUntilGetWorkReturned();
960 952
961 // The call to CoInitializeEx() should have returned S_OK to indicate that the 953 // The call to CoInitializeEx() should have returned S_OK to indicate that the
962 // COM library wasn't already initialized on the thread. 954 // COM library wasn't already initialized on the thread.
963 EXPECT_EQ(S_OK, delegate_raw->coinitialize_hresult()); 955 EXPECT_EQ(S_OK, delegate_raw->coinitialize_hresult());
964 956
965 worker->JoinForTesting(); 957 worker->JoinForTesting();
966 } 958 }
967 959
968 #endif // defined(OS_WIN) 960 #endif // defined(OS_WIN)
969 961
970 } // namespace internal 962 } // namespace internal
971 } // namespace base 963 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698