| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules
_registry.h" | 5 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules
_registry.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/values_test_util.h" | 10 #include "base/test/values_test_util.h" |
| 11 #include "chrome/browser/extensions/api/declarative_content/content_predicate.h" | 11 #include "chrome/browser/extensions/api/declarative_content/content_predicate.h" |
| 12 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" | 12 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" |
| 13 #include "chrome/browser/extensions/test_extension_environment.h" | 13 #include "chrome/browser/extensions/test_extension_environment.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "content/public/browser/navigation_handle.h" | 15 #include "content/public/browser/navigation_handle.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/frame_navigate_params.h" | 17 #include "content/public/common/frame_navigate_params.h" |
| 18 #include "content/public/test/test_web_contents_factory.h" |
| 18 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 namespace extensions { | 22 namespace extensions { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 class TestPredicateEvaluator; | 26 class TestPredicateEvaluator; |
| 26 | 27 |
| 27 class TestPredicate : public ContentPredicate { | 28 class TestPredicate : public ContentPredicate { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 class DeclarativeChromeContentRulesRegistryTest : public testing::Test { | 130 class DeclarativeChromeContentRulesRegistryTest : public testing::Test { |
| 130 public: | 131 public: |
| 131 DeclarativeChromeContentRulesRegistryTest() {} | 132 DeclarativeChromeContentRulesRegistryTest() {} |
| 132 | 133 |
| 133 protected: | 134 protected: |
| 134 TestExtensionEnvironment* env() { return &env_; } | 135 TestExtensionEnvironment* env() { return &env_; } |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 TestExtensionEnvironment env_; | 138 TestExtensionEnvironment env_; |
| 139 content::TestWebContentsFactory factory_; |
| 138 | 140 |
| 139 DISALLOW_COPY_AND_ASSIGN(DeclarativeChromeContentRulesRegistryTest); | 141 DISALLOW_COPY_AND_ASSIGN(DeclarativeChromeContentRulesRegistryTest); |
| 140 }; | 142 }; |
| 141 | 143 |
| 142 TEST_F(DeclarativeChromeContentRulesRegistryTest, ActiveRulesDoesntGrow) { | 144 TEST_F(DeclarativeChromeContentRulesRegistryTest, ActiveRulesDoesntGrow) { |
| 143 TestPredicateEvaluator* evaluator = nullptr; | 145 TestPredicateEvaluator* evaluator = nullptr; |
| 144 scoped_refptr<ChromeContentRulesRegistry> registry( | 146 scoped_refptr<ChromeContentRulesRegistry> registry( |
| 145 new ChromeContentRulesRegistry(env()->profile(), nullptr, | 147 new ChromeContentRulesRegistry(env()->profile(), nullptr, |
| 146 base::Bind(&CreateTestEvaluator, | 148 base::Bind(&CreateTestEvaluator, |
| 147 &evaluator))); | 149 &evaluator))); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 registry->MonitorWebContentsForRuleEvaluation(tab.get()); | 201 registry->MonitorWebContentsForRuleEvaluation(tab.get()); |
| 200 evaluator->RequestImmediateEvaluation(tab.get(), true); | 202 evaluator->RequestImmediateEvaluation(tab.get(), true); |
| 201 EXPECT_EQ(1u, registry->GetActiveRulesCountForTesting()); | 203 EXPECT_EQ(1u, registry->GetActiveRulesCountForTesting()); |
| 202 | 204 |
| 203 evaluator->RequestEvaluationOnNextOperation(tab.get(), false); | 205 evaluator->RequestEvaluationOnNextOperation(tab.get(), false); |
| 204 registry->DidFinishNavigation(tab.get(), navigation_handle.get()); | 206 registry->DidFinishNavigation(tab.get(), navigation_handle.get()); |
| 205 EXPECT_EQ(0u, registry->GetActiveRulesCountForTesting()); | 207 EXPECT_EQ(0u, registry->GetActiveRulesCountForTesting()); |
| 206 } | 208 } |
| 207 | 209 |
| 208 } // namespace extensions | 210 } // namespace extensions |
| OLD | NEW |