Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / public / test / browser_test.h
bloba9875b979f98843f49252267f1ba81d64377027b
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_H_
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_H_
8 // We only want to use InProcessBrowserTest in test targets which properly
9 // isolate each test case by running each test in a separate process.
10 // This way if a test hangs the test launcher can reliably terminate it.
12 // InProcessBrowserTest cannot be run more than once in the same address space
13 // anyway - otherwise the second test crashes.
14 #if defined(HAS_OUT_OF_PROC_TEST_RUNNER)
16 #include "base/compiler_specific.h"
17 #include "testing/gtest/include/gtest/gtest.h"
19 #define IN_PROC_BROWSER_TEST_( \
20 test_case_name, test_name, parent_class, parent_id) \
21 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
22 : public parent_class { \
23 public: \
24 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
26 protected: \
27 void RunTestOnMainThread() override; \
29 private: \
30 void TestBody() override {} \
31 static ::testing::TestInfo* const test_info_; \
32 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_case_name, \
33 test_name)); \
34 }; \
36 ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, \
37 test_name)::test_info_ = \
38 ::testing::internal::MakeAndRegisterTestInfo( \
39 #test_case_name, \
40 #test_name, \
41 "", \
42 "", \
43 ::testing::internal::CodeLocation(__FILE__, __LINE__), \
44 (parent_id), \
45 parent_class::SetUpTestCase, \
46 parent_class::TearDownTestCase, \
47 new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
48 test_case_name, test_name)>); \
49 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread()
51 #define IN_PROC_BROWSER_TEST_F(test_fixture, test_name)\
52 IN_PROC_BROWSER_TEST_(test_fixture, test_name, test_fixture,\
53 ::testing::internal::GetTypeId<test_fixture>())
55 #define IN_PROC_BROWSER_TEST_P_(test_case_name, test_name) \
56 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
57 : public test_case_name { \
58 public: \
59 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
61 protected: \
62 void RunTestOnMainThread() override; \
64 private: \
65 void TestBody() override {} \
66 static int AddToRegistry() { \
67 ::testing::UnitTest::GetInstance() \
68 ->parameterized_test_registry() \
69 .GetTestCasePatternHolder<test_case_name>( \
70 #test_case_name, \
71 ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
72 ->AddTestPattern( \
73 #test_case_name, \
74 #test_name, \
75 new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
76 test_case_name, test_name)>()); \
77 return 0; \
78 } \
79 static int gtest_registering_dummy_; \
80 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_case_name, \
81 test_name)); \
82 }; \
83 int GTEST_TEST_CLASS_NAME_(test_case_name, \
84 test_name)::gtest_registering_dummy_ = \
85 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
86 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread()
88 // Wrap the real macro with an outer macro to ensure that the parameters are
89 // evaluated (e.g., if |test_name| is prefixed with MAYBE_).
90 #define IN_PROC_BROWSER_TEST_P(test_case_name, test_name) \
91 IN_PROC_BROWSER_TEST_P_(test_case_name, test_name)
93 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER)
95 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_H_