Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry_unittest.cc

Issue 1159733004: Encapsulate CSS selector declarative content condition tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stars-declarative-content-range-for
Patch Set: iwyu Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/test/values_test_util.h" 9 #include "base/test/values_test_util.h"
10 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/extensions/test_extension_environment.h" 10 #include "chrome/browser/extensions/test_extension_environment.h"
12 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/frame_navigate_params.h" 14 #include "content/public/common/frame_navigate_params.h"
16 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 17
19 namespace extensions { 18 namespace extensions {
20 19
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 71
73 const Extension* extension = env.MakeExtension(*ParseJson( 72 const Extension* extension = env.MakeExtension(*ParseJson(
74 "{\"page_action\": {}}")); 73 "{\"page_action\": {}}"));
75 registry->AddRulesImpl(extension->id(), rules); 74 registry->AddRulesImpl(extension->id(), rules);
76 75
77 registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params); 76 registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params);
78 EXPECT_EQ(0u, active_rules(*registry.get()).size()); 77 EXPECT_EQ(0u, active_rules(*registry.get()).size());
79 78
80 std::vector<std::string> css_selectors; 79 std::vector<std::string> css_selectors;
81 css_selectors.push_back("input"); 80 css_selectors.push_back("input");
82 registry->Apply(tab.get(), css_selectors); 81 registry->UpdateMatchingCssSelectorsForTesting(tab.get(), css_selectors);
83 EXPECT_EQ(1u, active_rules(*registry.get()).size()); 82 EXPECT_EQ(1u, active_rules(*registry.get()).size());
84 83
85 // Closing the tab should erase its entry from active_rules_. 84 // Closing the tab should erase its entry from active_rules_.
86 tab.reset(); 85 tab.reset();
87 EXPECT_EQ(0u, active_rules(*registry.get()).size()); 86 EXPECT_EQ(0u, active_rules(*registry.get()).size());
88 87
89 tab = env.MakeTab(); 88 tab = env.MakeTab();
90 registry->Apply(tab.get(), css_selectors); 89 registry->UpdateMatchingCssSelectorsForTesting(tab.get(), css_selectors);
91 EXPECT_EQ(1u, active_rules(*registry.get()).size()); 90 EXPECT_EQ(1u, active_rules(*registry.get()).size());
92 // Navigating the tab should erase its entry from active_rules_ if 91 // Navigating the tab should erase its entry from active_rules_ if
93 // it no longer matches. 92 // it no longer matches.
94 registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params); 93 registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params);
95 EXPECT_EQ(0u, active_rules(*registry.get()).size()); 94 EXPECT_EQ(0u, active_rules(*registry.get()).size());
96 } 95 }
97 96
98 } // namespace 97 } // namespace
99 } // namespace extensions 98 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698