xref: /aosp_15_r20/external/cronet/net/third_party/quiche/overrides/quiche_platform_impl/quiche_test_impl.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_TEST_IMPL_H_
6 #define NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_TEST_IMPL_H_
7 
8 #include <cstdint>
9 
10 #include "base/test/gtest_util.h"
11 #include "net/quic/platform/impl/quic_test_flags_utils.h"
12 #include "net/test/scoped_disable_exit_on_dfatal.h"
13 #include "net/test/test_with_task_environment.h"
14 #include "net/third_party/quiche/src/quiche/quic/platform/api/quic_flags.h"
15 #include "testing/gmock/include/gmock/gmock.h"      // IWYU pragma: export
16 #include "testing/gtest/include/gtest/gtest-spi.h"  // IWYU pragma: export
17 #include "testing/gtest/include/gtest/gtest.h"      // IWYU pragma: export
18 
19 namespace quiche::test {
20 
21 class QuicheTestImpl : public ::testing::Test {
22  private:
23   QuicFlagChecker checker_;
24   QuicFlagSaverImpl saver_;  // Save/restore all QUIC flag values.
25 };
26 
27 template <class T>
28 class QuicheTestWithParamImpl : public ::testing::TestWithParam<T> {
29  private:
30   QuicFlagChecker checker_;
31   QuicFlagSaverImpl saver_;  // Save/restore all QUIC flag values.
32 };
33 
34 class ScopedEnvironmentForThreadsImpl {
35  public:
ScopedEnvironmentForThreadsImpl()36   ScopedEnvironmentForThreadsImpl()
37       : task_environment_(base::test::TaskEnvironment::MainThreadType::IO) {}
38 
39  public:
40   base::test::TaskEnvironment task_environment_;
41 };
42 
43 std::string QuicheGetCommonSourcePathImpl();
44 
45 }  // namespace quiche::test
46 
47 #if GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
48 #define EXPECT_QUICHE_DEBUG_DEATH_IMPL(condition, message) \
49   EXPECT_DEBUG_DEATH(condition, message)
50 #else
51 #define EXPECT_QUICHE_DEBUG_DEATH_IMPL(condition, message) \
52   do {                                                     \
53   } while (0)
54 #endif
55 
56 #define EXPECT_QUICHE_DEATH_IMPL(condition, message) \
57   EXPECT_CHECK_DEATH_WITH(condition, message)
58 
59 #define QUICHE_TEST_DISABLED_IN_CHROME_IMPL(name) DISABLED_##name
60 
61 #define QUICHE_SLOW_TEST_IMPL(name) DISABLED_##name
62 
63 using QuicheFlagSaverImpl = QuicFlagSaverImpl;
64 using ScopedEnvironmentForThreadsImpl =
65     quiche::test::ScopedEnvironmentForThreadsImpl;
66 
67 std::string QuicheGetTestMemoryCachePathImpl();
68 
69 using QuicheScopedDisableExitOnDFatalImpl =
70     net::test::ScopedDisableExitOnDFatal;
71 
72 #endif  // NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_TEST_IMPL_H_
73