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

Side by Side Diff: chrome/common/extensions/extension_unittest.cc

Issue 213009: Fix bug where we fail to install an extension that has an empty (Closed)
Patch Set: fix tests Created 11 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
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Test missing and invalid permissions array 175 // Test missing and invalid permissions array
176 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); 176 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
177 EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error)); 177 EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error));
178 ListValue* permissions = NULL; 178 ListValue* permissions = NULL;
179 input_value->GetList(keys::kPermissions, &permissions); 179 input_value->GetList(keys::kPermissions, &permissions);
180 ASSERT_FALSE(NULL == permissions); 180 ASSERT_FALSE(NULL == permissions);
181 181
182 permissions = new ListValue; 182 permissions = new ListValue;
183 input_value->Set(keys::kPermissions, permissions); 183 input_value->Set(keys::kPermissions, permissions);
184 EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error)); 184 EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error));
185 const std::vector<std::string>* error_vector = 185 EXPECT_EQ(0u, ExtensionErrorReporter::GetInstance()->GetErrors()->size());
186 ExtensionErrorReporter::GetInstance()->GetErrors();
187 const std::string log_error = error_vector->at(error_vector->size() - 1);
188 EXPECT_TRUE(MatchPattern(log_error,
189 errors::kInvalidPermissionCountWarning));
190 186
191 input_value->Set(keys::kPermissions, Value::CreateIntegerValue(9)); 187 input_value->Set(keys::kPermissions, Value::CreateIntegerValue(9));
192 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); 188 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
193 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissions)); 189 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissions));
194 190
195 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); 191 input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
196 input_value->GetList(keys::kPermissions, &permissions); 192 input_value->GetList(keys::kPermissions, &permissions);
197 permissions->Set(0, Value::CreateIntegerValue(24)); 193 permissions->Set(0, Value::CreateIntegerValue(24));
198 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); 194 EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error));
199 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); 195 EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission));
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 scoped_ptr<Extension> new_extension( 606 scoped_ptr<Extension> new_extension(
611 LoadManifest("allow_silent_upgrade", 607 LoadManifest("allow_silent_upgrade",
612 std::string(kTests[i].base_name) + "_new.json")); 608 std::string(kTests[i].base_name) + "_new.json"));
613 609
614 EXPECT_EQ(kTests[i].expect_success, 610 EXPECT_EQ(kTests[i].expect_success,
615 Extension::IsPrivilegeIncrease(old_extension.get(), 611 Extension::IsPrivilegeIncrease(old_extension.get(),
616 new_extension.get())) 612 new_extension.get()))
617 << kTests[i].base_name; 613 << kTests[i].base_name;
618 } 614 }
619 } 615 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698