OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #ifndef CONTENT_TEST_BROWSER_TEST_H_ |
| 6 #define CONTENT_TEST_BROWSER_TEST_H_ |
| 7 #pragma once |
| 8 |
| 9 // We only want to use InProcessBrowserTest in test targets which properly |
| 10 // isolate each test case by running each test in a separate process. |
| 11 // This way if a test hangs the test launcher can reliably terminate it. |
| 12 // |
| 13 // InProcessBrowserTest cannot be run more than once in the same address space |
| 14 // anyway - otherwise the second test crashes. |
| 15 #if defined(HAS_OUT_OF_PROC_TEST_RUNNER) |
| 16 |
| 17 #if defined(BROWSER_TESTS_HEADER_OVERRIDE) |
| 18 #include BROWSER_TESTS_HEADER_OVERRIDE |
| 19 #else |
| 20 #include "content/test/content_browser_test.h" |
| 21 typedef ContentBrowserTest InProcessBrowserTest; |
| 22 #endif |
| 23 |
| 24 #define IN_PROC_BROWSER_TEST_(test_case_name, test_name, parent_class,\ |
| 25 parent_id)\ |
| 26 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\ |
| 27 public:\ |
| 28 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ |
| 29 protected:\ |
| 30 virtual void RunTestOnMainThread();\ |
| 31 private:\ |
| 32 virtual void TestBody() {}\ |
| 33 static ::testing::TestInfo* const test_info_;\ |
| 34 GTEST_DISALLOW_COPY_AND_ASSIGN_(\ |
| 35 GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ |
| 36 };\ |
| 37 \ |
| 38 ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ |
| 39 ::test_info_ =\ |
| 40 ::testing::internal::MakeAndRegisterTestInfo(\ |
| 41 #test_case_name, #test_name, "", "", \ |
| 42 (parent_id), \ |
| 43 parent_class::SetUpTestCase, \ |
| 44 parent_class::TearDownTestCase, \ |
| 45 new ::testing::internal::TestFactoryImpl<\ |
| 46 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ |
| 47 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread() |
| 48 |
| 49 #define IN_PROC_BROWSER_TEST_F(test_fixture, test_name)\ |
| 50 IN_PROC_BROWSER_TEST_(test_fixture, test_name, test_fixture,\ |
| 51 ::testing::internal::GetTypeId<test_fixture>()) |
| 52 |
| 53 #define IN_PROC_BROWSER_TEST_P(test_case_name, test_name) \ |
| 54 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ |
| 55 : public test_case_name { \ |
| 56 public: \ |
| 57 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \ |
| 58 protected: \ |
| 59 virtual void RunTestOnMainThread(); \ |
| 60 private: \ |
| 61 virtual void TestBody() {} \ |
| 62 static int AddToRegistry() { \ |
| 63 ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ |
| 64 GetTestCasePatternHolder<test_case_name>(\ |
| 65 #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ |
| 66 #test_case_name, \ |
| 67 #test_name, \ |
| 68 new ::testing::internal::TestMetaFactory< \ |
| 69 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ |
| 70 return 0; \ |
| 71 } \ |
| 72 static int gtest_registering_dummy_; \ |
| 73 GTEST_DISALLOW_COPY_AND_ASSIGN_(\ |
| 74 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ |
| 75 }; \ |
| 76 int GTEST_TEST_CLASS_NAME_(test_case_name, \ |
| 77 test_name)::gtest_registering_dummy_ = \ |
| 78 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ |
| 79 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread() |
| 80 |
| 81 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) |
| 82 |
| 83 #endif // CONTENT_TEST_BROWSER_TEST_H_ |
OLD | NEW |