| 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 "chrome/common/extensions/api/extension_action/action_info.h" | 5 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 6 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h" | 6 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h" |
| 7 #include "chrome/common/extensions/api/icons/icons_handler.h" | 7 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 8 #include "chrome/common/extensions/extension_builder.h" | 8 #include "chrome/common/extensions/extension_builder.h" |
| 9 #include "chrome/common/extensions/extension_constants.h" | 9 #include "chrome/common/extensions/extension_constants.h" |
| 10 #include "chrome/common/extensions/extension_icon_set.h" | 10 #include "chrome/common/extensions/extension_icon_set.h" |
| 11 #include "chrome/common/extensions/extension_manifest_constants.h" | 11 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 12 #include "chrome/common/extensions/feature_switch.h" | 12 #include "chrome/common/extensions/feature_switch.h" |
| 13 #include "chrome/common/extensions/manifest_handler.h" | |
| 14 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 13 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 15 #include "extensions/common/install_warning.h" | 14 #include "extensions/common/install_warning.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 17 |
| 19 namespace errors = extension_manifest_errors; | 18 namespace errors = extension_manifest_errors; |
| 20 | 19 |
| 21 namespace extensions { | 20 namespace extensions { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 std::vector<InstallWarning> StripMissingFlagWarning( | 24 std::vector<InstallWarning> StripMissingFlagWarning( |
| 26 const std::vector<InstallWarning>& install_warnings) { | 25 const std::vector<InstallWarning>& install_warnings) { |
| 27 std::vector<InstallWarning> result; | 26 std::vector<InstallWarning> result; |
| 28 for (size_t i = 0; i < install_warnings.size(); ++i) { | 27 for (size_t i = 0; i < install_warnings.size(); ++i) { |
| 29 if (install_warnings[i].message != errors::kScriptBadgeRequiresFlag) | 28 if (install_warnings[i].message != errors::kScriptBadgeRequiresFlag) |
| 30 result.push_back(install_warnings[i]); | 29 result.push_back(install_warnings[i]); |
| 31 } | 30 } |
| 32 return result; | 31 return result; |
| 33 } | 32 } |
| 34 | 33 |
| 35 class ScriptBadgeManifestTest : public ExtensionManifestTest { | 34 class ScriptBadgeManifestTest : public ExtensionManifestTest { |
| 36 protected: | 35 protected: |
| 37 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() OVERRIDE { |
| 38 ExtensionManifestTest::SetUp(); | 37 (new IconsHandler)->Register(); |
| 39 ManifestHandler::Register(extension_manifest_keys::kScriptBadge, | 38 (new ScriptBadgeHandler)->Register(); |
| 40 make_linked_ptr(new ScriptBadgeHandler)); | |
| 41 ManifestHandler::Register(extension_manifest_keys::kIcons, | |
| 42 make_linked_ptr(new IconsHandler)); | |
| 43 } | 39 } |
| 44 }; | 40 }; |
| 45 | 41 |
| 46 } // namespace | 42 } // namespace |
| 47 | 43 |
| 48 TEST_F(ScriptBadgeManifestTest, ScriptBadgeBasic) { | 44 TEST_F(ScriptBadgeManifestTest, ScriptBadgeBasic) { |
| 49 scoped_refptr<Extension> extension( | 45 scoped_refptr<Extension> extension( |
| 50 ExtensionBuilder() | 46 ExtensionBuilder() |
| 51 .SetManifest(DictionaryBuilder() | 47 .SetManifest(DictionaryBuilder() |
| 52 .Set("manifest_version", 2) | 48 .Set("manifest_version", 2) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 EXPECT_EQ(2u, default_icon.map().size()); | 147 EXPECT_EQ(2u, default_icon.map().size()); |
| 152 EXPECT_EQ("icon128.png", | 148 EXPECT_EQ("icon128.png", |
| 153 default_icon.Get(extension_misc::EXTENSION_ICON_BITTY, | 149 default_icon.Get(extension_misc::EXTENSION_ICON_BITTY, |
| 154 ExtensionIconSet::MATCH_EXACTLY)); | 150 ExtensionIconSet::MATCH_EXACTLY)); |
| 155 EXPECT_EQ("icon128.png", | 151 EXPECT_EQ("icon128.png", |
| 156 default_icon.Get(2 * extension_misc::EXTENSION_ICON_BITTY, | 152 default_icon.Get(2 * extension_misc::EXTENSION_ICON_BITTY, |
| 157 ExtensionIconSet::MATCH_EXACTLY)); | 153 ExtensionIconSet::MATCH_EXACTLY)); |
| 158 } | 154 } |
| 159 | 155 |
| 160 } // namespace extensions | 156 } // namespace extensions |
| OLD | NEW |