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

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

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 6024 matching lines...) Expand 10 before | Expand all | Expand 10 after
6035 extension_info[0][0], extension_info[1][0], extension_info[2][0] 6035 extension_info[0][0], extension_info[1][0], extension_info[2][0]
6036 }; 6036 };
6037 6037
6038 // Each extension should end up in error. 6038 // Each extension should end up in error.
6039 ASSERT_TRUE(GetError(extension_ids[0])); 6039 ASSERT_TRUE(GetError(extension_ids[0]));
6040 EXPECT_TRUE(GetError(extension_ids[1])); 6040 EXPECT_TRUE(GetError(extension_ids[1]));
6041 EXPECT_TRUE(GetError(extension_ids[2])); 6041 EXPECT_TRUE(GetError(extension_ids[2]));
6042 6042
6043 // Accept the first extension, this will remove the error associated with 6043 // Accept the first extension, this will remove the error associated with
6044 // this extension. Also verify the other errors still exist. 6044 // this extension. Also verify the other errors still exist.
6045 GetError(extension_ids[0])->InstallUIProceed(); 6045 GetError(extension_ids[0])->OnInstallPromptDone(
6046 ExtensionInstallPrompt::Result::ACCEPTED);
6046 EXPECT_FALSE(GetError(extension_ids[0])); 6047 EXPECT_FALSE(GetError(extension_ids[0]));
6047 ASSERT_TRUE(GetError(extension_ids[1])); 6048 ASSERT_TRUE(GetError(extension_ids[1]));
6048 EXPECT_TRUE(GetError(extension_ids[2])); 6049 EXPECT_TRUE(GetError(extension_ids[2]));
6049 6050
6050 // Abort the second extension. 6051 // Abort the second extension.
6051 GetError(extension_ids[1])->InstallUIAbort(true); 6052 GetError(extension_ids[1])->OnInstallPromptDone(
6053 ExtensionInstallPrompt::Result::USER_CANCELED);
6052 EXPECT_FALSE(GetError(extension_ids[0])); 6054 EXPECT_FALSE(GetError(extension_ids[0]));
6053 EXPECT_FALSE(GetError(extension_ids[1])); 6055 EXPECT_FALSE(GetError(extension_ids[1]));
6054 ASSERT_TRUE(GetError(extension_ids[2])); 6056 ASSERT_TRUE(GetError(extension_ids[2]));
6055 6057
6056 // Finally, re-enable the third extension, all errors should be removed. 6058 // Finally, re-enable the third extension, all errors should be removed.
6057 service()->EnableExtension(extension_ids[2]); 6059 service()->EnableExtension(extension_ids[2]);
6058 EXPECT_FALSE(GetError(extension_ids[0])); 6060 EXPECT_FALSE(GetError(extension_ids[0]));
6059 EXPECT_FALSE(GetError(extension_ids[1])); 6061 EXPECT_FALSE(GetError(extension_ids[1]));
6060 EXPECT_FALSE(GetError(extension_ids[2])); 6062 EXPECT_FALSE(GetError(extension_ids[2]));
6061 6063
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
6153 EXPECT_TRUE(HasExternalInstallErrors(service_)); 6155 EXPECT_TRUE(HasExternalInstallErrors(service_));
6154 6156
6155 // We check both enabled and disabled, since these are "eventually exclusive" 6157 // We check both enabled and disabled, since these are "eventually exclusive"
6156 // sets. 6158 // sets.
6157 EXPECT_TRUE(registry()->disabled_extensions().GetByID(updates_from_webstore)); 6159 EXPECT_TRUE(registry()->disabled_extensions().GetByID(updates_from_webstore));
6158 EXPECT_FALSE(registry()->enabled_extensions().GetByID(updates_from_webstore)); 6160 EXPECT_FALSE(registry()->enabled_extensions().GetByID(updates_from_webstore));
6159 6161
6160 // Click the negative response. 6162 // Click the negative response.
6161 service_->external_install_manager() 6163 service_->external_install_manager()
6162 ->GetErrorsForTesting()[0] 6164 ->GetErrorsForTesting()[0]
6163 ->InstallUIAbort(true); 6165 ->OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED);
6164 // The Extension should be uninstalled. 6166 // The Extension should be uninstalled.
6165 EXPECT_FALSE(registry()->GetExtensionById(updates_from_webstore, 6167 EXPECT_FALSE(registry()->GetExtensionById(updates_from_webstore,
6166 ExtensionRegistry::EVERYTHING)); 6168 ExtensionRegistry::EVERYTHING));
6167 // The error should be removed. 6169 // The error should be removed.
6168 EXPECT_FALSE(HasExternalInstallErrors(service_)); 6170 EXPECT_FALSE(HasExternalInstallErrors(service_));
6169 } 6171 }
6170 6172
6171 // Test that clicking to keep the extension on an external install warning 6173 // Test that clicking to keep the extension on an external install warning
6172 // re-enables the extension. 6174 // re-enables the extension.
6173 TEST_F(ExtensionServiceTest, ExternalInstallClickToKeep) { 6175 TEST_F(ExtensionServiceTest, ExternalInstallClickToKeep) {
(...skipping 22 matching lines...) Expand all
6196 EXPECT_TRUE(HasExternalInstallErrors(service_)); 6198 EXPECT_TRUE(HasExternalInstallErrors(service_));
6197 6199
6198 // We check both enabled and disabled, since these are "eventually exclusive" 6200 // We check both enabled and disabled, since these are "eventually exclusive"
6199 // sets. 6201 // sets.
6200 EXPECT_TRUE(registry()->disabled_extensions().GetByID(updates_from_webstore)); 6202 EXPECT_TRUE(registry()->disabled_extensions().GetByID(updates_from_webstore));
6201 EXPECT_FALSE(registry()->enabled_extensions().GetByID(updates_from_webstore)); 6203 EXPECT_FALSE(registry()->enabled_extensions().GetByID(updates_from_webstore));
6202 6204
6203 // Accept the extension. 6205 // Accept the extension.
6204 service_->external_install_manager() 6206 service_->external_install_manager()
6205 ->GetErrorsForTesting()[0] 6207 ->GetErrorsForTesting()[0]
6206 ->InstallUIProceed(); 6208 ->OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED);
6207 6209
6208 // It should be enabled again. 6210 // It should be enabled again.
6209 EXPECT_TRUE(registry()->enabled_extensions().GetByID(updates_from_webstore)); 6211 EXPECT_TRUE(registry()->enabled_extensions().GetByID(updates_from_webstore));
6210 EXPECT_FALSE( 6212 EXPECT_FALSE(
6211 registry()->disabled_extensions().GetByID(updates_from_webstore)); 6213 registry()->disabled_extensions().GetByID(updates_from_webstore));
6212 6214
6213 // The error should be removed. 6215 // The error should be removed.
6214 EXPECT_FALSE(HasExternalInstallErrors(service_)); 6216 EXPECT_FALSE(HasExternalInstallErrors(service_));
6215 } 6217 }
6216 6218
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
6265 6267
6266 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 6268 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6267 content::Source<Profile>(profile()), 6269 content::Source<Profile>(profile()),
6268 content::NotificationService::NoDetails()); 6270 content::NotificationService::NoDetails());
6269 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 6271 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6270 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 6272 EXPECT_EQ(0u, registry()->enabled_extensions().size());
6271 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 6273 EXPECT_EQ(0u, registry()->disabled_extensions().size());
6272 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 6274 EXPECT_EQ(0u, registry()->terminated_extensions().size());
6273 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 6275 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
6274 } 6276 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_reenabler_unittest.cc ('k') | chrome/browser/extensions/external_install_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698