Commit 44836e4f authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Add a new QUIC platform API class ScopedEnvironmentForThreads which needs to...

Add a new QUIC platform API class ScopedEnvironmentForThreads which needs to be instantiated in tests which use threads.

Merge internal change: 206067592

Change-Id: Id873cbe6dbd6d515571f36454375129c85ff5eba
Reviewed-on: https://chromium-review.googlesource.com/1150811
Commit-Queue: Zhongyi Shi <zhongyi@chromium.org>
Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579195}
parent 7fd27c4b
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "net/test/test_with_scoped_task_environment.h"
#include "net/third_party/quic/core/crypto/null_encrypter.h" #include "net/third_party/quic/core/crypto/null_encrypter.h"
#include "net/third_party/quic/core/http/quic_spdy_client_stream.h" #include "net/third_party/quic/core/http/quic_spdy_client_stream.h"
#include "net/third_party/quic/core/quic_epoll_connection_helper.h" #include "net/third_party/quic/core/quic_epoll_connection_helper.h"
...@@ -263,8 +262,7 @@ class ClientDelegate : public PacketDroppingTestWriter::Delegate { ...@@ -263,8 +262,7 @@ class ClientDelegate : public PacketDroppingTestWriter::Delegate {
QuicClient* client_; QuicClient* client_;
}; };
class EndToEndTest : public QuicTestWithParam<TestParams>, class EndToEndTest : public QuicTestWithParam<TestParams> {
public net::WithScopedTaskEnvironment {
protected: protected:
EndToEndTest() EndToEndTest()
: initialized_(false), : initialized_(false),
...@@ -594,6 +592,7 @@ class EndToEndTest : public QuicTestWithParam<TestParams>, ...@@ -594,6 +592,7 @@ class EndToEndTest : public QuicTestWithParam<TestParams>,
*client_->client()->client_session(), n); *client_->client()->client_session(), n);
} }
ScopedEnvironmentForThreads environment_;
bool initialized_; bool initialized_;
QuicSocketAddress server_address_; QuicSocketAddress server_address_;
QuicString server_hostname_; QuicString server_hostname_;
......
...@@ -14,4 +14,7 @@ using QuicTest = QuicTestImpl; ...@@ -14,4 +14,7 @@ using QuicTest = QuicTestImpl;
template <class T> template <class T>
using QuicTestWithParam = QuicTestWithParamImpl<T>; using QuicTestWithParam = QuicTestWithParamImpl<T>;
// Class which needs to be instantiated in tests which use threads.
using ScopedEnvironmentForThreads = ScopedEnvironmentForThreadsImpl;
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_TEST_H_ #endif // NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_TEST_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "net/third_party/quic/platform/api/quic_flags.h" #include "net/third_party/quic/platform/api/quic_flags.h"
#include "net/test/test_with_scoped_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h" // IWYU pragma: export #include "testing/gmock/include/gmock/gmock.h" // IWYU pragma: export
#include "testing/gtest/include/gtest/gtest.h" // IWYU pragma: export #include "testing/gtest/include/gtest/gtest.h" // IWYU pragma: export
...@@ -50,4 +51,14 @@ class QuicTestWithParamImpl : public ::testing::TestWithParam<T> { ...@@ -50,4 +51,14 @@ class QuicTestWithParamImpl : public ::testing::TestWithParam<T> {
QuicFlagSaverImpl saver_; // Save/restore all QUIC flag values. QuicFlagSaverImpl saver_; // Save/restore all QUIC flag values.
}; };
class ScopedEnvironmentForThreadsImpl {
public:
ScopedEnvironmentForThreadsImpl()
: scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO) {}
public:
base::test::ScopedTaskEnvironment scoped_task_environment_;
};
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_TEST_IMPL_H_ #endif // NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_TEST_IMPL_H_
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