| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Install an extension. | 107 // Install an extension. |
| 108 const Extension* extension = InstallExtension( | 108 const Extension* extension = InstallExtension( |
| 109 test_data_dir_.AppendASCII("api_test/management/enabled_extension"), 1); | 109 test_data_dir_.AppendASCII("api_test/management/enabled_extension"), 1); |
| 110 ASSERT_TRUE(extension); | 110 ASSERT_TRUE(extension); |
| 111 | 111 |
| 112 const std::string id = extension->id(); | 112 const std::string id = extension->id(); |
| 113 | 113 |
| 114 // Uninstall, then cancel via the confirm dialog. | 114 // Uninstall, then cancel via the confirm dialog. |
| 115 scoped_refptr<ManagementUninstallFunction> uninstall_function( | 115 scoped_refptr<ManagementUninstallFunction> uninstall_function( |
| 116 new ManagementUninstallFunction()); | 116 new ManagementUninstallFunction()); |
| 117 uninstall_function->set_user_gesture(true); |
| 117 ManagementUninstallFunction::SetAutoConfirmForTest(false); | 118 ManagementUninstallFunction::SetAutoConfirmForTest(false); |
| 118 | 119 |
| 119 EXPECT_TRUE(MatchPattern( | 120 EXPECT_TRUE(MatchPattern( |
| 120 util::RunFunctionAndReturnError( | 121 util::RunFunctionAndReturnError( |
| 121 uninstall_function.get(), | 122 uninstall_function.get(), |
| 122 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", | 123 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", |
| 123 id.c_str()), | 124 id.c_str()), |
| 124 browser()), | 125 browser()), |
| 125 keys::kUninstallCanceledError)); | 126 keys::kUninstallCanceledError)); |
| 126 | 127 |
| 127 // Make sure the extension wasn't uninstalled. | 128 // Make sure the extension wasn't uninstalled. |
| 128 EXPECT_TRUE(service->GetExtensionById(id, false) != NULL); | 129 EXPECT_TRUE(service->GetExtensionById(id, false) != NULL); |
| 129 | 130 |
| 130 // Uninstall, then accept via the confirm dialog. | 131 // Uninstall, then accept via the confirm dialog. |
| 131 uninstall_function = new ManagementUninstallFunction(); | 132 uninstall_function = new ManagementUninstallFunction(); |
| 132 ManagementUninstallFunction::SetAutoConfirmForTest(true); | 133 ManagementUninstallFunction::SetAutoConfirmForTest(true); |
| 133 | 134 uninstall_function->set_user_gesture(true); |
| 134 util::RunFunctionAndReturnSingleResult( | 135 util::RunFunctionAndReturnSingleResult( |
| 135 uninstall_function.get(), | 136 uninstall_function.get(), |
| 136 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), | 137 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), |
| 137 browser()); | 138 browser()); |
| 138 | 139 |
| 139 // Make sure the extension was uninstalled. | 140 // Make sure the extension was uninstalled. |
| 140 EXPECT_TRUE(service->GetExtensionById(id, false) == NULL); | 141 EXPECT_TRUE(service->GetExtensionById(id, false) == NULL); |
| 141 } | 142 } |
| 142 | 143 |
| 143 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, | 144 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // extension should be reloaded and enabled. | 277 // extension should be reloaded and enabled. |
| 277 ASSERT_TRUE(CrashEnabledExtension(kId)); | 278 ASSERT_TRUE(CrashEnabledExtension(kId)); |
| 278 SetEnabled(false, true, std::string()); | 279 SetEnabled(false, true, std::string()); |
| 279 SetEnabled(true, true, std::string()); | 280 SetEnabled(true, true, std::string()); |
| 280 const Extension* extension = ExtensionSystem::Get(browser()->profile()) | 281 const Extension* extension = ExtensionSystem::Get(browser()->profile()) |
| 281 ->extension_service()->GetExtensionById(kId, false); | 282 ->extension_service()->GetExtensionById(kId, false); |
| 282 EXPECT_TRUE(extension); | 283 EXPECT_TRUE(extension); |
| 283 } | 284 } |
| 284 | 285 |
| 285 } // namespace extensions | 286 } // namespace extensions |
| OLD | NEW |