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

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

Issue 14694010: Consolidate manifest handler registration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "chrome/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h "
15 #include "chrome/common/extensions/api/extension_action/page_action_handler.h"
16 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
17 #include "chrome/common/extensions/background_info.h"
18 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_manifest_constants.h" 15 #include "chrome/common/extensions/extension_manifest_constants.h"
20 #include "chrome/common/extensions/manifest.h" 16 #include "chrome/common/extensions/manifest.h"
21 #include "chrome/common/extensions/manifest_handler.h"
22 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
23 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
24 #include "extensions/common/constants.h" 17 #include "extensions/common/constants.h"
25 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
26 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
29 22
30 using extensions::Extension; 23 using extensions::Extension;
31 using extensions::Manifest; 24 using extensions::Manifest;
32 25
33 namespace keys = extension_manifest_keys; 26 namespace keys = extension_manifest_keys;
34 27
35 class ExtensionFileUtilTest : public testing::Test { 28 class ExtensionFileUtilTest : public testing::Test {
36 protected:
37 virtual void SetUp() OVERRIDE {
38 testing::Test::SetUp();
39 (new extensions::BackgroundManifestHandler)->Register();
40 (new extensions::BrowserActionHandler)->Register();
41 (new extensions::DefaultLocaleHandler)->Register();
42 (new extensions::IconsHandler)->Register();
43 (new extensions::PageActionHandler)->Register();
44 (new extensions::ContentScriptsHandler)->Register();
45 }
46
47 virtual void TearDown() OVERRIDE {
48 extensions::ManifestHandler::ClearRegistryForTesting();
49 }
50 }; 29 };
51 30
52 TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { 31 TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) {
53 base::ScopedTempDir temp; 32 base::ScopedTempDir temp;
54 ASSERT_TRUE(temp.CreateUniqueTempDir()); 33 ASSERT_TRUE(temp.CreateUniqueTempDir());
55 34
56 // Create a source extension. 35 // Create a source extension.
57 std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 36 std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
58 std::string version("1.0"); 37 std::string version("1.0");
59 base::FilePath src = temp.path().AppendASCII(extension_id); 38 base::FilePath src = temp.path().AppendASCII(extension_id);
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( 573 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
595 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); 574 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
596 EXPECT_TRUE(extension3 == NULL); 575 EXPECT_TRUE(extension3 == NULL);
597 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", 576 EXPECT_STREQ("Could not load icon 'icon.png' for page action.",
598 error.c_str()); 577 error.c_str());
599 } 578 }
600 579
601 // TODO(aa): More tests as motivation allows. Maybe steal some from 580 // TODO(aa): More tests as motivation allows. Maybe steal some from
602 // ExtensionService? Many of them could probably be tested here without the 581 // ExtensionService? Many of them could probably be tested here without the
603 // MessageLoop shenanigans. 582 // MessageLoop shenanigans.
OLDNEW
« no previous file with comments | « chrome/common/extensions/chrome_manifest_handlers.cc ('k') | chrome/common/extensions/extension_sync_type_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698