| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mac/libdispatch_task_runner.h" | 5 #include "base/mac/libdispatch_task_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/mac/bind_objc_block.h" | 8 #include "base/mac/bind_objc_block.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 class LibDispatchTaskRunnerTest : public testing::Test { | 13 class LibDispatchTaskRunnerTest : public testing::Test { |
| 14 public: | 14 public: |
| 15 virtual void SetUp() override { | 15 void SetUp() override { |
| 16 task_runner_ = new base::mac::LibDispatchTaskRunner( | 16 task_runner_ = new base::mac::LibDispatchTaskRunner( |
| 17 "org.chromium.LibDispatchTaskRunnerTest"); | 17 "org.chromium.LibDispatchTaskRunnerTest"); |
| 18 } | 18 } |
| 19 | 19 |
| 20 // DispatchLastTask is used to run the main test thread's MessageLoop until | 20 // DispatchLastTask is used to run the main test thread's MessageLoop until |
| 21 // all non-delayed tasks are run on the LibDispatchTaskRunner. | 21 // all non-delayed tasks are run on the LibDispatchTaskRunner. |
| 22 void DispatchLastTask() { | 22 void DispatchLastTask() { |
| 23 dispatch_async(task_runner_->GetDispatchQueue(), ^{ | 23 dispatch_async(task_runner_->GetDispatchQueue(), ^{ |
| 24 message_loop_.PostTask(FROM_HERE, | 24 message_loop_.PostTask(FROM_HERE, |
| 25 base::MessageLoop::QuitWhenIdleClosure()); | 25 base::MessageLoop::QuitWhenIdleClosure()); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 }))); | 215 }))); |
| 216 | 216 |
| 217 const char* const expectations[] = { | 217 const char* const expectations[] = { |
| 218 "BEGIN First", | 218 "BEGIN First", |
| 219 "END First", | 219 "END First", |
| 220 "BEGIN Second", | 220 "BEGIN Second", |
| 221 "END Second" | 221 "END Second" |
| 222 }; | 222 }; |
| 223 VerifyTaskOrder(expectations, arraysize(expectations)); | 223 VerifyTaskOrder(expectations, arraysize(expectations)); |
| 224 } | 224 } |
| OLD | NEW |