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