1 // Copyright 2015 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_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_CONDITION_TRACKER_TEST_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_CONDITION_TRACKER_TEST_H_
7 
8 #include <memory>
9 
10 #include "base/macros.h"
11 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/test/browser_task_environment.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/test_renderer_host.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 
19 namespace content {
20 class MockRenderProcessHost;
21 class WebContents;
22 }  // namespace content
23 
24 namespace extensions {
25 
26 // Creates a TestWebContents browser context and mocks out RenderViewHosts. The
27 // latter is done to avoid having to run renderer processes and because the
28 // actual RenderViewHost implementation depends on things not available in this
29 // configuration.
30 class DeclarativeContentConditionTrackerTest : public testing::Test {
31  public:
32   DeclarativeContentConditionTrackerTest();
33   ~DeclarativeContentConditionTrackerTest() override;
34 
35  protected:
36   // Creates a new WebContents and retains ownership.
37   std::unique_ptr<content::WebContents> MakeTab();
38 
39   // Gets the MockRenderProcessHost associated with a WebContents.
40   content::MockRenderProcessHost* GetMockRenderProcessHost(
41       content::WebContents* contents);
42 
profile()43   TestingProfile* profile() { return profile_.get(); }
44 
45   const void* GeneratePredicateGroupID();
46 
47  private:
48   content::BrowserTaskEnvironment task_environment_;
49 
50   // Enables MockRenderProcessHosts.
51   content::RenderViewHostTestEnabler render_view_host_test_enabler_;
52 
53   const std::unique_ptr<TestingProfile> profile_;
54 
55   uintptr_t next_predicate_group_id_;
56 
57   DISALLOW_COPY_AND_ASSIGN(DeclarativeContentConditionTrackerTest);
58 };
59 
60 }  // namespace extensions
61 
62 #endif  // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_CONDITION_TRACKER_TEST_H_
63