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

Side by Side Diff: device/bluetooth/test/bluetooth_test_win.cc

Issue 2331423002: Replace TestSimpleTaskRunner::GetPendingTasks with TakePendingTasks (Closed)
Patch Set: split test Created 4 years, 2 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 "device/bluetooth/test/bluetooth_test_win.h" 5 #include "device/bluetooth/test/bluetooth_test_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 win::GattService* target_service = 465 win::GattService* target_service =
466 GetSimulatedService(target_device, win_characteristic->GetService()); 466 GetSimulatedService(target_device, win_characteristic->GetService());
467 if (target_service == nullptr) 467 if (target_service == nullptr)
468 return nullptr; 468 return nullptr;
469 return fake_bt_le_wrapper_->GetSimulatedGattCharacteristic( 469 return fake_bt_le_wrapper_->GetSimulatedGattCharacteristic(
470 target_service, std::to_string(win_characteristic->GetAttributeHandle())); 470 target_service, std::to_string(win_characteristic->GetAttributeHandle()));
471 } 471 }
472 472
473 void BluetoothTestWin::RunPendingTasksUntilCallback() { 473 void BluetoothTestWin::RunPendingTasksUntilCallback() {
474 std::deque<base::TestPendingTask> tasks = 474 std::deque<base::TestPendingTask> tasks =
475 bluetooth_task_runner_->GetPendingTasks(); 475 bluetooth_task_runner_->TakePendingTasks();
476 bluetooth_task_runner_->ClearPendingTasks();
477 int original_callback_count = callback_count_; 476 int original_callback_count = callback_count_;
478 int original_error_callback_count = error_callback_count_; 477 int original_error_callback_count = error_callback_count_;
479 do { 478 do {
480 base::TestPendingTask task = tasks.front(); 479 base::TestPendingTask task = tasks.front();
481 tasks.pop_front(); 480 tasks.pop_front();
482 task.task.Run(); 481 task.task.Run();
483 base::RunLoop().RunUntilIdle(); 482 base::RunLoop().RunUntilIdle();
484 } while (tasks.size() && callback_count_ == original_callback_count && 483 } while (tasks.size() && callback_count_ == original_callback_count &&
485 error_callback_count_ == original_error_callback_count); 484 error_callback_count_ == original_error_callback_count);
486 485
(...skipping 11 matching lines...) Expand all
498 void BluetoothTestWin::ForceRefreshDevice() { 497 void BluetoothTestWin::ForceRefreshDevice() {
499 adapter_win_->force_update_device_for_test_ = true; 498 adapter_win_->force_update_device_for_test_ = true;
500 FinishPendingTasks(); 499 FinishPendingTasks();
501 } 500 }
502 501
503 void BluetoothTestWin::FinishPendingTasks() { 502 void BluetoothTestWin::FinishPendingTasks() {
504 bluetooth_task_runner_->RunPendingTasks(); 503 bluetooth_task_runner_->RunPendingTasks();
505 base::RunLoop().RunUntilIdle(); 504 base::RunLoop().RunUntilIdle();
506 } 505 }
507 } 506 }
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win_unittest.cc ('k') | extensions/common/one_shot_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698