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

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry_with_cache_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
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/test_rules_registry.h" 5 #include "chrome/browser/extensions/api/declarative/test_rules_registry.h"
6 6
7 // Here we test the TestRulesRegistry which is the simplest possible 7 // Here we test the TestRulesRegistry which is the simplest possible
8 // implementation of RulesRegistryWithCache as a proxy for 8 // implementation of RulesRegistryWithCache as a proxy for
9 // RulesRegistryWithCache. 9 // RulesRegistryWithCache.
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 content::TestBrowserThread ui_; 62 content::TestBrowserThread ui_;
63 scoped_refptr<TestRulesRegistry> registry_; 63 scoped_refptr<TestRulesRegistry> registry_;
64 }; 64 };
65 65
66 TEST_F(RulesRegistryWithCacheTest, AddRules) { 66 TEST_F(RulesRegistryWithCacheTest, AddRules) {
67 // Check that nothing happens if the concrete RulesRegistry refuses to insert 67 // Check that nothing happens if the concrete RulesRegistry refuses to insert
68 // the rules. 68 // the rules.
69 registry_->SetResult("Error"); 69 registry_->SetResult("Error");
70 EXPECT_EQ("Error", AddRule(extension_id, rule_id)); 70 EXPECT_EQ("Error", AddRule(extension_id, rule_id));
71 EXPECT_EQ(0, GetNumberOfRules(extension_id)); 71 EXPECT_EQ(0, GetNumberOfRules(extension_id));
72 registry_->SetResult(""); 72 registry_->SetResult(std::string());
73 73
74 // Check that rules can be inserted. 74 // Check that rules can be inserted.
75 EXPECT_EQ("", AddRule(extension_id, rule_id)); 75 EXPECT_EQ("", AddRule(extension_id, rule_id));
76 EXPECT_EQ(1, GetNumberOfRules(extension_id)); 76 EXPECT_EQ(1, GetNumberOfRules(extension_id));
77 77
78 // Check that rules cannot be inserted twice with the same rule_id. 78 // Check that rules cannot be inserted twice with the same rule_id.
79 EXPECT_NE("", AddRule(extension_id, rule_id)); 79 EXPECT_NE("", AddRule(extension_id, rule_id));
80 EXPECT_EQ(1, GetNumberOfRules(extension_id)); 80 EXPECT_EQ(1, GetNumberOfRules(extension_id));
81 81
82 // Check that different extensions may use the same rule_id. 82 // Check that different extensions may use the same rule_id.
83 EXPECT_EQ("", AddRule(extension2_id, rule_id)); 83 EXPECT_EQ("", AddRule(extension2_id, rule_id));
84 EXPECT_EQ(1, GetNumberOfRules(extension_id)); 84 EXPECT_EQ(1, GetNumberOfRules(extension_id));
85 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); 85 EXPECT_EQ(1, GetNumberOfRules(extension2_id));
86 } 86 }
87 87
88 TEST_F(RulesRegistryWithCacheTest, RemoveRules) { 88 TEST_F(RulesRegistryWithCacheTest, RemoveRules) {
89 // Prime registry. 89 // Prime registry.
90 EXPECT_EQ("", AddRule(extension_id, rule_id)); 90 EXPECT_EQ("", AddRule(extension_id, rule_id));
91 EXPECT_EQ("", AddRule(extension2_id, rule_id)); 91 EXPECT_EQ("", AddRule(extension2_id, rule_id));
92 EXPECT_EQ(1, GetNumberOfRules(extension_id)); 92 EXPECT_EQ(1, GetNumberOfRules(extension_id));
93 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); 93 EXPECT_EQ(1, GetNumberOfRules(extension2_id));
94 94
95 // Check that nothing happens if the concrete RuleRegistry refuses to remove 95 // Check that nothing happens if the concrete RuleRegistry refuses to remove
96 // the rules. 96 // the rules.
97 registry_->SetResult("Error"); 97 registry_->SetResult("Error");
98 EXPECT_EQ("Error", RemoveRule(extension_id, rule_id)); 98 EXPECT_EQ("Error", RemoveRule(extension_id, rule_id));
99 EXPECT_EQ(1, GetNumberOfRules(extension_id)); 99 EXPECT_EQ(1, GetNumberOfRules(extension_id));
100 registry_->SetResult(""); 100 registry_->SetResult(std::string());
101 101
102 // Check that nothing happens if a rule does not exist. 102 // Check that nothing happens if a rule does not exist.
103 EXPECT_EQ("", RemoveRule(extension_id, "unknown_rule")); 103 EXPECT_EQ("", RemoveRule(extension_id, "unknown_rule"));
104 EXPECT_EQ(1, GetNumberOfRules(extension_id)); 104 EXPECT_EQ(1, GetNumberOfRules(extension_id));
105 105
106 // Check that rules may be removed and only for the correct extension. 106 // Check that rules may be removed and only for the correct extension.
107 EXPECT_EQ("", RemoveRule(extension_id, rule_id)); 107 EXPECT_EQ("", RemoveRule(extension_id, rule_id));
108 EXPECT_EQ(0, GetNumberOfRules(extension_id)); 108 EXPECT_EQ(0, GetNumberOfRules(extension_id));
109 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); 109 EXPECT_EQ(1, GetNumberOfRules(extension2_id));
110 } 110 }
111 111
112 TEST_F(RulesRegistryWithCacheTest, RemoveAllRules) { 112 TEST_F(RulesRegistryWithCacheTest, RemoveAllRules) {
113 // Prime registry. 113 // Prime registry.
114 EXPECT_EQ("", AddRule(extension_id, rule_id)); 114 EXPECT_EQ("", AddRule(extension_id, rule_id));
115 EXPECT_EQ("", AddRule(extension_id, rule2_id)); 115 EXPECT_EQ("", AddRule(extension_id, rule2_id));
116 EXPECT_EQ("", AddRule(extension2_id, rule_id)); 116 EXPECT_EQ("", AddRule(extension2_id, rule_id));
117 EXPECT_EQ(2, GetNumberOfRules(extension_id)); 117 EXPECT_EQ(2, GetNumberOfRules(extension_id));
118 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); 118 EXPECT_EQ(1, GetNumberOfRules(extension2_id));
119 119
120 // Check that nothing happens if the concrete RuleRegistry refuses to remove 120 // Check that nothing happens if the concrete RuleRegistry refuses to remove
121 // the rules. 121 // the rules.
122 registry_->SetResult("Error"); 122 registry_->SetResult("Error");
123 EXPECT_EQ("Error", registry_->RemoveAllRules(extension_id)); 123 EXPECT_EQ("Error", registry_->RemoveAllRules(extension_id));
124 EXPECT_EQ(2, GetNumberOfRules(extension_id)); 124 EXPECT_EQ(2, GetNumberOfRules(extension_id));
125 registry_->SetResult(""); 125 registry_->SetResult(std::string());
126 126
127 // Check that rules may be removed and only for the correct extension. 127 // Check that rules may be removed and only for the correct extension.
128 EXPECT_EQ("", registry_->RemoveAllRules(extension_id)); 128 EXPECT_EQ("", registry_->RemoveAllRules(extension_id));
129 EXPECT_EQ(0, GetNumberOfRules(extension_id)); 129 EXPECT_EQ(0, GetNumberOfRules(extension_id));
130 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); 130 EXPECT_EQ(1, GetNumberOfRules(extension2_id));
131 } 131 }
132 132
133 TEST_F(RulesRegistryWithCacheTest, GetRules) { 133 TEST_F(RulesRegistryWithCacheTest, GetRules) {
134 // Prime registry. 134 // Prime registry.
135 EXPECT_EQ("", AddRule(extension_id, rule_id)); 135 EXPECT_EQ("", AddRule(extension_id, rule_id));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 EXPECT_EQ("", AddRule(extension_id, rule_id)); 170 EXPECT_EQ("", AddRule(extension_id, rule_id));
171 EXPECT_EQ("", AddRule(extension2_id, rule_id)); 171 EXPECT_EQ("", AddRule(extension2_id, rule_id));
172 172
173 // Check that the correct rules are removed. 173 // Check that the correct rules are removed.
174 registry_->OnExtensionUnloaded(extension_id); 174 registry_->OnExtensionUnloaded(extension_id);
175 EXPECT_EQ(0, GetNumberOfRules(extension_id)); 175 EXPECT_EQ(0, GetNumberOfRules(extension_id));
176 EXPECT_EQ(1, GetNumberOfRules(extension2_id)); 176 EXPECT_EQ(1, GetNumberOfRules(extension2_id));
177 } 177 }
178 178
179 } // namespace extensions 179 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698