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

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

Issue 2163023002: Unify usage of logging/assert macros in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops commit on wrong branch Created 4 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
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 20 matching lines...) Expand all
31 31
32 struct TraitsExecutionModePair { 32 struct TraitsExecutionModePair {
33 TraitsExecutionModePair(const TaskTraits& traits, 33 TraitsExecutionModePair(const TaskTraits& traits,
34 ExecutionMode execution_mode) 34 ExecutionMode execution_mode)
35 : traits(traits), execution_mode(execution_mode) {} 35 : traits(traits), execution_mode(execution_mode) {}
36 36
37 TaskTraits traits; 37 TaskTraits traits;
38 ExecutionMode execution_mode; 38 ExecutionMode execution_mode;
39 }; 39 };
40 40
41 #if ENABLE_THREAD_RESTRICTIONS 41 #if DCHECK_IS_ON()
42 // Returns whether I/O calls are allowed on the current thread. 42 // Returns whether I/O calls are allowed on the current thread.
43 bool GetIOAllowed() { 43 bool GetIOAllowed() {
44 const bool previous_value = ThreadRestrictions::SetIOAllowed(true); 44 const bool previous_value = ThreadRestrictions::SetIOAllowed(true);
45 ThreadRestrictions::SetIOAllowed(previous_value); 45 ThreadRestrictions::SetIOAllowed(previous_value);
46 return previous_value; 46 return previous_value;
47 } 47 }
48 #endif 48 #endif
49 49
50 // Verify that the current thread priority and I/O restrictions are appropriate 50 // Verify that the current thread priority and I/O restrictions are appropriate
51 // to run a Task with |traits|. 51 // to run a Task with |traits|.
52 // Note: ExecutionMode is verified inside TestTaskFactory. 52 // Note: ExecutionMode is verified inside TestTaskFactory.
53 void VerifyTaskEnvironement(const TaskTraits& traits) { 53 void VerifyTaskEnvironement(const TaskTraits& traits) {
54 EXPECT_EQ(traits.priority() == TaskPriority::BACKGROUND 54 EXPECT_EQ(traits.priority() == TaskPriority::BACKGROUND
55 ? ThreadPriority::BACKGROUND 55 ? ThreadPriority::BACKGROUND
56 : ThreadPriority::NORMAL, 56 : ThreadPriority::NORMAL,
57 PlatformThread::GetCurrentThreadPriority()); 57 PlatformThread::GetCurrentThreadPriority());
58 58
59 #if ENABLE_THREAD_RESTRICTIONS 59 #if DCHECK_IS_ON()
60 // The #if above is required because GetIOAllowed() always returns true when 60 // The #if above is required because GetIOAllowed() always returns true when
61 // !ENABLE_THREAD_RESTRICTIONS, even when |traits| don't allow file I/O. 61 // !DCHECK_IS_ON(), even when |traits| don't allow file I/O.
62 EXPECT_EQ(traits.with_file_io(), GetIOAllowed()); 62 EXPECT_EQ(traits.with_file_io(), GetIOAllowed());
63 #endif 63 #endif
64 64
65 // Verify that the thread the task is running on is named as expected. 65 // Verify that the thread the task is running on is named as expected.
66 const std::string current_thread_name(PlatformThread::GetName()); 66 const std::string current_thread_name(PlatformThread::GetName());
67 EXPECT_NE(std::string::npos, current_thread_name.find("TaskScheduler")); 67 EXPECT_NE(std::string::npos, current_thread_name.find("TaskScheduler"));
68 EXPECT_NE(std::string::npos, 68 EXPECT_NE(std::string::npos,
69 current_thread_name.find( 69 current_thread_name.find(
70 traits.priority() == TaskPriority::BACKGROUND ? "Background" 70 traits.priority() == TaskPriority::BACKGROUND ? "Background"
71 : "Foreground")); 71 : "Foreground"));
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 thread->WaitForAllTasksToRun(); 249 thread->WaitForAllTasksToRun();
250 thread->Join(); 250 thread->Join();
251 } 251 }
252 } 252 }
253 253
254 // TODO(fdoray): Add tests with Sequences that move around worker pools once 254 // TODO(fdoray): Add tests with Sequences that move around worker pools once
255 // child TaskRunners are supported. 255 // child TaskRunners are supported.
256 256
257 } // namespace internal 257 } // namespace internal
258 } // namespace base 258 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698