Commit d8e00974 authored by Carlos Caballero's avatar Carlos Caballero Committed by Commit Bot

Use ScopedTaskEnvironment instead of MessageLoop

MessageLoop will go away, eventually.

ScopedTaskEnvironment will per default start a ThreadPool, which should
be fine in most of the cases. If you belive your test needs to make sure
that no ThreadPool runs let me know and I will update the patch.

DO NOT SUBMMIT

BUG=891670
This CL was uploaded by git cl split.

R=rmcelrath@chromium.org

Change-Id: Iccef22a70c2f7465a6a3da5bb717c18922d8065a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635517
Auto-Submit: Carlos Caballero <carlscab@google.com>
Reviewed-by: default avatarRobbie McElrath <rmcelrath@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664700}
parent 66e52c3a
......@@ -12,9 +12,9 @@
#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/test_mock_time_task_runner.h"
#include "net/base/chunked_upload_data_stream.h"
#include "net/base/completion_repeating_callback.h"
......@@ -58,8 +58,7 @@ class TestCallback {
class ThrottlingControllerTestHelper {
public:
ThrottlingControllerTestHelper()
: task_runner_(base::MakeRefCounted<base::TestMockTimeTaskRunner>()),
completion_callback_(base::BindRepeating(&TestCallback::Run,
: completion_callback_(base::BindRepeating(&TestCallback::Run,
base::Unretained(&callback_))),
mock_transaction_(kSimpleGET_Transaction),
buffer_(base::MakeRefCounted<net::IOBuffer>(64)),
......@@ -77,7 +76,6 @@ class ThrottlingControllerTestHelper {
&network_transaction);
transaction_.reset(
new ThrottlingNetworkTransaction(std::move(network_transaction)));
message_loop_.SetTaskRunner(task_runner_);
}
void SetNetworkState(bool offline, double download, double upload) {
......@@ -145,12 +143,12 @@ class ThrottlingControllerTestHelper {
ThrottlingNetworkTransaction* transaction() { return transaction_.get(); }
void FastForwardUntilNoTasksRemain() {
task_runner_->FastForwardUntilNoTasksRemain();
scoped_task_environment_.FastForwardUntilNoTasksRemain();
}
private:
scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
base::MessageLoop message_loop_;
base::test::ScopedTaskEnvironment scoped_task_environment_{
base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME};
MockNetworkLayer network_layer_;
TestCallback callback_;
net::CompletionRepeatingCallback completion_callback_;
......
......@@ -6,8 +6,8 @@
#include <vector>
#include "base/message_loop/message_loop.h"
#include "base/optional.h"
#include "base/test/scoped_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace network {
......@@ -16,7 +16,7 @@ namespace {
class WebSocketThrottlerTest : public ::testing::Test {
private:
base::MessageLoop message_loop_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
};
TEST(WebSocketPerProcessThrottlerTest, InitialState) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment