| 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/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 browser()), | 94 browser()), |
| 95 keys::kUninstallCanceledError)); | 95 keys::kUninstallCanceledError)); |
| 96 | 96 |
| 97 // Make sure the extension wasn't uninstalled. | 97 // Make sure the extension wasn't uninstalled. |
| 98 EXPECT_TRUE(service->GetExtensionById(id, false) != NULL); | 98 EXPECT_TRUE(service->GetExtensionById(id, false) != NULL); |
| 99 | 99 |
| 100 // Uninstall, then accept via the confirm dialog. | 100 // Uninstall, then accept via the confirm dialog. |
| 101 uninstall_function = new UninstallFunction(); | 101 uninstall_function = new UninstallFunction(); |
| 102 UninstallFunction::SetAutoConfirmForTest(true); | 102 UninstallFunction::SetAutoConfirmForTest(true); |
| 103 | 103 |
| 104 util::RunFunctionAndReturnResult( | 104 util::RunFunctionAndReturnSingleResult( |
| 105 uninstall_function, | 105 uninstall_function, |
| 106 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), | 106 base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), |
| 107 browser()); | 107 browser()); |
| 108 | 108 |
| 109 // Make sure the extension was uninstalled. | 109 // Make sure the extension was uninstalled. |
| 110 EXPECT_TRUE(service->GetExtensionById(id, false) == NULL); | 110 EXPECT_TRUE(service->GetExtensionById(id, false) == NULL); |
| 111 } | 111 } |
| 112 | 112 |
| 113 class ExtensionManagementApiEscalationTest : public ExtensionBrowserTest { | 113 class ExtensionManagementApiEscalationTest : public ExtensionBrowserTest { |
| 114 protected: | 114 protected: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 ScopedTempDir scoped_temp_dir_; | 165 ScopedTempDir scoped_temp_dir_; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 const char ExtensionManagementApiEscalationTest::kId[] = | 168 const char ExtensionManagementApiEscalationTest::kId[] = |
| 169 "pgdpcfcocojkjfbgpiianjngphoopgmo"; | 169 "pgdpcfcocojkjfbgpiianjngphoopgmo"; |
| 170 | 170 |
| 171 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, | 171 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, |
| 172 DisabledReason) { | 172 DisabledReason) { |
| 173 scoped_ptr<base::Value> result( | 173 scoped_ptr<base::Value> result(util::RunFunctionAndReturnSingleResult( |
| 174 util::RunFunctionAndReturnResult(new GetExtensionByIdFunction(), | 174 new GetExtensionByIdFunction(), |
| 175 base::StringPrintf("[\"%s\"]", kId), | 175 base::StringPrintf("[\"%s\"]", kId), |
| 176 browser())); | 176 browser())); |
| 177 ASSERT_TRUE(result.get() != NULL); | 177 ASSERT_TRUE(result.get() != NULL); |
| 178 ASSERT_TRUE(result->IsType(base::Value::TYPE_DICTIONARY)); | 178 ASSERT_TRUE(result->IsType(base::Value::TYPE_DICTIONARY)); |
| 179 base::DictionaryValue* dict = | 179 base::DictionaryValue* dict = |
| 180 static_cast<base::DictionaryValue*>(result.get()); | 180 static_cast<base::DictionaryValue*>(result.get()); |
| 181 std::string reason; | 181 std::string reason; |
| 182 EXPECT_TRUE(dict->GetStringASCII(keys::kDisabledReasonKey, &reason)); | 182 EXPECT_TRUE(dict->GetStringASCII(keys::kDisabledReasonKey, &reason)); |
| 183 EXPECT_EQ(reason, std::string(keys::kDisabledReasonPermissionsIncrease)); | 183 EXPECT_EQ(reason, std::string(keys::kDisabledReasonPermissionsIncrease)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, | 186 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, |
| 187 ReEnable) { | 187 ReEnable) { |
| 188 // Expect an error about no gesture. | 188 // Expect an error about no gesture. |
| 189 ReEnable(false, keys::kGestureNeededForEscalationError); | 189 ReEnable(false, keys::kGestureNeededForEscalationError); |
| 190 | 190 |
| 191 // Expect an error that user cancelled the dialog. | 191 // Expect an error that user cancelled the dialog. |
| 192 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 192 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 193 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 193 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
| 194 ReEnable(true, keys::kUserDidNotReEnableError); | 194 ReEnable(true, keys::kUserDidNotReEnableError); |
| 195 | 195 |
| 196 // This should succeed when user accepts dialog. | 196 // This should succeed when user accepts dialog. |
| 197 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 197 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 198 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 198 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
| 199 ReEnable(true, ""); | 199 ReEnable(true, ""); |
| 200 } | 200 } |
| OLD | NEW |