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. 4 5 #ifndef CHROME_TEST_BASE_CHROME_RENDER_VIEW_HOST_TEST_HARNESS_H_ 6 #define CHROME_TEST_BASE_CHROME_RENDER_VIEW_HOST_TEST_HARNESS_H_ 7 8 #include <memory> 9 #include <utility> 10 11 #include "base/compiler_specific.h" 12 #include "chrome/test/base/testing_profile.h" 13 #include "content/public/test/test_renderer_host.h" 14 15 // Wrapper around RenderViewHostTestHarness that uses a TestingProfile as 16 // browser context instead of a TestBrowserContext. 17 class ChromeRenderViewHostTestHarness 18 : public content::RenderViewHostTestHarness { 19 public: 20 // Construct a ChromeRenderViewHostTestHarness with zero or more arguments 21 // passed to content::RenderViewHostTestHarness. 22 template <typename... TaskEnvironmentTraits> ChromeRenderViewHostTestHarness(TaskEnvironmentTraits &&...traits)23 explicit ChromeRenderViewHostTestHarness(TaskEnvironmentTraits&&... traits) 24 : content::RenderViewHostTestHarness( 25 std::forward<TaskEnvironmentTraits>(traits)...) {} 26 27 ~ChromeRenderViewHostTestHarness() override; 28 29 TestingProfile* profile(); 30 31 protected: 32 // testing::Test 33 void TearDown() override; 34 35 // Returns a list of factories to use when creating the TestingProfile. 36 // Can be overridden by sub-classes if needed. 37 virtual TestingProfile::TestingFactories GetTestingFactories() const; 38 39 // Creates a TestingProfile to use as the browser context. 40 std::unique_ptr<TestingProfile> CreateTestingProfile(); 41 42 // content::RenderViewHostTestHarness. 43 std::unique_ptr<content::BrowserContext> CreateBrowserContext() final; 44 }; 45 46 #endif // CHROME_TEST_BASE_CHROME_RENDER_VIEW_HOST_TEST_HARNESS_H_ 47