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 152 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_refptr<GetExtensionByIdFunction> function = |
| 174 new GetExtensionByIdFunction(); |
173 scoped_ptr<base::Value> result(util::RunFunctionAndReturnSingleResult( | 175 scoped_ptr<base::Value> result(util::RunFunctionAndReturnSingleResult( |
174 new GetExtensionByIdFunction(), | 176 function.get(), |
175 base::StringPrintf("[\"%s\"]", kId), | 177 base::StringPrintf("[\"%s\"]", kId), |
176 browser())); | 178 browser())); |
177 ASSERT_TRUE(result.get() != NULL); | 179 ASSERT_TRUE(result.get() != NULL); |
178 ASSERT_TRUE(result->IsType(base::Value::TYPE_DICTIONARY)); | 180 ASSERT_TRUE(result->IsType(base::Value::TYPE_DICTIONARY)); |
179 base::DictionaryValue* dict = | 181 base::DictionaryValue* dict = |
180 static_cast<base::DictionaryValue*>(result.get()); | 182 static_cast<base::DictionaryValue*>(result.get()); |
181 std::string reason; | 183 std::string reason; |
182 EXPECT_TRUE(dict->GetStringASCII(keys::kDisabledReasonKey, &reason)); | 184 EXPECT_TRUE(dict->GetStringASCII(keys::kDisabledReasonKey, &reason)); |
183 EXPECT_EQ(reason, std::string(keys::kDisabledReasonPermissionsIncrease)); | 185 EXPECT_EQ(reason, std::string(keys::kDisabledReasonPermissionsIncrease)); |
184 } | 186 } |
185 | 187 |
186 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, | 188 IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, |
187 ReEnable) { | 189 ReEnable) { |
188 // Expect an error about no gesture. | 190 // Expect an error about no gesture. |
189 ReEnable(false, keys::kGestureNeededForEscalationError); | 191 ReEnable(false, keys::kGestureNeededForEscalationError); |
190 | 192 |
191 // Expect an error that user cancelled the dialog. | 193 // Expect an error that user cancelled the dialog. |
192 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 194 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
193 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 195 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
194 ReEnable(true, keys::kUserDidNotReEnableError); | 196 ReEnable(true, keys::kUserDidNotReEnableError); |
195 | 197 |
196 // This should succeed when user accepts dialog. | 198 // This should succeed when user accepts dialog. |
197 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 199 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
198 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 200 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
199 ReEnable(true, ""); | 201 ReEnable(true, ""); |
200 } | 202 } |
OLD | NEW |