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

Side by Side Diff: chrome/browser/extensions/extension_error_controller_unittest.cc

Issue 508513002: Remove implicit conversions from scoped_refptr to T* in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Two more Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "chrome/browser/extensions/extension_error_controller.h" 6 #include "chrome/browser/extensions/extension_error_controller.h"
7 #include "chrome/browser/extensions/extension_error_ui.h" 7 #include "chrome/browser/extensions/extension_error_ui.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_service_test_base.h" 9 #include "chrome/browser/extensions/extension_service_test_base.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 ExtensionPrefs* ExtensionErrorControllerUnitTest::GetPrefs() { 146 ExtensionPrefs* ExtensionErrorControllerUnitTest::GetPrefs() {
147 return ExtensionPrefs::Get(profile()); 147 return ExtensionPrefs::Get(profile());
148 } 148 }
149 149
150 // Test that closing the extension alert for blacklisted extensions counts 150 // Test that closing the extension alert for blacklisted extensions counts
151 // as acknowledging them in the prefs. 151 // as acknowledging them in the prefs.
152 TEST_F(ExtensionErrorControllerUnitTest, ClosingAcknowledgesBlacklisted) { 152 TEST_F(ExtensionErrorControllerUnitTest, ClosingAcknowledgesBlacklisted) {
153 // Add a blacklisted extension. 153 // Add a blacklisted extension.
154 scoped_refptr<const Extension> extension = BuildExtension(); 154 scoped_refptr<const Extension> extension = BuildExtension();
155 ASSERT_TRUE(AddBlacklistedExtension(extension)); 155 ASSERT_TRUE(AddBlacklistedExtension(extension.get()));
156 156
157 service_->Init(); 157 service_->Init();
158 158
159 // Make sure that we created an error "ui" to warn about the blacklisted 159 // Make sure that we created an error "ui" to warn about the blacklisted
160 // extension. 160 // extension.
161 ASSERT_TRUE(g_error_ui); 161 ASSERT_TRUE(g_error_ui);
162 ExtensionErrorUI::Delegate* delegate = g_error_ui->delegate(); 162 ExtensionErrorUI::Delegate* delegate = g_error_ui->delegate();
163 ASSERT_TRUE(delegate); 163 ASSERT_TRUE(delegate);
164 164
165 // Make sure that the blacklisted extension is reported (and that no other 165 // Make sure that the blacklisted extension is reported (and that no other
166 // extensions are). 166 // extensions are).
167 const ExtensionSet& delegate_blacklisted_extensions = 167 const ExtensionSet& delegate_blacklisted_extensions =
168 delegate->GetBlacklistedExtensions(); 168 delegate->GetBlacklistedExtensions();
169 EXPECT_EQ(1u, delegate_blacklisted_extensions.size()); 169 EXPECT_EQ(1u, delegate_blacklisted_extensions.size());
170 EXPECT_TRUE(delegate_blacklisted_extensions.Contains(extension->id())); 170 EXPECT_TRUE(delegate_blacklisted_extensions.Contains(extension->id()));
171 171
172 // Close, and verify that the extension ids now acknowledged. 172 // Close, and verify that the extension ids now acknowledged.
173 g_error_ui->CloseUI(); 173 g_error_ui->CloseUI();
174 EXPECT_TRUE(GetPrefs()->IsBlacklistedExtensionAcknowledged(extension->id())); 174 EXPECT_TRUE(GetPrefs()->IsBlacklistedExtensionAcknowledged(extension->id()));
175 // Verify we cleaned up after ourselves. 175 // Verify we cleaned up after ourselves.
176 EXPECT_FALSE(g_error_ui); 176 EXPECT_FALSE(g_error_ui);
177 } 177 }
178 178
179 // Test that clicking "accept" on the extension alert counts as acknowledging 179 // Test that clicking "accept" on the extension alert counts as acknowledging
180 // blacklisted extensions. 180 // blacklisted extensions.
181 TEST_F(ExtensionErrorControllerUnitTest, AcceptingAcknowledgesBlacklisted) { 181 TEST_F(ExtensionErrorControllerUnitTest, AcceptingAcknowledgesBlacklisted) {
182 // Add a blacklisted extension. 182 // Add a blacklisted extension.
183 scoped_refptr<const Extension> extension = BuildExtension(); 183 scoped_refptr<const Extension> extension = BuildExtension();
184 ASSERT_TRUE(AddBlacklistedExtension(extension)); 184 ASSERT_TRUE(AddBlacklistedExtension(extension.get()));
185 185
186 service_->Init(); 186 service_->Init();
187 187
188 // Make sure that we created an error "ui" to warn about the blacklisted 188 // Make sure that we created an error "ui" to warn about the blacklisted
189 // extension. 189 // extension.
190 ASSERT_TRUE(g_error_ui); 190 ASSERT_TRUE(g_error_ui);
191 191
192 // Accept, and verify that the extension ids now acknowledged. 192 // Accept, and verify that the extension ids now acknowledged.
193 g_error_ui->Accept(); 193 g_error_ui->Accept();
194 EXPECT_TRUE(GetPrefs()->IsBlacklistedExtensionAcknowledged(extension->id())); 194 EXPECT_TRUE(GetPrefs()->IsBlacklistedExtensionAcknowledged(extension->id()));
195 // Verify we cleaned up after ourselves. 195 // Verify we cleaned up after ourselves.
196 EXPECT_FALSE(g_error_ui); 196 EXPECT_FALSE(g_error_ui);
197 } 197 }
198 198
199 // Test that we don't warn for extensions which are blacklisted, but have 199 // Test that we don't warn for extensions which are blacklisted, but have
200 // already been acknowledged. 200 // already been acknowledged.
201 TEST_F(ExtensionErrorControllerUnitTest, DontWarnForAcknowledgedBlacklisted) { 201 TEST_F(ExtensionErrorControllerUnitTest, DontWarnForAcknowledgedBlacklisted) {
202 scoped_refptr<const Extension> extension = BuildExtension(); 202 scoped_refptr<const Extension> extension = BuildExtension();
203 ASSERT_TRUE(AddBlacklistedExtension(extension)); 203 ASSERT_TRUE(AddBlacklistedExtension(extension.get()));
204 204
205 GetPrefs()->AcknowledgeBlacklistedExtension(extension->id()); 205 GetPrefs()->AcknowledgeBlacklistedExtension(extension->id());
206 206
207 service_->Init(); 207 service_->Init();
208 208
209 // We should never have made an alert, because the extension should already 209 // We should never have made an alert, because the extension should already
210 // be acknowledged. 210 // be acknowledged.
211 ASSERT_FALSE(g_error_ui); 211 ASSERT_FALSE(g_error_ui);
212 } 212 }
213 213
214 } // namespace extensions 214 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698