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

Side by Side Diff: extensions/common/file_util_unittest.cc

Issue 1541113003: Revert of Change extension icon load errors to warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual rebase Created 4 years, 12 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 | « extensions/common/file_util.cc ('k') | extensions/common/manifest_handler_helpers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "extensions/common/file_util.h" 5 #include "extensions/common/file_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 "the_id", 409 "the_id",
410 Manifest::EXTERNAL_PREF, 410 Manifest::EXTERNAL_PREF,
411 Extension::ERROR_ON_PRIVATE_KEY, 411 Extension::ERROR_ON_PRIVATE_KEY,
412 &error); 412 &error);
413 EXPECT_FALSE(extension.get()); 413 EXPECT_FALSE(extension.get());
414 EXPECT_THAT(error, 414 EXPECT_THAT(error,
415 testing::ContainsRegex( 415 testing::ContainsRegex(
416 "extension includes the key file.*ext_root.a_key.pem")); 416 "extension includes the key file.*ext_root.a_key.pem"));
417 } 417 }
418 418
419 // Try to install an extension with a zero-length icon file. 419 TEST_F(FileUtilTest, CheckZeroLengthIconFile) {
420 TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFile) {
421 base::FilePath install_dir; 420 base::FilePath install_dir;
422 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &install_dir)); 421 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &install_dir));
423 422
424 base::FilePath ext_dir = 423 // Try to install an extension with a zero-length icon file.
425 install_dir.AppendASCII("file_util").AppendASCII("bad_icon");
426
427 std::string error;
428 scoped_refptr<Extension> extension(file_util::LoadExtension(
429 ext_dir, Manifest::INTERNAL, Extension::NO_FLAGS, &error));
430 EXPECT_TRUE(extension);
431 ASSERT_EQ(2U, extension->install_warnings().size());
432
433 EXPECT_EQ("Could not load extension icon 'missing-icon.png'.",
434 extension->install_warnings()[0].message);
435 EXPECT_EQ("Could not load extension icon 'icon.png'.",
436 extension->install_warnings()[1].message);
437 }
438
439 // Try to install an unpacked extension with a zero-length icon file.
440 TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFileUnpacked) {
441 base::FilePath install_dir;
442 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &install_dir));
443
444 base::FilePath ext_dir = 424 base::FilePath ext_dir =
445 install_dir.AppendASCII("file_util").AppendASCII("bad_icon"); 425 install_dir.AppendASCII("file_util").AppendASCII("bad_icon");
446 426
447 std::string error; 427 std::string error;
448 scoped_refptr<Extension> extension(file_util::LoadExtension( 428 scoped_refptr<Extension> extension(file_util::LoadExtension(
449 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); 429 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
450 EXPECT_FALSE(extension); 430 EXPECT_TRUE(extension.get() == NULL);
451 EXPECT_EQ("Could not load extension icon 'missing-icon.png'.", error); 431 EXPECT_STREQ("Could not load extension icon 'icon.png'.", error.c_str());
452 } 432 }
453 433
454 TEST_F(FileUtilTest, ExtensionURLToRelativeFilePath) { 434 TEST_F(FileUtilTest, ExtensionURLToRelativeFilePath) {
455 #define URL_PREFIX "chrome-extension://extension-id/" 435 #define URL_PREFIX "chrome-extension://extension-id/"
456 struct TestCase { 436 struct TestCase {
457 const char* url; 437 const char* url;
458 const char* expected_relative_path; 438 const char* expected_relative_path;
459 } test_cases[] = { 439 } test_cases[] = {
460 { URL_PREFIX "simple.html", 440 { URL_PREFIX "simple.html",
461 "simple.html" }, 441 "simple.html" },
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 base::FilePath actual_path = 534 base::FilePath actual_path =
555 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); 535 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path);
556 EXPECT_EQ(expected_path.value(), actual_path.value()) << 536 EXPECT_EQ(expected_path.value(), actual_path.value()) <<
557 " For the path " << url; 537 " For the path " << url;
558 } 538 }
559 // Remove temp files. 539 // Remove temp files.
560 ASSERT_TRUE(base::DeleteFile(root_path, true)); 540 ASSERT_TRUE(base::DeleteFile(root_path, true));
561 } 541 }
562 542
563 } // namespace extensions 543 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/file_util.cc ('k') | extensions/common/manifest_handler_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698